Patchwork [4,of,6,ctx-minor-fixes] memctx: simplify _manifest with new revlog nodeids

login
register
mail settings
Submitter Sean Farley
Date Sept. 19, 2018, 5:35 a.m.
Message ID <0173c0dca9d389d55a3f.1537335346@1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa>
Download mbox | patch
Permalink /patch/34823/
State Accepted
Headers show

Comments

Sean Farley - Sept. 19, 2018, 5:35 a.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1526998571 -7200
#      Tue May 22 16:16:11 2018 +0200
# Branch ctx-minor-fixes
# Node ID 0173c0dca9d389d55a3f0e8ff3bcf43dc7ef659d
# Parent  2a524ac6b6e5da11f0f8ab9c9137d44c16f724b5
memctx: simplify _manifest with new revlog nodeids

This was originally written before we had modifiednodeid and
addednodeid, so we had to get the parents of the context, the data from
the function, and then hash that.

This is much more simple now and helps refactor more code later.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
index 4149dec..3bcfe6c 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -34,11 +34,10 @@  from . import (
     patch,
     pathutil,
     phases,
     pycompat,
     repoview,
-    revlog,
     scmutil,
     sparse,
     subrepo,
     subrepoutil,
     util,
@@ -2285,21 +2284,14 @@  class memctx(committablectx):
         # keep this simple for now; just worry about p1
         pctx = self._parents[0]
         man = pctx.manifest().copy()
 
         for f in self._status.modified:
-            p1node = nullid
-            p2node = nullid
-            p = pctx[f].parents() # if file isn't in pctx, check p2?
-            if len(p) > 0:
-                p1node = p[0].filenode()
-                if len(p) > 1:
-                    p2node = p[1].filenode()
-            man[f] = revlog.hash(self[f].data(), p1node, p2node)
+            man[f] = modifiednodeid
 
         for f in self._status.added:
-            man[f] = revlog.hash(self[f].data(), nullid, nullid)
+            man[f] = addednodeid
 
         for f in self._status.removed:
             if f in man:
                 del man[f]