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

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 13, 2014, 9:42 p.m.
Message ID <cf50d9c4b1c911eca175.1413236529@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6239/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Oct. 13, 2014, 9:42 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.

Patch

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()