In git it's quite convenient to identify a commit relative to the latest commit in the repo with HEAD~1
.
I have searched and cannot find an equivalent for this in mercurial. I find mercurials revision numbers rather annoying.
The revset feature of Mercurial is extremely powerful (and much less arcane than git revision specification syntax): see hg help revsets
(or online at: http://www.selenic.com/mercurial/hg.1.html#specifying-revision-sets).
See here for a list of predicates (I don't know why they aren't displayed in the online doc): http://hg.intevation.org/mercurial/crew/file/e597ef52a7c2/mercurial/revset.py#l811
In your case that would be: p1(tip)
.
The correct answer is .^
or .~1
.
tip
points to the latest revision that entered the repository, not the current revision you're on. Any answers that include tip
in them are incorrect.
Mercurial's revset syntax is specified in more detail here: https://www.mercurial-scm.org/repo/hg/help/revsets
x^n
: The nth parent of x, n == 0, 1, or 2. For n == 0, x; for n == 1, the first parent of each changeset in x; for n == 2, the second parent of changeset in x.
x~n
: The nth first ancestor of x; "x~0" is x; "x~3" is "x^^^". For n < 0, the nth unambiguous descendant of x.
x^
: Equivalent to "x^1", the first parent of each changeset in x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With