C-x v i bug

Matt Mackall mpm at selenic.com
Fri Dec 18 12:16:10 CST 2009


On Fri, 2009-12-18 at 09:40 -0800, Dan Nicolaescu wrote:
> Matt Mackall <mpm at selenic.com> writes:
> 
>   > On Fri, 2009-12-18 at 07:54 -0800, Dan Nicolaescu wrote:
>   > > Martin Geisler <mg at lazybytes.net> writes:
>   > > 
>   > >   > Dan Nicolaescu <dann at ics.uci.edu> writes:
>   > >   > 
>   > >   > > Let's first talk about the original problem that started this
>   > >   > > discussion.
>   > >   > >
>   > >   > > When a file in a directory that is under mercurial control is opened
>   > >   > > in emacs, emacs runs "hg status FILE" so that it knows if it's
>   > >   > > registered or not, if it's modified, etc.
>   > >   > >
>   > >   > > Any user settings in .hgrc should be irrelevant to the above. Right?
>   > >   > 
>   > >   > Right. Many people use the color extension to get better feedback from
>   > >   > 'hg status', but if Emacs sets TERM=dumb, then the extension will
>   > >   > disable itself. I'm just mentioning color to say that there are useful
>   > >   > extensions out there that modify even basic commands like 'hg status'.
>   > >   > 
>   > >   > > It's desirable that this is as fast as possible, so processing .hgrc,
>   > >   > > initializing plugins will just waste time.
>   > >   > > After that emacs will want to know the version number for the file, for that
>   > >   > > it runs "hg log -l1 FILE", and parse it from the output.
>   > >   > > Any user settings in .hgrc should be irrelevant for this command.  Right?
>   > >   > 
>   > >   > Right, and it's even quite important that you disable localization (run
>   > >   > hg with LANGUAGE=C in the environment). Otherwise you'll end up parsing:
>   > >   > 
>   > >   >   % hg log -l1 README
>   > >   >   ændring:     9586:a41f2840f9c6
>   > >   >   bruger:      Lee Cantey <lcantey at gmail.com>
>   > >   >   dato:        Tue Oct 13 12:27:50 2009 -0700
>   > >   >   uddrag:      README: revert accidental commit
>   > >   > 
>   > >   > The user could also very well have installed a different default style
>   > >   > by setting ui.style. On the command line it's done line this:
>   > > 
>   > > Thank you, this was very useful in taking care of some issues in emacs.
>   > > 
>   > >   >   % hg log -l1 README --style=compact
>   > >   >   9586   a41f2840f9c6   2009-10-13 12:27 -0700   lcantey
>   > >   >     README: revert accidental commit
>   > >   > 
>   > >   > > [too bad that the status and version number are not available from a
>   > >   > > single command...]
>   > >   > 
>   > >   > Well, you know, files don't really have a version number with modern
>   > >   > version control systems. The entire tree has a version number... You can
>   > >   > of course ask about when a file was last touched, but I think that
>   > >   > information is getting more and more irrelevant these days.
>   > > 
>   > > In emacs the generic Version Control layer needs a version number in some case.
>   > > Here's an example from a bug report:
>   > > 
>   > > cd  /tmp
>   > > mkdir hgtest2
>   > > cd hgtest2
>   > > hg init
>   > > echo foo > foo.txt
>   > > hg add foo.txt
>   > > hg commit -m "Added foo.txt"
>   > > hg branch bar
>   > > echo bar > foo.txt
>   > > hg commit -m "Changed foo to bar"
>   > > hg update -r default
>   > > echo frobozz > frobozz.txt
>   > > hg add frobozz.txt
>   > > hg commit -m "Added frobozz.txt"
>   > > 
>   > > 
>   > > now open the file mkdir /tmp/hgtest2/foo.txt and ask to see the
>   > > annotated version, emacs does that by running
>   > > 
>   > > hg annotate -r REVISION foo.txt
>   > >
>   > > How can REVISION be obtained in this case?
>   > > It should be "0", but
>   > > hg log -l1 foo.txt
>   > > does not show that...
>   > 
>   > Version numbers are not per-file in Mercurial. The number you should use
>   > is the global number (or numbers!) reported by hg parents. This revision
>   > is also known as '.', eg 'hg annotate -r . foo.txt'. 
> 
> . is not usable in all cases.   For the example above:
> 
> hg log -r . foo.txt 
> 
> does not work, it does not show anything.

I just tested it with the above commands and it works at least as far
back as 1.0.

> works.
> 
> So it seems that getting the result of hg parents is TRTD.
> 
>   > You're probably thinking "but I actually want to report the last
>   > changeset this file was touched in to be more like CVS". 
> 
> Nope, not at all.  Nothing is trying to be like CVS here.
> 
>   > As a side note, if you want history relative to the working directory
>   > (and not just all of history), you'll want the -f flag to log.
> 
> What's the more useful version that gives the user a better idea what
> happened to the file in question?

Depends.

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list