debugcommands: add a debugpathcopies command
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 25 Jan 2019 14:41:53 -0800
changeset 41515 7dc160a57025
parent 41514 888e8b36b8d9
child 41516 d65519e5dd04
debugcommands: add a debugpathcopies command I've been working on storing copy metadata in the changelog instead of the filelog and this has been useful for debugging. Do we usually add tests for these? Differential Revision: https://phab.mercurial-scm.org/D5791
mercurial/debugcommands.py
tests/test-completion.t
tests/test-help.t
--- a/mercurial/debugcommands.py	Fri Feb 01 20:21:04 2019 -0500
+++ b/mercurial/debugcommands.py	Fri Jan 25 14:41:53 2019 -0800
@@ -38,6 +38,7 @@
     cmdutil,
     color,
     context,
+    copies,
     dagparser,
     encoding,
     error,
@@ -1804,6 +1805,18 @@
     ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
     ui.write('\n')
 
+@command('debugpathcopies',
+         cmdutil.walkopts,
+         'hg debugcopies REV1 REV2 [FILE]',
+         inferrepo=True)
+def debugpathcopies(ui, repo, rev1, rev2, *pats, **opts):
+    """show copies between two revisions"""
+    ctx1 = scmutil.revsingle(repo, rev1)
+    ctx2 = scmutil.revsingle(repo, rev2)
+    m = scmutil.match(ctx1, pats, opts)
+    for dst, src in copies.pathcopies(ctx1, ctx2, m).items():
+        ui.write('%s -> %s\n' % (src, dst))
+
 @command('debugpeer', [], _('PATH'), norepo=True)
 def debugpeer(ui, path):
     """establish a connection to a peer repository"""
--- a/tests/test-completion.t	Fri Feb 01 20:21:04 2019 -0500
+++ b/tests/test-completion.t	Fri Jan 25 14:41:53 2019 -0800
@@ -104,6 +104,7 @@
   debugnamecomplete
   debugobsolete
   debugpathcomplete
+  debugpathcopies
   debugpeer
   debugpickmergetool
   debugpushkey
@@ -280,6 +281,7 @@
   debugnamecomplete: 
   debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
   debugpathcomplete: full, normal, added, removed
+  debugpathcopies: include, exclude
   debugpeer: 
   debugpickmergetool: rev, changedelete, include, exclude, tool
   debugpushkey: 
--- a/tests/test-help.t	Fri Feb 01 20:21:04 2019 -0500
+++ b/tests/test-help.t	Fri Jan 25 14:41:53 2019 -0800
@@ -1014,6 +1014,8 @@
    debugoptEXP   (no help text available)
    debugpathcomplete
                  complete part or all of a tracked path
+   debugpathcopies
+                 show copies between two revisions
    debugpeer     establish a connection to a peer repository
    debugpickmergetool
                  examine which merge tool is chosen for specified file