Mercurial > hg-stable
changeset 1116:0cdd73b0767c
Add some rename debugging support
author | mpm@selenic.com |
---|---|
date | Sat, 27 Aug 2005 20:58:53 -0700 |
parents | 89f54e72581d |
children | 30ab5b8ee8ec |
files | mercurial/commands.py mercurial/filelog.py |
diffstat | 2 files changed, 34 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Aug 27 20:42:53 2005 -0700 +++ b/mercurial/commands.py Sat Aug 27 20:58:53 2005 -0700 @@ -690,6 +690,9 @@ % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2], time.strftime("%x %X", time.localtime(dc[file_][3])), file_)) + ui.write("\n") + for f in repo.dirstate.copies: + ui.write("%s -> %s\n" % (repo.dirstate.copies[f], f)) def debugdata(ui, file_, rev): """dump the contents of an data file revision""" @@ -718,6 +721,25 @@ ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) ui.write("}\n") +def debugrename(ui, repo, file, rev=None): + 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") + def debugwalk(ui, repo, *pats, **opts): """show how files match on given patterns""" items = list(walk(repo, pats, opts)) @@ -1515,6 +1537,7 @@ "debugdata": (debugdata, [], 'debugdata FILE REV'), "debugindex": (debugindex, [], 'debugindex FILE'), "debugindexdot": (debugindexdot, [], 'debugindexdot FILE'), + "debugrename": (debugrename, [], 'debugrename FILE [REV]'), "debugwalk": (debugwalk, [('I', 'include', [], 'include path in search'),
--- a/mercurial/filelog.py Sat Aug 27 20:42:53 2005 -0700 +++ b/mercurial/filelog.py Sat Aug 27 20:58:53 2005 -0700 @@ -40,9 +40,10 @@ def readmeta(self, node): t = self.revision(node) if not t.startswith('\1\n'): - return t + return {} s = t.find('\1\n', 2) mt = t[2:s] + m = {} for l in mt.splitlines(): k, v = l.split(": ", 1) m[k] = v @@ -56,6 +57,15 @@ text = "\1\n" + "".join(mt) + "\1\n" + text return self.addrevision(text, transaction, link, p1, p2) + def renamed(self, node): + if 0 and self.parents(node)[0] != nullid: + print "shortcut" + return False + m = self.readmeta(node) + if m and m.has_key("copy"): + return (m["copy"], bin(m["copyrev"])) + return False + def annotate(self, node): def decorate(text, rev):