mercurial/commands.py
changeset 2036 c9226bcc288d
parent 2029 d436b21b20dc
child 2037 f90513a3dbcd
--- a/mercurial/commands.py	Fri Mar 31 10:52:56 2006 -0800
+++ b/mercurial/commands.py	Sat Apr 01 11:58:50 2006 +0200
@@ -2287,9 +2287,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
@@ -2309,24 +2308,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 = []
@@ -2362,8 +2343,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:
@@ -3011,7 +2996,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'))],