diff mercurial/context.py @ 27183:0945539a3a6b

extdiff: correctly handle deleted subrepositories (issue3153) Previously, when extdiff was called on two changesets where a subrepository had been removed, an unexpected KeyError would be raised. Now, the missing subrepository will be ignored. This behavior mirrors the behavior in diffordiffstat from cmdutil.py line ~1138-1153. The KeyError is caught and the revision is set to None. try/catch of LookupError around matchmod.narrowmatcher and sub.status is removed, as LookupError is not raised anywhere within those methods or deeper calls.
author Andrew Zwicky <andrew.zwicky@gmail.com>
date Tue, 17 Nov 2015 16:42:52 -0600
parents a29db426c5ba
children 15c6eb0a51bd
line wrap: on
line diff
--- a/mercurial/context.py	Sat Nov 21 13:28:12 2015 +0900
+++ b/mercurial/context.py	Tue Nov 17 16:42:52 2015 -0600
@@ -336,17 +336,19 @@
 
         if listsubrepos:
             for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
-                rev2 = ctx2.subrev(subpath)
                 try:
-                    submatch = matchmod.narrowmatcher(subpath, match)
-                    s = sub.status(rev2, match=submatch, ignored=listignored,
-                                   clean=listclean, unknown=listunknown,
-                                   listsubrepos=True)
-                    for rfiles, sfiles in zip(r, s):
-                        rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
-                except error.LookupError:
-                    self._repo.ui.status(_("skipping missing "
-                                           "subrepository: %s\n") % subpath)
+                    rev2 = ctx2.subrev(subpath)
+                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 ignore it.
+                    rev2 = None
+                submatch = matchmod.narrowmatcher(subpath, match)
+                s = sub.status(rev2, match=submatch, ignored=listignored,
+                               clean=listclean, unknown=listunknown,
+                               listsubrepos=True)
+                for rfiles, sfiles in zip(r, s):
+                    rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
 
         for l in r:
             l.sort()