From patchwork Wed Oct 3 19:10:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7, of, 8, V3] copies: add a devel debug mode to trace what copy tracing does From: Boris Feld X-Patchwork-Id: 35422 Message-Id: <2b5e633c984e0341b260.1538593850@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Cc: gregory.szorc@gmail.com Date: Wed, 03 Oct 2018 21:10:50 +0200 # HG changeset patch # User Boris Feld # Date 1536333366 14400 # Fri Sep 07 11:16:06 2018 -0400 # Node ID 2b5e633c984e0341b2606e66cfafc92f27c10876 # Parent fd0da35824d09d0a0fa66a23627dd24209c6c3b1 # EXP-Topic copy-perf # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2b5e633c984e 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@y: src@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 ..