changeset 10882:f0bfe42c7b1f

rollback: add dry-run argument, emit transaction description
author Steve Borho <steve@borho.org>
date Fri, 09 Apr 2010 17:23:37 -0500
parents a685011ed38e
children 4fb1bafd43e7
files hgext/bookmarks.py mercurial/commands.py mercurial/localrepo.py tests/test-acl.out tests/test-backout.out tests/test-bundle-r.out tests/test-bundle.out tests/test-convert-cvs.out tests/test-debugcomplete.out tests/test-diff-color.out tests/test-hook.out tests/test-import.out tests/test-keyword.out tests/test-newbranch.out tests/test-notify.out tests/test-pull-r.out tests/test-push-http.out tests/test-rename-after-merge.out tests/test-rollback.out tests/test-tags.out tests/test-url-rev.out
diffstat 21 files changed, 54 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bookmarks.py	Fri Apr 09 17:23:35 2010 -0500
+++ b/hgext/bookmarks.py	Fri Apr 09 17:23:37 2010 -0500
@@ -241,10 +241,10 @@
                 file.close()
             return mark
 
-        def rollback(self):
+        def rollback(self, *args):
             if os.path.exists(self.join('undo.bookmarks')):
                 util.rename(self.join('undo.bookmarks'), self.join('bookmarks'))
-            return super(bookmark_repo, self).rollback()
+            return super(bookmark_repo, self).rollback(*args)
 
         def lookup(self, key):
             if key in self._bookmarks:
--- a/mercurial/commands.py	Fri Apr 09 17:23:35 2010 -0500
+++ b/mercurial/commands.py	Fri Apr 09 17:23:37 2010 -0500
@@ -2854,7 +2854,7 @@
     finally:
         wlock.release()
 
-def rollback(ui, repo):
+def rollback(ui, repo, **opts):
     """roll back the last transaction
 
     This command should be used with care. There is only one level of
@@ -2881,7 +2881,7 @@
     repository; for example an in-progress pull from the repository
     may fail if a rollback is performed.
     """
