changeset 3652:f4dece0f7016

refactor debugrenamed
author Matt Mackall <mpm@selenic.com>
date Wed, 15 Nov 2006 15:51:58 -0600
parents 6389205291c6
children d793e09e1b71
files mercurial/commands.py tests/test-copy2.out tests/test-rename-merge1.out
diffstat 3 files changed, 14 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Nov 15 15:51:58 2006 -0600
+++ b/mercurial/commands.py	Wed Nov 15 15:51:58 2006 -0600
@@ -960,25 +960,17 @@
             ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
     ui.write("}\n")
 
-def debugrename(ui, repo, file, rev=None):
+def debugrename(ui, repo, file1, *pats, **opts):
     """dump rename information"""
-    r = repo.file(relpath(repo, [file])[0])
-    if rev:
-        try:
-            # assume all revision numbers are for changesets
-            n = repo.lookup(rev)
-            change = repo.changelog.read(n)
-            m = repo.manifest.read(change[0])
-            n = m[relpath(repo, [file])[0]]
-        except (hg.RepoError, KeyError):
-            n = r.lookup(rev)
-    else:
-        n = r.tip()
-    m = r.renamed(n)
-    if m:
-        ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1])))
-    else:
-        ui.write(_("not renamed\n"))
+
+    ctx = repo.changectx(opts.get('rev', 'tip'))
+    for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
+                                             ctx.node()):
+        m = ctx.filectx(abs).renamed()
+        if m:
+            ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1])))
+        else:
+            ui.write(_("%s not renamed\n") % rel)
 
 def debugwalk(ui, repo, *pats, **opts):
     """show how files match on given patterns"""
--- a/tests/test-copy2.out	Wed Nov 15 15:51:58 2006 -0600
+++ b/tests/test-copy2.out	Wed Nov 15 15:51:58 2006 -0600
@@ -4,9 +4,9 @@
 # should match
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       5      0       0 2ed2a3912a0b 000000000000 000000000000
-renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
+bar renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
 # should not be renamed
-not renamed
+bar not renamed
 # should show copy
 copy: foo -> bar
 # should show no parents for tip
@@ -18,5 +18,5 @@
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       5      0       0 2ed2a3912a0b 000000000000 000000000000
      1         5       7      1       2 dd12c926cf16 2ed2a3912a0b 000000000000
-renamed from foo:dd12c926cf165e3eb4cf87b084955cb617221c17
+bar renamed from foo:dd12c926cf165e3eb4cf87b084955cb617221c17
 # should show no copies
--- a/tests/test-rename-merge1.out	Wed Nov 15 15:51:58 2006 -0600
+++ b/tests/test-rename-merge1.out	Wed Nov 15 15:51:58 2006 -0600
@@ -22,4 +22,4 @@
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0      67      0       1 dc51707dfc98 000000000000 000000000000
      1        67      72      1       3 b2494a44f0a9 000000000000 dc51707dfc98
-renamed from a:dd03b83622e78778b403775d0d074b9ac7387a66
+b renamed from a:dd03b83622e78778b403775d0d074b9ac7387a66