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