Incorrect file log in special cases

Matt Mackall mpm at selenic.com
Thu Sep 15 15:43:32 UTC 2011


On Thu, 2011-09-15 at 06:50 +0400, Alexander Drozdov wrote:
> 
> 15.09.2011 05:05, Greg Ward wrote:
> > On Wed, Sep 14, 2011 at 4:27 AM, Martin Geisler<mg at lazybytes.net>  wrote:
> >> I'm afraid you're right: it's an optimization and it's known as
> >>
> >>   http://mercurial.selenic.com/bts/issue1327
> >>   http://mercurial.selenic.com/bts/issue3004
> >>
> >> and probably some other issue numbers.
> >
> > We should probably publicise the known workaround for this optimization:
> >
> >    hg log --removed<filename>
> 
> hg log --removed is not exactly what I want, in my case r1 still present in the history:

Does it modify 'file'? Yes. So it's in the log. If you want to restrict
logging to a branch, that's a completely different topic, as log very
intentionally shows all branches by default.

To restrict what's shown by log, I recommend:

hg log -f   # show only ancestors of the working directory
hg log -r ::. # the revset equivalent

hg log -f -r X # show only ancestors of X
hg log -r ::X

hg log -b B  # show only changesets on branch B
hg log -r 'branch(B)'

hg log -b . # show the branch associated with the working dir
hg log -b <rev> # show the branch associated with some revision

hg log foo # fast-path history of foo, with no duplicates
hg log -f foo  # follow history from . including renames
hg log --removed foo   # slow-path history

hg log -r 'branch(B) and file(foo) and author(alexander) and not merge() and ::.'


> $ hg log --removed file
> changeset:   2:5347ab6c4652
> tag:         tip
> parent:      0:2c2bc407e5f1
> user:        sorcerer
> date:        Wed Sep 14 11:33:16 2011 +0400
> summary:     4 for default
> 
> changeset:   1:91886adde9f6
> branch:      br1
> user:        sorcerer
> date:        Wed Sep 14 11:33:16 2011 +0400
> summary:     4 for br1
> 
> changeset:   0:2c2bc407e5f1
> user:        sorcerer
> date:        Wed Sep 14 11:33:16 2011 +0400
> summary:     Initial
> 
> Also, hg annotate doesn't support --removed option so it seems there is no any workaround for it.

Nope, there is no fix for annotate.

FYI, folks, for real projects, this optimization matters:

$ time hg log drivers/char/random.c | wc
    680    2469   25547

real	0m0.570s  <- nearly instant
user	0m0.473s
sys	0m0.087s

$ time hg log --removed drivers/char/random.c | wc
    834    2976   31269  

real	0m23.574s  <- an uncomfortable 50x slower
user	0m23.052s
sys	0m0.457s

And yes, there are 22 changesets missed on the fast path above. Every
single one of them is a duplicate hands-free merge that makes a trivial
duplicate change to the file.

This is why, six years after this issue was identified, we still haven't
gotten rid of the slow path. Until some figures out a clever way to
optimize the slow path, it's 

I'll sit down and add some mention of --removed and some examples to the
log help today.

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial mailing list