Mercurial > hg
changeset 15634:cfc15cbecc5e stable
diff: don't crash when diffing a revision with a deleted subrepo (issue3153)
When a user requested a diff between a revision (r1) that contained a subrepo
and another (r2) that did not, mercurial would crash if r1 was specified before
r2 but would execute the diff otherwise. This fixes this behavior by skipping
the missing subrepo in the diff.
author | Renato Cunha <renato@renatocunha.com> |
---|---|
date | Wed, 14 Dec 2011 12:28:00 -0200 |
parents | dc5d1394ecd1 |
children | 82f5e471792d |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Dec 15 11:13:38 2011 +0100 +++ b/mercurial/cmdutil.py Wed Dec 14 12:28:00 2011 -0200 @@ -588,8 +588,14 @@ ctx1 = repo[node1] ctx2 = repo[node2] for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): - if node2 is not None: - node2 = ctx2.substate[subpath][1] + try: + if node2 is not None: + node2 = ctx2.substate[subpath][1] + 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. + node2 = None submatch = matchmod.narrowmatcher(subpath, match) sub.diff(diffopts, node2, submatch, changes=changes, stat=stat, fp=fp, prefix=prefix)