Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 1514:faf46d810a85
avoid to copy more than one file to the same destination file
author | Robin Farine <robin.farine@terminus.org> |
---|---|
date | Tue, 08 Nov 2005 10:35:13 -0800 |
parents | 5c3b93b244aa |
children | 0b1b029b4de3 |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Nov 08 10:35:09 2005 -0800 +++ b/mercurial/commands.py Tue Nov 08 10:35:13 2005 -0800 @@ -790,6 +790,7 @@ cwd = repo.getcwd() errors = 0 copied = [] + targets = {} def okaytocopy(abs, rel, exact): reasons = {'?': _('is not managed'), @@ -803,7 +804,12 @@ def copy(abssrc, relsrc, target, exact): abstarget = util.canonpath(repo.root, cwd, target) reltarget = util.pathto(cwd, abstarget) - if os.path.exists(reltarget): + prevsrc = targets.get(abstarget) + if prevsrc is not None: + ui.warn(_('%s: not overwriting - %s collides with %s\n') % + (reltarget, abssrc, prevsrc)) + return + elif os.path.exists(reltarget): if opts['force']: os.unlink(reltarget) else: @@ -829,6 +835,7 @@ (relsrc, inst.strerror)) errors += 1 return + targets[abstarget] = abssrc repo.copy(abssrc, abstarget) copied.append((abssrc, relsrc, exact))