diff mercurial/debugcommands.py @ 30958:df73368c87c3

debugcommands: move 'debugwalk' in the new module
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 02 Feb 2017 10:07:28 +0100
parents 14794735faa8
children bd5694ce8beb
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Thu Feb 02 10:06:01 2017 +0100
+++ b/mercurial/debugcommands.py	Thu Feb 02 10:07:28 2017 +0100
@@ -2025,3 +2025,21 @@
     unable to access the repository should be low.
     """
     return repair.upgraderepo(ui, repo, run=run, optimize=optimize)
+
+@command('debugwalk', commands.walkopts, _('[OPTION]... [FILE]...'),
+         inferrepo=True)
+def debugwalk(ui, repo, *pats, **opts):
+    """show how files match on given patterns"""
+    m = scmutil.match(repo[None], pats, opts)
+    items = list(repo.walk(m))
+    if not items:
+        return
+    f = lambda fn: fn
+    if ui.configbool('ui', 'slash') and pycompat.ossep != '/':
+        f = lambda fn: util.normpath(fn)
+    fmt = 'f  %%-%ds  %%-%ds  %%s' % (
+        max([len(abs) for abs in items]),
+        max([len(m.rel(abs)) for abs in items]))
+    for abs in items:
+        line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
+        ui.write("%s\n" % line.rstrip())