get rev number of current working version?

Steve Borho steve at borho.org
Wed Nov 28 19:12:10 UTC 2007


Neal Becker wrote:
> On Wednesday 28 November 2007, Dustin Sallings wrote:
>   
>> On Nov 28, 2007, at 9:12, Neal Becker wrote:
>>     
>>> [nbecker at nbecker1 ~]$ cp -al idma-cdma idma-cdma.r297
>>> [nbecker at nbecker1 ~]$ cd idma-cdma.r297/
>>> [nbecker at nbecker1 idma-cdma.r297]$ hg revert -r 297 --all
>>> reverting ...
>>> [nbecker at nbecker1 idma-cdma.r297]$ hg id
>>> 020ca3a96b03+ tip
>>> [nbecker at nbecker1 idma-cdma.r297]$ hg id -n
>>> 306+
>>>
>>> This is the current repo tip, not the rev 297 of the working copy.
>>>
>>> I want a way for my program to print out the revision it was built
>>> from.
>>> Presumably, the revision of the working directory is the correct
>>> thing.
>>>       
>> 	Well, this is a different case.  You're starting out on 306, but
>> you're asking mercurial to make all of the changes to 306 that are
>> required to make it look like 297.  Note that it does *not* make the
>> tree version 297, because if you commit, you'll be on 307 with a tree
>> that looks just like 297.
>>
>> 	What you're doing is very similar to a backout over several revisions.
>>
>> 	If you want you tree to *be* 297, you update to it, otherwise, it is
>> doing the right thing.
>>     
>
>
> OK, then what is a "good" way for my program to get a revision number?  I 
> think ideally the revision number should match what the working directory 
> revision is (regardless of how it got that way)?
>
>   
Mercurial doesn't keep track of a revision number per file, it only 
remembers the changeset revision that you last checked out (updated to), 
e.g. the working directory parent revision.  When you revert one or
more files to the contents of another revision, it does not change the 
working directory parent.

I guess that's a long winded way o saying you can't get the revision
number you reverted to.

--
Steve



More information about the Mercurial mailing list