[PATCH 2 of 4 stable] subrepo: fix diff/status -S of removed subrepo (issue3056)

Dov Feldstern dovdevel at gmail.com
Wed Apr 25 05:02:46 CDT 2012


# HG changeset patch
# User Dov Feldstern <dfeldstern at gmail.com>
# Date 1335346519 -10800
# Branch stable
# Node ID 53993d3679374d477ed7d4cd3e858240f1ae6467
# Parent  aaa5bc10d80dc7b974b1a9be1d9fdf9fad093dfd
subrepo: fix diff/status -S of removed subrepo (issue3056)

This changeset solves the second half of issue 3056 --- comparison of rev1 and
rev2, where some subrepo has been removed between rev1 and rev2.

The correct handling of this case is to set the state of the subrepo in rev2 to
the null state. That way, we get the correct comparison between the subrepo's
state in rev1, with the empty state, which is, effectively, its state in rev2
where it no longer exists.

diff -r aaa5bc10d80d -r 53993d367937 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Apr 25 12:35:12 2012 +0300
+++ b/mercurial/cmdutil.py	Wed Apr 25 12:35:19 2012 +0300
@@ -610,8 +610,8 @@
             except KeyError:
                 # A subrepo that existed in node1 was deleted between node1 and
                 # node2 (inclusive). Thus, ctx2's substate won't contain that
-                # subpath. The best we can do is to ignore it.
-                tempnode2 = None
+                # subpath. Treat its state in ctx2 as null.
+                tempnode2 = hex(nullid)
             submatch = matchmod.narrowmatcher(subpath, match)
             sub.diff(diffopts, tempnode2, submatch, changes=changes,
                      stat=stat, fp=fp, prefix=prefix)
diff -r aaa5bc10d80d -r 53993d367937 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed Apr 25 12:35:12 2012 +0300
+++ b/mercurial/localrepo.py	Wed Apr 25 12:35:19 2012 +0300
@@ -1442,7 +1442,12 @@
                 if working:
                     rev2 = None
                 else:
-                    rev2 = ctx2.substate[subpath][1]
+                    try:
+                        rev2 = ctx2.substate[subpath][1]
+                    except KeyError:
+                        # If the subrepo was removed between ctx1 and
+                        # ctx2, its state in ctx2 is null.
+                        rev2 = nullid
                 try:
                     submatch = matchmod.narrowmatcher(subpath, match)
                     s = sub.status(rev2, match=submatch, ignored=listignored,


More information about the Mercurial-devel mailing list