Patchwork [3,of,3] localrepo: update file nodeid and flags in the same place

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 13, 2014, 9:42 p.m.
Message ID <0d5f627436419322a34c.1413236530@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6240/
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 1413235127 25200
#      Mon Oct 13 14:18:47 2014 -0700
# Node ID 0d5f627436419322a34cda463c960ed3c1a6a99f
# Parent  cf50d9c4b1c911eca17575d8c92cf1ecdd66887d
localrepo: update file nodeid and flags in the same place

Now that we have a separate variable for the original 'm1' manifest,
we can safely update the nodeid of the file in the new manifest in the
same place as we update the flags.
Matt Mackall - Oct. 14, 2014, 5:24 a.m.
On Mon, 2014-10-13 at 14:42 -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@gmail.com>
> # Date 1413235127 25200
> #      Mon Oct 13 14:18:47 2014 -0700
> # Node ID 0d5f627436419322a34cda463c960ed3c1a6a99f
> # Parent  cf50d9c4b1c911eca17575d8c92cf1ecdd66887d
> localrepo: update file nodeid and flags in the same place
> 
> Now that we have a separate variable for the original 'm1' manifest,
> we can safely update the nodeid of the file in the new manifest in the
> same place as we update the flags.

These are queued for default, thanks.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1387,7 +1387,7 @@ 
                 m = m1.copy()
 
                 # check in files
-                new = {}
+                added = []
                 changed = []
                 linkrev = len(self)
                 for f in sorted(ctx.modified() + ctx.added()):
@@ -1397,8 +1397,9 @@ 
                         if fctx is None:
                             removed.append(f)
                         else:
-                            new[f] = self._filecommit(fctx, m1, m2, linkrev,
-                                                      trp, changed)
+                            added.append(f)
+                            m[f] = self._filecommit(fctx, m1, m2, linkrev,
+                                                    trp, changed)
                             m.set(f, fctx.flags())
                     except OSError, inst:
                         self.ui.warn(_("trouble committing %s!\n") % f)
@@ -1410,14 +1411,13 @@ 
                         raise
 
                 # update manifest
-                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 m]
                 for f in drop:
                     del m[f]
                 mn = self.manifest.add(m, trp, linkrev,
                                        p1.manifestnode(), p2.manifestnode(),
-                                       new, drop)
+                                       added, drop)
                 files = changed + removed
             else:
                 mn = p1.manifestnode()