# HG changeset patch # User Matt Mackall # Date 2008-10-18 09:26:09 # Node ID b801d6e5dc834a8fc5d2039d5800dfaf438996fa # Parent db7557359636017e4ebf55c3a8a8d3558a3a9eb3 rename: handle renaming to a target marked removed diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -398,12 +398,12 @@ def copy(ui, repo, pats, opts, rename=Fa if state not in 'mn' and not dryrun: repo.dirstate.normallookup(abstarget) else: - if repo.dirstate[origsrc] == 'a': + if repo.dirstate[origsrc] == 'a' and origsrc == abssrc: if not ui.quiet: ui.warn(_("%s has not been committed yet, so no copy " "data will be stored for %s.\n") % (repo.pathto(origsrc, cwd), reltarget)) - if abstarget not in repo.dirstate and not dryrun: + if repo.dirstate[abstarget] in '?r' and not dryrun: repo.add([abstarget]) elif not dryrun: repo.copy(origsrc, abstarget) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1149,7 +1149,7 @@ class localrepository(repo.repository): "symbolic link\n") % dest) else: wlock = self.wlock() - if dest not in self.dirstate: + if self.dirstate[dest] in '?r': self.dirstate.add(dest) self.dirstate.copy(source, dest) finally: