[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mercurial
Subject:    Re: get rev number of current working version?
From:       Matt Mackall <mpm () selenic ! com>
Date:       2007-11-28 20:12:33
Message-ID: 20071128201232.GC19691 () waste ! org
[Download RAW message or body]

On Wed, Nov 28, 2007 at 12:59:02PM -0500, Neal Becker wrote:
> On Wednesday 28 November 2007, Dustin Sallings wrote:
> > On Nov 28, 2007, at 9:12, Neal Becker wrote:
> > > [nbecker@nbecker1 ~]$ cp -al idma-cdma idma-cdma.r297
> > > [nbecker@nbecker1 ~]$ cd idma-cdma.r297/
> > > [nbecker@nbecker1 idma-cdma.r297]$ hg revert -r 297 --all
> > > reverting ...
> > > [nbecker@nbecker1 idma-cdma.r297]$ hg id
> > > 020ca3a96b03+ tip
> > > [nbecker@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)?

The answer is still "hg id". The "306+" above indicates a modified
version of 306, which is precisely what you've got.

You're misunderstanding revert. Revert is not the opposite of update,
and it has no effect on hg's notion of the version in the working
directory. Instead, revert gives you the same result as having
manually edited one or more files back to an earlier state.

You almost certainly want to do "hg update -C 297" instead.

-- 
Mathematics is the supreme nostalgia of our time.
_______________________________________________
Mercurial mailing list
Mercurial@selenic.com
http://selenic.com/mailman/listinfo/mercurial
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic