# HG changeset patch # User Matt Mackall # Date 2008-06-03 20:41:09 # Node ID 9eb274d773d9f9a95207c8a255ebeb3f5a5a2b6a # Parent 37eedb1a18485d052410efae391be5d68f1040d1 copies: teach copies about dirstate.copies When we're using copies() to find changes between the working directory and its first parent for diff/status/etc., use dirstate.copies() directly. This avoids doing a full statwalk for simple diffs (issue1090) and removes a special case from the status command. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2644,20 +2644,18 @@ def status(ui, repo, *pats, **opts): changestates = zip(states, 'MAR!?IC', stat) if (opts['all'] or opts['copies']) and not opts['no_status']: - if opts.get('rev') == []: - # fast path, more correct with merge parents - copy = repo.dirstate.copies() - else: - ctxn = repo.changectx(nullid) - ctx1 = repo.changectx(node1) - ctx2 = repo.changectx(node2) - if node2 is None: - ctx2 = repo.workingctx() - for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items(): - if v in stat[1]: - copy[v] = k - elif k in stat[1]: - copy[k] = v + ctxn = repo.changectx(nullid) + ctx1 = repo.changectx(node1) + ctx2 = repo.changectx(node2) + added = stat[1] + if node2 is None: + added = stat[0] + stat[1] # merged? + ctx2 = repo.workingctx() + for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items(): + if k in added: + copy[k] = v + elif v in added: + copy[v] = k for state, char, files in changestates: if state in show: diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -109,6 +109,10 @@ def copies(repo, c1, c2, ca, checkdirs=F if not c1 or not c2 or c1 == c2: return {}, {} + # avoid silly behavior for parent -> working dir + if c2.node() == None and c1.node() == repo.dirstate.parents()[0]: + return repo.dirstate.copies(), {} + limit = _findlimit(repo, c1.rev(), c2.rev()) m1 = c1.manifest() m2 = c2.manifest() diff --git a/tests/test-merge-remove.out b/tests/test-merge-remove.out --- a/tests/test-merge-remove.out +++ b/tests/test-merge-remove.out @@ -13,7 +13,6 @@ r 0 -1 foo1 copy: foo -> foo1 R bar R foo1 - foo % readding foo1 and bar adding bar adding foo1