Search code examples
mercurial

How do I update to the last public revision in my repository?


o 911e74cd  44 minutes ago master
|
| @  f085ae95  3 minutes ago
| |  Testing 
| |
| o  4431b579  Today at 11:24 
|/   Feature
|
o  4ab195c4  Today at 04:59 

I am currently on revision f085ae95 and I would like to use one hg update command to get to 4ab195c4, which is the last ancestor that is on the public branch in the repository.


Solution

  • hg log -r "last(public() and ancestors(.))" --template "{node}" will print out the hash of the last commit on the public branch that is also an ancestor of the current commit. As such you can now chain command calss via:

    hg update `hg log -r "last(public() and ancestors(.))" --template "{node}"`
    

    or

    hg rebase -s `<commit-you-want-to-rebase>` -d `hg log -r "last(public() and ancestors(.))" --template "{node}"`