comparison mercurial/commands.py @ 1513:5c3b93b244aa

copy & rename don't overwrite unless --force is specified
author Robin Farine <robin.farine@terminus.org>
date Tue, 08 Nov 2005 10:35:09 -0800
parents 53ad6ee6ede4
children faf46d810a85
comparison
equal deleted inserted replaced
1512:53ad6ee6ede4 1513:5c3b93b244aa
801 return True 801 return True
802 802
803 def copy(abssrc, relsrc, target, exact): 803 def copy(abssrc, relsrc, target, exact):
804 abstarget = util.canonpath(repo.root, cwd, target) 804 abstarget = util.canonpath(repo.root, cwd, target)
805 reltarget = util.pathto(cwd, abstarget) 805 reltarget = util.pathto(cwd, abstarget)
806 if not opts['force'] and repo.dirstate.state(abstarget) not in 'a?': 806 if os.path.exists(reltarget):
807 ui.warn(_('%s: not overwriting - file already managed\n') % 807 if opts['force']:
808 reltarget) 808 os.unlink(reltarget)
809 return 809 else:
810 ui.warn(_('%s: not overwriting - file exists\n') %
811 reltarget)
812 return
810 if ui.verbose or not exact: 813 if ui.verbose or not exact:
811 ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) 814 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
812 if not opts['after']: 815 if not opts['after']:
813 targetdir = os.path.dirname(reltarget) or '.' 816 targetdir = os.path.dirname(reltarget) or '.'
814 if not os.path.isdir(targetdir): 817 if not os.path.isdir(targetdir):