hg status and intermediate file changes

Mads Kiilerich mads at kiilerich.com
Thu Feb 24 07:09:54 CST 2011


On 02/24/2011 11:18 AM, Jason Harris wrote:
> Hi All,
>
> One of my MacHg users and code contributors Eugene Golushkov posted the following issue to me:
>
> https://bitbucket.org/jfh/machg/issue/200
>
> Towards the end of this issue he uncovered what seems to be a problem in core Mercurial:
>
> If I run:
>
> hg init bob
> cd bob
> echo one>  theFile
> hg commit -A -m "initial"
> echo two>  theFile
> hg commit -m "secondary"
> echo one>  theFile
> hg commit -m "change back"
> hg status --rev 0:2
>
> this yields the result
>
> M theFile
>
> the status command according to the documentation states:
>   "If two revisions are given, the differences between them are shown."
>
> So status is reporting 'theFile' as of version 2 is different than that as of version 0, Whereas if you actually run the diff
>
> hg diff --rev 0:2
>
> there are no differences whatsoever.

I think that is intentional and correct behavior.

The status command looks at the meta information, not at the file 
content. The file _was_ modified, and the difference between files with 
same content do in some cases matter. They have different history and 
are thus different.

Status should only look at content when it is reporting relative to the 
working directory, in which case it has to predict what commit would do 
next.

Diff will however look at the content (but only where the meta 
information says that it is relevant).

The wording in the help could perhaps be rephrased so it doesn't give 
the wrong association to the diff command. Perhaps something like "the 
changes between them" or "the status changes between them"?

> Why this is bitting us is that after having eg two branches and doing appropriate transplants and merges etc, it's really nice to compare one branch relative to another and know what are the real differences. If there are lots of false positives like this where it looks like there is a difference but in fact there isn't, ... well ...  it's much harder to sift through the files.
>
> In any case Eugene provided the fix. (I ran it through the test suite and everything seemed to pass although there was a lot of noise in the test suite since some tests are failing for me. Very likely it's my configuration though since eg the cvs tests have always failed for me, etc...)
>
> His patch is as follows:
>
> # HG changeset patch
> # User jfh<jason at jasonfharris.com>
> # Date 2011-02-24 11:10:08 +0100
> # Node ID 75323eb95610231e671d1b200c32d6205594b7a7
> # Parent  acbe171c8fbe9b789057f84fb962a9c2a966a787
> make status --rev star:finish only report true changes and not intermediate changes
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1223,7 +1223,7 @@
>                   if fn in mf1:
>                       if (mf1.flags(fn) != mf2.flags(fn) or
>                           (mf1[fn] != mf2[fn] and
> -                         (mf2[fn] or ctx1[fn].cmp(ctx2[fn])))):
> +                         ctx1[fn].cmp(ctx2[fn]))):
>                           modified.append(fn)
>                       elif listclean:
>                           clean.append(fn)
>
> Can someone confirm this is the right way to fix this? If so I will send the patch formally, along with a change to the test suite to catch this case.

I think this line of code is dead, and there shouldn't be a cmp here at all.

See 
http://www.selenic.com/pipermail/mercurial-devel/2011-February/028488.html

/Mads


More information about the Mercurial-devel mailing list