-    repo.rollback()
+    repo.rollback(opts.get('dry_run'))
 
 def root(ui, repo):
     """print the root (top) of the current working directory
@@ -3821,7 +3821,7 @@
           ('', 'no-backup', None, _('do not save backup copies of files')),
          ] + walkopts + dryrunopts,
          _('[OPTION]... [-r REV] [NAME]...')),
-    "rollback": (rollback, []),
+    "rollback": (rollback, dryrunopts),
     "root": (root, []),
     "^serve":
         (serve,
--- a/mercurial/localrepo.py	Fri Apr 09 17:23:35 2010 -0500
+++ b/mercurial/localrepo.py	Fri Apr 09 17:23:37 2010 -0500
@@ -599,13 +599,25 @@
         finally:
             lock.release()
 
-    def rollback(self):
+    def rollback(self, dryrun=False):
         wlock = lock = None
         try:
             wlock = self.wlock()
             lock = self.lock()
             if os.path.exists(self.sjoin("undo")):
-                self.ui.status(_("rolling back last transaction\n"))
+                try:
+                    args = self.opener("undo.desc", "r").read().split(",")
+                    if len(args) == 3 and self.ui.verbose:
+                        desc = _("rolling back %s (%s) to revision %s\n") % (
+                                 args[1], args[2], args[0])
+                    else:
+                        desc = _("rolling back %s to revision %s\n") % (
+                                 args[1], args[0])
+                except (IOError, IndexError):
+                    desc = _("rolling back unknown transaction\n")
+                self.ui.status(desc)
+                if dryrun:
+                    return
                 transaction.rollback(self.sopener, self.sjoin("undo"),
                                      self.ui.warn)
                 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
--- a/tests/test-acl.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-acl.out	Fri Apr 09 17:23:37 2010 -0500
@@ -71,7 +71,7 @@
 files: 3 chunks
 added 3 changesets with 3 changes to 3 files
 updating the branch cache
-rolling back last transaction
+rolling back push to revision 1
 0:6675d58eff77
 
 Extension disabled for lack of acl.sources
@@ -143,7 +143,7 @@
 calling hook pretxnchangegroup.acl: hgext.acl.hook
 acl: changes have source "push" - skipping
 updating the branch cache
-rolling back last transaction
+rolling back push to revision 1
 0:6675d58eff77
 
 No [acl.allow]/[acl.deny]
@@ -221,7 +221,7 @@
 acl: allowing changeset f9cafe1212c8
 acl: allowing changeset 911600dab2ae
 updating the branch cache
-rolling back last transaction
+rolling back push to revision 1
 0:6675d58eff77
 
 Empty [acl.allow]
@@ -799,7 +799,7 @@
 acl: allowing changeset f9cafe1212c8
 acl: allowing changeset 911600dab2ae
 updating the branch cache
-rolling back last transaction
+rolling back push to revision 1
 0:6675d58eff77
 
 wilma can change files with a .txt extension
@@ -1160,6 +1160,6 @@
 acl: allowing changeset f9cafe1212c8
 acl: allowing changeset 911600dab2ae
 updating the branch cache
-rolling back last transaction
+rolling back push to revision 1
 0:6675d58eff77
 
--- a/tests/test-backout.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-backout.out	Fri Apr 09 17:23:37 2010 -0500
@@ -62,7 +62,7 @@
 # backout with valid parent should be ok
 removing d
 changeset 5:10e5328c8435 backs out changeset 4:b2f3bb92043e
-rolling back last transaction
+rolling back commit to revision 5
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 removing c
 changeset 5:033590168430 backs out changeset 4:b2f3bb92043e
--- a/tests/test-bundle-r.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-bundle-r.out	Fri Apr 09 17:23:37 2010 -0500
@@ -154,7 +154,7 @@
 crosschecking files in changesets and manifests
 checking files
 4 files, 9 changesets, 7 total revisions
-rolling back last transaction
+rolling back pull to revision 5
 % should fail
 abort: --base is incompatible with specifying a destination
 abort: repository default-push not found!
@@ -187,7 +187,7 @@
 crosschecking files in changesets and manifests
 checking files
 4 files, 9 changesets, 7 total revisions
-rolling back last transaction
+rolling back unbundle to revision 3
 % 2
 2:d62976ca1e50
 adding changesets
@@ -202,7 +202,7 @@
 crosschecking files in changesets and manifests
 checking files
 2 files, 5 changesets, 5 total revisions
-rolling back last transaction
+rolling back unbundle to revision 3
 adding changesets
 adding manifests
 adding file changes
@@ -215,7 +215,7 @@
 crosschecking files in changesets and manifests
 checking files
 3 files, 7 changesets, 6 total revisions
-rolling back last transaction
+rolling back unbundle to revision 3
 adding changesets
 adding manifests
 adding file changes
--- a/tests/test-bundle.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-bundle.out	Fri Apr 09 17:23:37 2010 -0500
@@ -37,7 +37,7 @@
 added 9 changesets with 7 changes to 4 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
 ====== Rollback empty
-rolling back last transaction
+rolling back pull to revision 0
 ====== Pull full.hg into empty again (using --cwd)
 pulling from ../full.hg
 requesting all changes
@@ -55,7 +55,7 @@
 searching for changes
 no changes found
 ====== Rollback empty
-rolling back last transaction
+rolling back pull to revision 0
 ====== Pull full.hg into empty again (using -R)
 pulling from full.hg
 requesting all changes
@@ -123,7 +123,7 @@
 added 9 changesets with 7 changes to 4 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
 ====== Rollback empty
-rolling back last transaction
+rolling back pull to revision 0
 ====== Log -R bundle:empty+full.hg
 8 7 6 5 4 3 2 1 0 
 ====== Pull full.hg into empty again (using -R; with hook)
--- a/tests/test-convert-cvs.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-convert-cvs.out	Fri Apr 09 17:23:37 2010 -0500
@@ -45,7 +45,7 @@
 2 Initial revision
 1 import
 filtering out empty revision
-rolling back last transaction
+rolling back commit to revision 1
 0 ci0
 updating tags
 c
--- a/tests/test-debugcomplete.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-debugcomplete.out	Fri Apr 09 17:23:37 2010 -0500
@@ -220,7 +220,7 @@
 rename: after, force, include, exclude, dry-run
 resolve: all, list, mark, unmark, no-status, include, exclude
 revert: all, date, rev, no-backup, include, exclude, dry-run
-rollback: 
+rollback: dry-run
 root: 
 showconfig: untrusted
 tag: force, local, rev, remove, message, date, user
--- a/tests/test-diff-color.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-diff-color.out	Fri Apr 09 17:23:37 2010 -0500
@@ -43,7 +43,7 @@
  c
 record this change to 'a'? [Ynsfdaq?] 
 
-rolling back last transaction
+rolling back commit to revision 1
 % qrecord
 diff --git a/a b/a
 old mode 100644
--- a/tests/test-hook.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-hook.out	Fri Apr 09 17:23:37 2010 -0500
@@ -101,7 +101,7 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files
 (run 'hg update' to get a working copy)
-rolling back last transaction
+rolling back pull to revision 4
 preoutgoing hook: HG_SOURCE=pull 
 preoutgoing.forbid hook: HG_SOURCE=pull 
 pulling from ../a
--- a/tests/test-import.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-import.out	Fri Apr 09 17:23:37 2010 -0500
@@ -182,7 +182,7 @@
 applying ../patch1
 applying ../patch2
 applied 1d4bd90af0e4
-rolling back last transaction
+rolling back commit to revision 2
 parent: 1
 % hg import in a subdirectory
 requesting all changes
--- a/tests/test-keyword.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-keyword.out	Fri Apr 09 17:23:37 2010 -0500
@@ -198,7 +198,7 @@
 +do not process $Id:
 +xxx $
 % rollback
-rolling back last transaction
+rolling back commit to revision 2
 % status
 A c
 % update -C
@@ -266,7 +266,7 @@
 % status
 ? c
 % rollback
-rolling back last transaction
+rolling back commit to revision 3
 % status
 R a
 ? c
@@ -308,7 +308,7 @@
 ignore $Id$
 
 % rollback
-rolling back last transaction
+rolling back commit to revision 3
 % clean update
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % kwexpand/kwshrink on selected files
--- a/tests/test-newbranch.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-newbranch.out	Fri Apr 09 17:23:37 2010 -0500
@@ -62,7 +62,7 @@
 default
 bar
 % test for invalid branch cache
-rolling back last transaction
+rolling back commit to revision 5
 changeset:   4:4909a3732169
 branch:      foo
 tag:         tip
--- a/tests/test-notify.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-notify.out	Fri Apr 09 17:23:37 2010 -0500
@@ -95,10 +95,10 @@
 +a
 (run 'hg update' to get a working copy)
 % fail for config file is missing
-rolling back last transaction
+rolling back pull to revision 1
 pull failed
 % pull
-rolling back last transaction
+rolling back pull to revision 1
 pulling from ../a
 searching for changes
 adding changesets
@@ -129,7 +129,7 @@
 +a
 (run 'hg update' to get a working copy)
 % pull
-rolling back last transaction
+rolling back pull to revision 1
 pulling from ../a
 searching for changes
 adding changesets
--- a/tests/test-pull-r.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-pull-r.out	Fri Apr 09 17:23:37 2010 -0500
@@ -19,7 +19,7 @@
 abort: unknown revision 'missing'!
 % pull multiple revisions with update
 0:bbd179dfa0a7
-rolling back last transaction
+rolling back pull to revision 0
 % pull -r 0
 changeset:   0:bbd179dfa0a7
 tag:         tip
--- a/tests/test-push-http.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-push-http.out	Fri Apr 09 17:23:37 2010 -0500
@@ -25,7 +25,7 @@
 remote: added 1 changesets with 1 changes to 1 files
 % serve errors
 changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http 
-rolling back last transaction
+rolling back serve to revision 1
 % expect authorization error: all users denied
 abort: authorization failed
 pushing to http://localhost:$HGPORT/
--- a/tests/test-rename-after-merge.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-rename-after-merge.out	Fri Apr 09 17:23:37 2010 -0500
@@ -34,7 +34,7 @@
 (branch merge, don't forget to commit)
 % commit issue 1476
 copies:      c2 (c1)
-rolling back last transaction
+rolling back commit to revision 3
 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
 % merge heads again
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-rollback.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-rollback.out	Fri Apr 09 17:23:37 2010 -0500
@@ -9,7 +9,7 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     test
 
-rolling back last transaction
+rolling back commit to revision 0
 checking changesets
 checking manifests
 crosschecking files in changesets and manifests
@@ -18,14 +18,14 @@
 A a
 % Test issue 902
 marked working directory as branch test
-rolling back last transaction
+rolling back commit to revision 0
 default
 % Test issue 1635 (commit message saved)
 .hg/last-message.txt:
 test2
 % Test rollback of hg before issue 902 was fixed
 marked working directory as branch test
-rolling back last transaction
+rolling back commit to revision 0
 Named branch could not be reset, current branch still is: test
 test
 % rollback by pretxncommit saves commit message (issue 1635)
--- a/tests/test-tags.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-tags.out	Fri Apr 09 17:23:37 2010 -0500
@@ -111,7 +111,7 @@
 summary:     Removed tag bar
 
 % rollback undoes tag operation
-rolling back last transaction
+rolling back commit to revision 5
 tip                                4:0c192d7d5e6b
 bar                                1:78391a272241
 tip                                4:0c192d7d5e6b
--- a/tests/test-url-rev.out	Fri Apr 09 17:23:35 2010 -0500
+++ b/tests/test-url-rev.out	Fri Apr 09 17:23:37 2010 -0500
@@ -75,7 +75,7 @@
 
 
 % rolling back
-rolling back last transaction
+rolling back push to revision 2
 % incoming
 2:faba9097cad4
 % pull
@@ -104,7 +104,7 @@
 % no new revs, no update
 0:1f0dee641bb7
 % rollback
-rolling back last transaction
+rolling back pull to revision 2
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 0:1f0dee641bb7
 % pull -u takes us back to branch foo
@@ -116,7 +116,7 @@
 summary:     new head of branch foo
 
 % rollback
-rolling back last transaction
+rolling back pull to revision 2
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % parents
 0:1f0dee641bb7