# HG changeset patch # User Martin von Zweigbergk # Date 2019-03-20 18:42:02 # Node ID 27475ae67676f68e20f0b18e7d6634ee6dd2d282 # Parent aa84bc48c2f710b41352f7b0045aa8cf838e0733 copies: extract function for deciding whether to use changeset-centric algos We'll eventually have a "experimental.copies.read-from=changeset-only" option too and I don't want to spread the logic for determining if we should use changeset-centric of filelog-centric algorithms. Differential Revision: https://phab.mercurial-scm.org/D6163 diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -160,13 +160,18 @@ def _computeforwardmissing(a, b, match=N mb = b.manifest() return mb.filesnotin(ma, match=match) +def usechangesetcentricalgo(repo): + """Checks if we should use changeset-centric copy algorithms""" + return (repo.ui.config('experimental', 'copies.read-from') == + 'compatibility') + def _committedforwardcopies(a, b, match): """Like _forwardcopies(), but b.rev() cannot be None (working copy)""" # files might have to be traced back to the fctx parent of the last # one-side-only changeset, but not further back than that repo = a._repo - if repo.ui.config('experimental', 'copies.read-from') == 'compatibility': + if usechangesetcentricalgo(repo): return _changesetforwardcopies(a, b, match) debug = repo.ui.debugflag and repo.ui.configbool('devel', 'debug.copies') diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1205,7 +1205,7 @@ def _markchanges(repo, unknown, deleted, wctx.copy(old, new) def getrenamedfn(repo, endrev=None): - if repo.ui.config('experimental', 'copies.read-from') == 'compatibility': + if copiesmod.usechangesetcentricalgo(repo): def getrenamed(fn, rev): ctx = repo[rev] p1copies = ctx.p1copies()