Mercurial > public > mercurial-scm > hg-stable
diff mercurial/context.py @ 23584:db03ed8cbfa3
memctx: fix manifest for removed files (issue4470)
filectxfn returns None for removed files, so we have to check for None
before computing the new file content hash for the manifest.
Includes a test that proves this works, by demonstrating that we can
show the diff of an amended commit in the committemplate.
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 15 Dec 2014 15:00:54 -0500 |
parents | 114992041625 |
children | 8063901e56cd |
line wrap: on
line diff
--- a/mercurial/context.py Fri Dec 12 15:53:17 2014 -0500 +++ b/mercurial/context.py Mon Dec 15 15:00:54 2014 -0500 @@ -1625,9 +1625,10 @@ # keep this simple for now; just worry about p1 pctx = self._parents[0] + pman = pctx.manifest() man = pctx.manifest().copy() - for f, fnode in man.iteritems(): + for f, fnode in pman.iteritems(): p1node = nullid p2node = nullid p = pctx[f].parents() # if file isn't in pctx, check p2? @@ -1635,7 +1636,12 @@ p1node = p[0].node() if len(p) > 1: p2node = p[1].node() - man[f] = revlog.hash(self[f].data(), p1node, p2node) + fctx = self[f] + if fctx is None: + # removed file + del man[f] + else: + man[f] = revlog.hash(fctx.data(), p1node, p2node) return man