Patchwork D8591: mergestate: move staticmethod _filectxorabsent to module level

login
register
mail settings
Submitter phabricator
Date May 28, 2020, 8:25 p.m.
Message ID <differential-rev-PHID-DREV-jgemy4fqxml3yjj33g22-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46384/
State Superseded
Headers show

Comments

phabricator - May 28, 2020, 8:25 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I suspect this was a static method just because it made merge.py feel
  less messy, but now we have a mergestate package so we can do better.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8591

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -30,6 +30,12 @@ 
     bits = bits[:-2] + bits[-1:]
     return b'\0'.join(bits)
 
+def _filectxorabsent(hexnode, ctx, f):
+    if hexnode == nullhex:
+        return filemerge.absentfilectx(ctx, f)
+    else:
+        return ctx[f]
+
 
 # Merge state record types. See ``mergestate`` docs for more.
 RECORD_LOCAL = b'L'
@@ -600,8 +606,8 @@ 
             actx = self._repo[anccommitnode]
         else:
             actx = None
-        fcd = self._filectxorabsent(localkey, wctx, dfile)
-        fco = self._filectxorabsent(onode, octx, ofile)
+        fcd = _filectxorabsent(localkey, wctx, dfile)
+        fco = _filectxorabsent(onode, octx, ofile)
         # TODO: move this to filectxorabsent
         fca = self._repo.filectx(afile, fileid=anode, changectx=actx)
         # "premerge" x flags
@@ -679,12 +685,6 @@ 
 
         return complete, r
 
-    def _filectxorabsent(self, hexnode, ctx, f):
-        if hexnode == nullhex:
-            return filemerge.absentfilectx(ctx, f)
-        else:
-            return ctx[f]
-
     def preresolve(self, dfile, wctx):
         """run premerge process for dfile