comparison mercurial/commands.py @ 5811:180a3eee4b75

Fix copies reporting in log and convert. If copy logged in file revision, we report copy for changeset only if file revisions linkrev points back to the changeset in question or both changeset parents contain different file revisions. This fixes extra copies reported when executable bit was changed for previously copied file.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 29 Dec 2007 17:11:48 +0300
parents 28d9f8cd02f2
children bd34f0ac3cb0
comparison
equal deleted inserted replaced
5810:124577de40a7 5811:180a3eee4b75
879 """dump rename information""" 879 """dump rename information"""
880 880
881 ctx = repo.changectx(opts.get('rev', 'tip')) 881 ctx = repo.changectx(opts.get('rev', 'tip'))
882 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts, 882 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
883 ctx.node()): 883 ctx.node()):
884 m = ctx.filectx(abs).renamed() 884 fctx = ctx.filectx(abs)
885 m = fctx.filelog().renamed(fctx.filenode())
885 if m: 886 if m:
886 ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1]))) 887 ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1])))
887 else: 888 else:
888 ui.write(_("%s not renamed\n") % rel) 889 ui.write(_("%s not renamed\n") % rel)
889 890
1699 endrev = max(cmdutil.revrange(repo, opts['rev'])) + 1 1700 endrev = max(cmdutil.revrange(repo, opts['rev'])) + 1
1700 else: 1701 else:
1701 endrev = repo.changelog.count() 1702 endrev = repo.changelog.count()
1702 rcache = {} 1703 rcache = {}
1703 ncache = {} 1704 ncache = {}
1704 dcache = [] 1705 def getrenamed(fn, rev):
1705 def getrenamed(fn, rev, man):
1706 '''looks up all renames for a file (up to endrev) the first 1706 '''looks up all renames for a file (up to endrev) the first
1707 time the file is given. It indexes on the changerev and only 1707 time the file is given. It indexes on the changerev and only
1708 parses the manifest if linkrev != changerev. 1708 parses the manifest if linkrev != changerev.
1709 Returns rename info for fn at changerev rev.''' 1709 Returns rename info for fn at changerev rev.'''
1710 if fn not in rcache: 1710 if fn not in rcache:
1720 ncache[fn][node] = renamed 1720 ncache[fn][node] = renamed
1721 if lr >= endrev: 1721 if lr >= endrev:
1722 break 1722 break
1723 if rev in rcache[fn]: 1723 if rev in rcache[fn]:
1724 return rcache[fn][rev] 1724 return rcache[fn][rev]
1725 mr = repo.manifest.rev(man) 1725
1726 if repo.manifest.parentrevs(mr) != (mr - 1, nullrev): 1726 # If linkrev != rev (i.e. rev not found in rcache) fallback to
1727 return ncache[fn].get(repo.manifest.find(man, fn)[0]) 1727 # filectx logic.
1728 if not dcache or dcache[0] != man: 1728
1729 dcache[:] = [man, repo.manifest.readdelta(man)] 1729 try:
1730 if fn in dcache[1]: 1730 return repo.changectx(rev).filectx(fn).renamed()
1731 return ncache[fn].get(dcache[1][fn]) 1731 except revlog.LookupError:
1732 pass
1732 return None 1733 return None
1733 1734
1734 df = False 1735 df = False
1735 if opts["date"]: 1736 if opts["date"]:
1736 df = util.matchdate(opts["date"]) 1737 df = util.matchdate(opts["date"])
1763 if miss: 1764 if miss:
1764 continue 1765 continue
1765 1766
1766 copies = [] 1767 copies = []
1767 if opts.get('copies') and rev: 1768 if opts.get('copies') and rev:
1768 mf = get(rev)[0]
1769 for fn in get(rev)[3]: 1769 for fn in get(rev)[3]:
1770 rename = getrenamed(fn, rev, mf) 1770 rename = getrenamed(fn, rev)
1771 if rename: 1771 if rename:
1772 copies.append((fn, rename[0])) 1772 copies.append((fn, rename[0]))
1773 displayer.show(rev, changenode, copies=copies) 1773 displayer.show(rev, changenode, copies=copies)
1774 elif st == 'iter': 1774 elif st == 'iter':
1775 if count == limit: break 1775 if count == limit: break