How to update to latest 'public' revision with mercrial? - mercurial

Is there a way to update to the latest public revision?
I naively tried
hg up -r "phase('public')"
but that only got me
hg: parse error: unknown identifier: phase
:-)

I believe you are trying to do:
hg up -r 'public()'

Related

How to update hg with ignoring one file

When checking hg verify
portfolio/600x600/72.jpg#8: unpacking 346174023f35: revlog decompress error: Error -3 while decompressing data: incorrect data check
And I need update another files except this. Have any command in hg for do this?
for example from version 49 to 50
like this
hg update 50 -ignore portfolio/600x600/72.jpg
Updating to a revision does not support this. However you can revert selected files to a certain revision:
hg revert -rXXX FILENAME
it also supports the --exclude and --include flags, so you could try:
hg revert -r50 --all --exclude portfolio/600x600/72.jpg
Mind: the repository will be a modified state after this, should you commit, the parent will be your currently checked-out revision.

Error when splitting a mercurial repository

I have a mercurial repository hosted on bitbucket containing several folders. My goal was to split each of these folder into a separate repository. After trying a few things suggested on stackoverflow, which failed, my last throw of the dice was to replicate a mock example in the bitbucket tutorial
Even though I followed the instructions to the letter, this also failed:
hg convert -s hg -d hg --filemap mymapfile hgsplitpractice hgfreshrepo
initializing destination hgfreshrepo repository
hgsplitpractice is not a local Mercurial repository
abort: hgsplitpractice: missing or unsupported repository
This is the same error that appeared in my previous attempts to split my actual repo.
The questions are:
1. why is this failing?
2. is there any other way to split these repositories?
I was getting the same error as you did.
In my case, the problem was something really silly: I was referring to both repositories by their names instead of specifying their full path.
I hope it helps someone else.
This was failing:
hg convert -s hg -d hg --filemap mymapfile "My-old-repo" "New-repo"
This worked like a charm:
hg convert -s hg -d hg --filemap mymapfile "d:/allrepos/My-old-repo" "d:/allrepos/New-repo"
You can try to use the convert extension.
After the command:
--filemap
you can use:
exclude path/that/you/want/to/split
rename path/that/you/want/to/split .
See this thread for more: Can I split a Mercurial repository?

hg convert not actually converting?

I run the following hg command and see a whole bunch of revision numbers & their messages fly past my screen, but when it finishes the destination hg repository is empty.
hg convert -s p4 //depot/proj1/... c:\hg\proj1 --config convert.p4.startrev=1267
What am I doing wrong?
When in doubt, use the summary command. You'll probably see something like this:
$ hg sum
parent: -1:000000000000 (no revision checked out)
branch: default
commit: (clean)
update: 15225 new changesets (update)
This says "nothing checked out, on the default branch, nothing to commit, 15225 changesets if you update".
An empty repo looks like this:
$ hg sum
parent: -1:000000000000 tip (empty repository)
branch: default
commit: (clean)
update: (current)
The repository is not empty. There should be an empty directory, .hg, which contains the whole history of your project.
If you want to see the state of your repo at the latest revision, you can update your local copy with hg update.
It turned out my Perforce database had a bit of corruption in very early changesets. Once I told the convert extension to start at a later change set, the conversion went without a hitch.

Mercurial - determine where file was removed?

If you do hg log myfile -v you see a list of changesets that the file was modified in.
In our case, in the most recent changeset, the file was removed. But you can't tell this by looking at the verbose (-v) output of hg log. Is there an easy Mercurial command you can use to determine if and when a file has been removed from the repo?
Update: Note that this is on a Windows client, and we are using Mercurial v 1.4.3
Update 2: Appears the answers below would work with a more recent version of Mercurial, however an upgrade isn't in the cards right now. Any other ideas for v 1.4.3 ???
You can check which revision deleted a file (any many other interesting features) using revsets:
hg log -r 'removes(<myfile>)'
Some examples:
hg log -r 'removes(build.xml)' // where build.xml used to be in the current directory
hg log -r 'removes("**/build.xml")' // where build.xml may have been in sub directories
See hg help revsets for details.
The --removed flag should get you what you are looking for:
hg log myfile -v --removed
From the help for hg log:
--removed include revisions where files were removed
This is what I use to list all the deleted files in my repository:
hg log --template "{rev}: {file_dels}\n" | grep -v ':\s*$'

Mercurial: warn when adding files which would otherwise be ignored?

How can ask Mercurial to warn me before I add files which would otherwise be ignored?
For example, something like:
$ hg add foo.o
warning: adding ignored file foo.o
There seems to have been a patch submitted to the mailing list: https://www.mercurial-scm.org/pipermail/mercurial-devel/2008-February/004993.html
But I can't find any further references to it.
Use hg addremove. It will not add ignored files.
Extract from addremove documentation
New files are ignored if they match any of the patterns in .hgignore. As with add, these changes take effect at the next commit.
It's sort of a hacky workaround and only half what you want, but you could replace
$ hg add foo.o
with
$ hg add -I foo.o
That says "add everything but only if it's not ignored and it matches the pattern after -I".
An example:
$ ls -A
.hg .hgignore this
$ cat .hgignore
this
$ hg stat --all
? .hgignore
I this
$ hg add -I this
$ hg stat --all
? .hgignore
I this
So you can see that "this" wasn't added and is still in ignored state. Of course, that's not a warning, it's a refusal.
This won't help much on add, but you could catch it during commit by using a
pretxncommit hook.