[PATCH 2 of 3] localrepo: use separate variable for p1 manifest and new manifest

Martin von Zweigbergk martinvonz at gmail.com
Mon Oct 13 16:42:09 CDT 2014


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at gmail.com>
# Date 1413234707 25200
#      Mon Oct 13 14:11:47 2014 -0700
# Node ID cf50d9c4b1c911eca17575d8c92cf1ecdd66887d
# Parent  d15cebdd63433e29201c8f66f2aeb4e456bc6810
localrepo: 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.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1382,8 +1382,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 = {}
@@ -1398,7 +1399,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
@@ -1409,13 +1410,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()


More information about the Mercurial-devel mailing list