comparison mercurial/commands.py @ 3652:f4dece0f7016

refactor debugrenamed
author Matt Mackall <mpm@selenic.com>
date Wed, 15 Nov 2006 15:51:58 -0600
parents 6389205291c6
children d793e09e1b71
comparison
equal deleted inserted replaced
3651:6389205291c6 3652:f4dece0f7016
958 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) 958 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
959 if pp[1] != nullid: 959 if pp[1] != nullid:
960 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) 960 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
961 ui.write("}\n") 961 ui.write("}\n")
962 962
963 def debugrename(ui, repo, file, rev=None): 963 def debugrename(ui, repo, file1, *pats, **opts):
964 """dump rename information""" 964 """dump rename information"""
965 r = repo.file(relpath(repo, [file])[0]) 965
966 if rev: 966 ctx = repo.changectx(opts.get('rev', 'tip'))
967 try: 967 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
968 # assume all revision numbers are for changesets 968 ctx.node()):
969 n = repo.lookup(rev) 969 m = ctx.filectx(abs).renamed()
970 change = repo.changelog.read(n) 970 if m:
971 m = repo.manifest.read(change[0]) 971 ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1])))
972 n = m[relpath(repo, [file])[0]] 972 else:
973 except (hg.RepoError, KeyError): 973 ui.write(_("%s not renamed\n") % rel)
974 n = r.lookup(rev)
975 else:
976 n = r.tip()
977 m = r.renamed(n)
978 if m:
979 ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1])))
980 else:
981 ui.write(_("not renamed\n"))
982 974
983 def debugwalk(ui, repo, *pats, **opts): 975 def debugwalk(ui, repo, *pats, **opts):
984 """show how files match on given patterns""" 976 """show how files match on given patterns"""
985 items = list(cmdutil.walk(repo, pats, opts)) 977 items = list(cmdutil.walk(repo, pats, opts))
986 if not items: 978 if not items: