[PATCH 6 of 7 V2] copies: add a devel debug mode to trace what copy tracing does
Boris Feld
boris.feld at octobus.net
Mon Oct 1 16:46:29 UTC 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1536333366 14400
# Fri Sep 07 11:16:06 2018 -0400
# Node ID f2217ab4eabea69017826084288abc00c0cf40b7
# Parent f0474004509e6dbb7c534b8ea27ae44d9cf71a28
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f2217ab4eabe
copies: add a devel debug mode to trace what copy tracing does
Mercurial can spend a lot of time finding renames between two commits. Having
more information about that process help (eg: many files vs 1 file, etc...)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -377,6 +377,9 @@ coreconfigitem('devel', 'user.obsmarker'
coreconfigitem('devel', 'warn-config-unknown',
default=None,
)
+coreconfigitem('devel', 'debug.copies',
+ default=False,
+)
coreconfigitem('devel', 'debug.extensions',
default=False,
)
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -163,9 +163,17 @@ 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
- limit = _findlimit(a._repo, a.rev(), b.rev())
+ repo = a._repo
+ debug = repo.ui.debugflag and repo.ui.configbool('devel', 'debug.copies')
+ dbg = repo.ui.debug
+ if debug:
+ dbg('debug.copies: looking into rename from %s to %s\n'
+ % (a, b))
+ limit = _findlimit(repo, a.rev(), b.rev())
if limit is None:
limit = -1
+ if debug:
+ dbg('debug.copies: search limit: %d\n' % limit)
am = a.manifest()
# find where new files came from
@@ -186,11 +194,20 @@ def _committedforwardcopies(a, b, match)
missing = _computeforwardmissing(a, b, match=forwardmissingmatch)
ancestrycontext = a._repo.changelog.ancestors([b.rev()], inclusive=True)
+
+ if debug:
+ dbg('debug.copies: missing file to search: %d\n' % len(missing))
+
for f in missing:
+ if debug:
+ dbg('debug.copies: tracing file: %s\n' % f)
fctx = b[f]
fctx._ancestrycontext = ancestrycontext
+
ofctx = _tracefile(fctx, am, limit)
if ofctx:
+ if debug:
+ dbg('debug.copies: rename of: %s\n' % ofctx._path)
cm[f] = ofctx.path()
return cm
@@ -226,13 +243,24 @@ def _backwardrenames(a, b):
def pathcopies(x, y, match=None):
"""find {dst at y: src at x} copy mapping for directed compare"""
+ repo = x._repo
+ debug = repo.ui.debugflag and repo.ui.configbool('devel', 'debug.copies')
+ if debug:
+ repo.ui.debug('debug.copies: searching copies from %s to %s\n'
+ % (x, y))
if x == y or not x or not y:
return {}
a = y.ancestor(x)
if a == x:
+ if debug:
+ repo.ui.debug('debug.copies: search mode: forward\n')
return _forwardcopies(x, y, match=match)
if a == y:
+ if debug:
+ repo.ui.debug('debug.copies: search mode: backward\n')
return _backwardrenames(x, y)
+ if debug:
+ repo.ui.debug('debug.copies: search mode: combined\n')
return _chain(x, y, _backwardrenames(x, a),
_forwardcopies(a, y, match=match))
diff --git a/tests/test-mv-cp-st-diff.t b/tests/test-mv-cp-st-diff.t
--- a/tests/test-mv-cp-st-diff.t
+++ b/tests/test-mv-cp-st-diff.t
@@ -1666,4 +1666,18 @@ accessing the parent of 4 (renamed) shou
@@ -0,0 +1,1 @@
+change
+Check debug output for copy tracing
+
+ $ hg status --copies --rev 'desc(dev)' --rev . --config devel.debug.copies=yes --debug
+ debug.copies: searching copies from a51f36ab1704 to 7935fd48a8f9
+ debug.copies: search mode: forward
+ debug.copies: looking into rename from a51f36ab1704 to 7935fd48a8f9
+ debug.copies: search limit: 2
+ debug.copies: missing file to search: 1
+ debug.copies: tracing file: renamed
+ debug.copies: rename of: f
+ A renamed
+ f
+ R f
+
$ cd ..
More information about the Mercurial-devel
mailing list