Merged with crew.
--- a/mercurial/commands.py Sat Apr 01 23:57:24 2006 +0200
+++ b/mercurial/commands.py Sun Apr 02 08:19:41 2006 +0200
@@ -2326,9 +2326,8 @@
to the named files or directories. This restores the contents of
the affected files to an unmodified state.
- Modified files have backup copies saved before revert. To disable
- backups, use --no-backup. To change the name of backup files, use
- --backup to give a format string.
+ Modified files are saved with a .orig suffix before reverting.
+ To disable these backups, use --no-backup.
Using the -r option, it reverts the given files or directories to
their state as of an earlier revision. This can be helpful to "roll
@@ -2348,24 +2347,6 @@
node = opts['rev'] and repo.lookup(opts['rev']) or parent
mf = repo.manifest.read(repo.changelog.read(node)[0])
- def backup(name, exact):
- bakname = make_filename(repo, repo.changelog,
- opts['backup_name'] or '%p.orig',
- node=parent, pathname=name)
- if os.path.exists(name):
- # if backup already exists and is same as backup we want
- # to make, do nothing
- if os.path.exists(bakname):
- if repo.wread(name) == repo.wread(bakname):
- return
- raise util.Abort(_('cannot save current version of %s - '
- '%s exists and differs') %
- (name, bakname))
- ui.status(('saving current version of %s as %s\n') %
- (name, bakname))
- shutil.copyfile(name, bakname)
- shutil.copymode(name, bakname)
-
wlock = repo.wlock()
entries = []
@@ -2401,8 +2382,12 @@
for abs, rel, exact in entries:
def handle(xlist, dobackup):
xlist[0].append(abs)
- if dobackup and not opts['no_backup']:
- backup(rel, exact)
+ if dobackup and not opts['no_backup'] and os.path.exists(rel):
+ bakname = "%s.orig" % rel
+ ui.note(_('saving current version of %s as %s\n') %
+ (rel, bakname))
+ shutil.copyfile(rel, bakname)
+ shutil.copymode(rel, bakname)
if ui.verbose or not exact:
ui.status(xlist[1] % rel)
for table, hitlist, misslist, backuphit, backupmiss in disptable:
@@ -3056,7 +3041,6 @@
"^revert":
(revert,
[('r', 'rev', '', _('revision to revert to')),
- ('', 'backup-name', '', _('save backup with formatted name')),
('', 'no-backup', None, _('do not save backup copies of files')),
('I', 'include', [], _('include names matching given patterns')),
('X', 'exclude', [], _('exclude names matching given patterns'))],
--- a/tests/test-confused-revert.out Sat Apr 01 23:57:24 2006 +0200
+++ b/tests/test-confused-revert.out Sun Apr 02 08:19:41 2006 +0200
@@ -2,7 +2,6 @@
A b
R a
reverting...
-saving current version of b as b.orig
forgetting b
undeleting a
%%% should show b unknown and a back to normal
--- a/tests/test-merge-revert.out Sat Apr 01 23:57:24 2006 +0200
+++ b/tests/test-merge-revert.out Sun Apr 02 08:19:41 2006 +0200
@@ -3,7 +3,6 @@
016807e6fdaf tip
eb43f19ff115
eb43f19ff115+
-saving current version of file1 as file1.orig
reverting file1
? file1.orig
eb43f19ff115
--- a/tests/test-revert Sat Apr 01 23:57:24 2006 +0200
+++ b/tests/test-revert Sun Apr 02 08:19:41 2006 +0200
@@ -22,16 +22,16 @@
echo %% should show b added, copy saved, and c modified
hg status
hg revert b
-echo %% should show b unknown, b.bak unknown, and c modified
+echo %% should show b unknown, b.orig unknown, and c modified
hg status
hg revert --no-backup c
-echo %% should show unknown: b b.bak
+echo %% should show unknown: b b.orig
hg status
-echo %% should show a b b.bak c e
+echo %% should show a b b.orig c e
ls
-echo %% should save backup to e.0
+echo %% should verbosely save backup to e.orig
echo z > e
-hg revert --backup='%p.%R'
+hg revert -v
echo %% should say no changes needed
hg revert a
echo %% should say file not managed
--- a/tests/test-revert.out Sat Apr 01 23:57:24 2006 +0200
+++ b/tests/test-revert.out Sun Apr 02 08:19:41 2006 +0200
@@ -13,23 +13,25 @@
%% should show b added, copy saved, and c modified
M c
A b
-saving current version of b as b.orig
-%% should show b unknown, b.bak unknown, and c modified
+%% should show b unknown, b.orig unknown, and c modified
M c
? b
? b.orig
-%% should show unknown: b b.bak
+%% should show unknown: b b.orig
? b
? b.orig
-%% should show a b b.bak c e
+%% should show a b b.orig c e
a
b
b.orig
c
e
-%% should save backup to e.0
-saving current version of e as e.0
+%% should verbosely save backup to e.orig
+saving current version of e as e.orig
reverting e
+resolving manifests
+getting e
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
%% should say no changes needed
no changes needed to a
%% should say file not managed
--- a/tests/test-tag.out Sat Apr 01 23:57:24 2006 +0200
+++ b/tests/test-tag.out Sun Apr 02 08:19:41 2006 +0200
@@ -21,7 +21,6 @@
use of 'hg tag NAME [REV]' is deprecated, please use 'hg tag [-r REV] NAME' instead
abort: use only one form to specify the revision
failed
-saving current version of .hgtags as .hgtags.orig
use of 'hg tag NAME [REV]' is deprecated, please use 'hg tag [-r REV] NAME' instead
0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah
0acdaf8983679e0aac16e811534eb49d7ee1f2b4 bleah0