Revision of changeset "null": Bug or feature?
Simon Sapin
simon.sapin at octobus.net
Wed Jan 12 13:07:42 UTC 2022
On 12/01/2022 12:34, Dr Rainer Woitok wrote:
> Greetings,
>
> recently I stumbled upon the following:
>
> $ hg log -r null -T '{rev}\n'
> -1
> $ hg log -r -1 -T '{rev}\n'
> 665
> $ hg tip -T '{rev}\n'
> 665
> $
>
> At least commands "hg identify" and "hg status" also interpret a revis-
> ion of "-1" as "tip".
>
> Does this work as designed?
Yes, I believe so.
Internally, Mercurial identifies a revision by a plain integer: non-negative for
"real" revisions or -1 for the special null revision.
What’s passed to many command-line arguments however is not directly a revision
number but a "revset" with a whole query language:
https://www.mercurial-scm.org/repo/hg/help/revsets
In that language:
> A plain integer is treated as a revision number. Negative integers are treated as
> sequential offsets from the tip, with -1 denoting the tip, -2 denoting the
> revision prior to the tip, and so forth.
>
> […]
>
> The reserved name "null" indicates the null revision. This is the revision of an
> empty repository, and the parent of revision 0.
--
Simon Sapin
More information about the Mercurial
mailing list