##// END OF EJS Templates
remove: add -n/--dry-run option
Vadim Gelfer -
r2414:86e07466 default
parent child Browse files
Show More
@@ -1055,22 +1055,23 b' def docopy(ui, repo, pats, opts, wlock):'
1055 ui.warn(_('%s: not overwriting - file exists\n') %
1055 ui.warn(_('%s: not overwriting - file exists\n') %
1056 reltarget)
1056 reltarget)
1057 return
1057 return
1058 if not opts['after']:
1058 if not opts['after'] and not opts['dry_run']:
1059 os.unlink(reltarget)
1059 os.unlink(reltarget)
1060 if opts['after']:
1060 if opts['after']:
1061 if not os.path.exists(reltarget):
1061 if not os.path.exists(reltarget):
1062 return
1062 return
1063 else:
1063 else:
1064 targetdir = os.path.dirname(reltarget) or '.'
1064 targetdir = os.path.dirname(reltarget) or '.'
1065 if not os.path.isdir(targetdir):
1065 if not os.path.isdir(targetdir) and not opts['dry_run']:
1066 os.makedirs(targetdir)
1066 os.makedirs(targetdir)
1067 try:
1067 try:
1068 restore = repo.dirstate.state(abstarget) == 'r'
1068 restore = repo.dirstate.state(abstarget) == 'r'
1069 if restore:
1069 if restore and not dry_run:
1070 repo.undelete([abstarget], wlock)
1070 repo.undelete([abstarget], wlock)
1071 try:
1071 try:
1072 shutil.copyfile(relsrc, reltarget)
1072 if not opts['dry_run']:
1073 shutil.copymode(relsrc, reltarget)
1073 shutil.copyfile(relsrc, reltarget)
1074 shutil.copymode(relsrc, reltarget)
1074 restore = False
1075 restore = False
1075 finally:
1076 finally:
1076 if restore:
1077 if restore:
@@ -1088,7 +1089,7 b' def docopy(ui, repo, pats, opts, wlock):'
1088 if ui.verbose or not exact:
1089 if ui.verbose or not exact:
1089 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
1090 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
1090 targets[abstarget] = abssrc
1091 targets[abstarget] = abssrc
1091 if abstarget != origsrc:
1092 if abstarget != origsrc and not opts['dry_run']:
1092 repo.copy(origsrc, abstarget, wlock)
1093 repo.copy(origsrc, abstarget, wlock)
1093 copied.append((abssrc, relsrc, exact))
1094 copied.append((abssrc, relsrc, exact))
1094
1095
@@ -1172,10 +1173,9 b' def docopy(ui, repo, pats, opts, wlock):'
1172 if not copylist:
1173 if not copylist:
1173 raise util.Abort(_('no files to copy'))
1174 raise util.Abort(_('no files to copy'))
1174
1175
1175 if not opts.get('dry_run'):
1176 for targetpath, srcs in copylist:
1176 for targetpath, srcs in copylist:
1177 for origsrc, abssrc, relsrc, exact in srcs:
1177 for origsrc, abssrc, relsrc, exact in srcs:
1178 copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
1178 copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
1179
1179
1180 if errors:
1180 if errors:
1181 ui.warn(_('(consider using --after)\n'))
1181 ui.warn(_('(consider using --after)\n'))
@@ -2309,7 +2309,8 b' def rename(ui, repo, *pats, **opts):'
2309 if ui.verbose or not exact:
2309 if ui.verbose or not exact:
2310 ui.status(_('removing %s\n') % rel)
2310 ui.status(_('removing %s\n') % rel)
2311 names.append(abs)
2311 names.append(abs)
2312 repo.remove(names, True, wlock)
2312 if not opts['dry_run']:
2313 repo.remove(names, True, wlock)
2313 return errs
2314 return errs
2314
2315
2315 def revert(ui, repo, *pats, **opts):
2316 def revert(ui, repo, *pats, **opts):
@@ -3066,7 +3067,8 b' table = {'
3066 ('f', 'force', None,
3067 ('f', 'force', None,
3067 _('forcibly copy over an existing managed file')),
3068 _('forcibly copy over an existing managed file')),
3068 ('I', 'include', [], _('include names matching the given patterns')),
3069 ('I', 'include', [], _('include names matching the given patterns')),
3069 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
3070 ('X', 'exclude', [], _('exclude names matching the given patterns')),
3071 ('n', 'dry-run', None, _('print what would be done'))],
3070 _('hg rename [OPTION]... SOURCE... DEST')),
3072 _('hg rename [OPTION]... SOURCE... DEST')),
3071 "^revert":
3073 "^revert":
3072 (revert,
3074 (revert,
General Comments 0
You need to be logged in to leave comments. Login now