From patchwork Thu May 28 20:25:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8591: mergestate: move staticmethod _filectxorabsent to module level From: phabricator X-Patchwork-Id: 46384 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Thu, 28 May 2020 20:25:54 +0000 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 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