hg status and intermediate file changes

Jason Harris jason at jasonfharris.com
Thu Feb 24 04:18:01 CST 2011


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. 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.

Thanks,
  Jas


More information about the Mercurial-devel mailing list