Mercurial > hg
diff mercurial/copies.py @ 40057:25b2868206e2
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 to understand what makes it slow in
an individual instance. (eg: many files vs 1 file, etc...)
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 07 Sep 2018 11:16:06 -0400 |
parents | 707c3804e607 |
children | cf01616f8d96 |
line wrap: on
line diff
--- a/mercurial/copies.py Tue Oct 02 17:34:34 2018 -0700 +++ b/mercurial/copies.py Fri Sep 07 11:16:06 2018 -0400 @@ -163,9 +163,17 @@ """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 @@ 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 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))