"--rev x" also matches against the short node number
Jan Olsen
janpolsen at gmail.com
Tue May 24 19:22:21 UTC 2011
On Tue, May 24, 2011 at 20:09, Matt Mackall <mpm at selenic.com> wrote:
> > The-Big-Devil:test janpolsen$ *hg log*
> > > changeset: 0:72ab0071a9d7
> > > tag: tip
>
> You have exactly one revision..
>
I just created a new repository so I could reproduce the problem.
> > > The-Big-Devil:test janpolsen$ *hg log -r7*
> > > 'changeset: 0:72ab0071a9d7
>
> ..so this answer is an unambiguous match.
>
Background info:
Because of various reasons we log all changes (only the essential
information and not the diffs) to a database. That is done automatically by
a scheduled job which runs every fifth minute.
So lets say I have the following records in my database:
revision short node filename (more columns which are not important
here)
0 72ab0071a9d7 test_file_a
1 b3e7fa92ec23 test_file_ba
1 b3e7fa92ec23 test_file_bb
1 b3e7fa92ec23 test_file_bc
2 12387abcf612 test_file_c
..
71 98abc683efd9 test_file_x
At this point if the before mentioned job runs it will do the following.
The job selects the highest revision for my repository according to the
database (71) and increments that number by one (72).
So I want to add all changesets from 72 and up to the tip "--rev 72:tip".
If I have commited more changes sets, then there wont be a problem, because
they will all get selected with "--rev 72:tip".
However if I haven't commited any changesets, then "--rev 72:tip" will
select everything because revision 0's short node starts with 72.
The result will be, that every five minutes all change sets will get
exported (though not imported to the databae because primary key
constraints).
> If this behaviour is intentional, is there then a way where I can make
> sure
> > it's only the revision number I look at and not the short node number?
>
> This is rarely an issue in practice, but:
>
> hg log -r 'rev(7)' <- match only revision 7
> hg log -r 'id(7)' <- match only the changeset with the unambiguous
> prefix 7
>
Holy cr at p!... I didn't now about all those advanced selectors from "hg help
revsets"!
Your "hg log -r 'rev(7)'" showed me in the right direction, but is only part
of what I need. To solve the above problem I have to do "hg log --rev
'rev(72):tip'".
Thanks a ton :).
Best regards
Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20110524/53184cd5/attachment.html>
More information about the Mercurial
mailing list