changeset 22909:4545c5b53013

commit: use separate variable for p1 manifest and new manifest In localrepo.commitctx(), p1's manifest is copied and used as the basis for the manifest that is about to be committed. The way the copy is updated makes it safe to use it where the original p1's manifest is wanted. For readability, though, a separate variable for each purpose would be clearer. Make it so.
author Martin von Zweigbergk <martinvonz@gmail.com>
date Mon, 13 Oct 2014 14:11:47 -0700
parents 71570f310417
children 4f2a5c7cdf78
files mercurial/localrepo.py
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Oct 13 14:34:53 2014 -0700
+++ b/mercurial/localrepo.py	Mon Oct 13 14:11:47 2014 -0700
@@ -1387,8 +1387,9 @@
             trp = weakref.proxy(tr)
 
             if ctx.files():
-                m1 = p1.manifest().copy()
+                m1 = p1.manifest()
                 m2 = p2.manifest()
+                m = m1.copy()
 
                 # check in files
                 new = {}
@@ -1404,7 +1405,7 @@
                         else:
                             new[f] = self._filecommit(fctx, m1, m2, linkrev,
                                                       trp, changed)
-                            m1.set(f, fctx.flags())
+                            m.set(f, fctx.flags())
                     except OSError, inst:
                         self.ui.warn(_("trouble committing %s!\n") % f)
                         raise
@@ -1415,13 +1416,14 @@
                         raise
 
                 # update manifest
-                m1.update(new)
+                m.update(new)
                 removed = [f for f in sorted(removed) if f in m1 or f in m2]
-                drop = [f for f in removed if f in m1]
+                drop = [f for f in removed if f in m]
                 for f in drop:
-                    del m1[f]
-                mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
-                                       p2.manifestnode(), new, drop)
+                    del m[f]
+                mn = self.manifest.add(m, trp, linkrev,
+                                       p1.manifestnode(), p2.manifestnode(),
+                                       new, drop)
                 files = changed + removed
             else:
                 mn = p1.manifestnode()