[PATCH] rollback: clarifies the message about the reverted state (issue 2628)

Gilles Moris gilles.moris at free.fr
Thu Feb 10 02:05:22 CST 2011


# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1297324986 -3600
# Node ID 9705430d311af358bce56bd92293d0705b6bf7f6
# Parent  69e69b131458023d21ec40aa48fc5299e43ce69b
rollback: clarifies the message about the reverted state (issue 2628)

Previously, when rolling back a transaction, some users could be confused
between the level to which the database is rolled back, and the new parents
of the working directory.

  $ hg rollback
  rolling back to revision 4 (undo commit)

With this change:
  $ hg rollback
  rolling back database to tip revision 4 (undo commit)
  your working directory is now based on revision 2 and 1

So now the user can realize that the database has been rolled back to an older
tip, but also that the working directory is not on the tip (here we are
rolling back the merge of the heads 2 and 1)

diff -r 69e69b131458 -r 9705430d311a mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Feb 04 09:17:07 2011 +0100
+++ b/mercurial/localrepo.py	Thu Feb 10 09:03:06 2011 +0100
@@ -695,11 +695,12 @@
                 try:
                     args = self.opener("undo.desc", "r").read().splitlines()
                     if len(args) >= 3 and self.ui.verbose:
-                        desc = _("rolling back to revision %s"
+                        desc = _("rolling back database to tip revision %s"
                                  " (undo %s: %s)\n") % (
                                  int(args[0]) - 1, args[1], args[2])
                     elif len(args) >= 2:
-                        desc = _("rolling back to revision %s (undo %s)\n") % (
+                        desc = _("rolling back database to tip revision %s"
+                                 " (undo %s)\n") % (
                                  int(args[0]) - 1, args[1])
                 except IOError:
                     desc = _("rolling back unknown transaction\n")
@@ -719,6 +720,9 @@
                 self.invalidate()
                 self.dirstate.invalidate()
                 self.destroyed()
+                self.ui.status(_("your working directory is now based on "
+                                 "revision %s\n") % (
+                    _(' and ').join(str(p.rev()) for p in self.parents())))
             else:
                 self.ui.warn(_("no rollback information available\n"))
                 return 1
diff -r 69e69b131458 -r 9705430d311a tests/test-acl.t
--- a/tests/test-acl.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-acl.t	Thu Feb 10 09:03:06 2011 +0100
@@ -141,7 +141,8 @@
   files: 3/3 chunks (100.00%)
   added 3 changesets with 3 changes to 3 files
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
@@ -219,7 +220,8 @@
   calling hook pretxnchangegroup.acl: hgext.acl.hook
   acl: changes have source "push" - skipping
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
@@ -307,7 +309,8 @@
   acl: branch access granted: "911600dab2ae" on branch "default"
   acl: allowing changeset 911600dab2ae
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
@@ -941,7 +944,8 @@
   acl: branch access granted: "911600dab2ae" on branch "default"
   acl: allowing changeset 911600dab2ae
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
@@ -1336,7 +1340,8 @@
   acl: branch access granted: "911600dab2ae" on branch "default"
   acl: allowing changeset 911600dab2ae
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
@@ -1432,7 +1437,8 @@
   acl: branch access granted: "911600dab2ae" on branch "default"
   acl: allowing changeset 911600dab2ae
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
@@ -1621,7 +1627,8 @@
   acl: branch access granted: "911600dab2ae" on branch "default"
   acl: allowing changeset 911600dab2ae
   updating the branch cache
-  rolling back to revision 0 (undo push)
+  rolling back database to tip revision 0 (undo push)
+  your working directory is now based on revision 0
   0:6675d58eff77
   
 
diff -r 69e69b131458 -r 9705430d311a tests/test-backout.t
--- a/tests/test-backout.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-backout.t	Thu Feb 10 09:03:06 2011 +0100
@@ -204,7 +204,8 @@
   changeset 5:10e5328c8435 backs out changeset 4:b2f3bb92043e
 
   $ hg rollback
-  rolling back to revision 4 (undo commit)
+  rolling back database to tip revision 4 (undo commit)
+  your working directory is now based on revision 4
   $ hg update -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
diff -r 69e69b131458 -r 9705430d311a tests/test-bookmarks-strip.t
--- a/tests/test-bookmarks-strip.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-bookmarks-strip.t	Thu Feb 10 09:03:06 2011 +0100
@@ -77,7 +77,8 @@
   adding b
   $ hg bookmarks markb
   $ hg rollback
-  rolling back to revision 0 (undo commit)
+  rolling back database to tip revision 0 (undo commit)
+  your working directory is now based on revision 0
 
 are you there?
 
diff -r 69e69b131458 -r 9705430d311a tests/test-bundle-r.t
--- a/tests/test-bundle-r.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-bundle-r.t	Thu Feb 10 09:03:06 2011 +0100
@@ -200,7 +200,8 @@
   checking files
   4 files, 9 changesets, 7 total revisions
   $ hg rollback
-  rolling back to revision 4 (undo pull)
+  rolling back database to tip revision 4 (undo pull)
+  your working directory is now based on revision -1
   $ cd ..
 
 should fail
@@ -276,7 +277,8 @@
   checking files
   4 files, 9 changesets, 7 total revisions
   $ hg rollback
-  rolling back to revision 2 (undo unbundle)
+  rolling back database to tip revision 2 (undo unbundle)
+  your working directory is now based on revision 2
 
 revision 2
 
@@ -300,7 +302,8 @@
   checking files
   2 files, 5 changesets, 5 total revisions
   $ hg rollback
-  rolling back to revision 2 (undo unbundle)
+  rolling back database to tip revision 2 (undo unbundle)
+  your working directory is now based on revision 2
   $ hg unbundle ../test-bundle-branch2.hg
   adding changesets
   adding manifests
@@ -319,7 +322,8 @@
   checking files
   3 files, 7 changesets, 6 total revisions
   $ hg rollback
-  rolling back to revision 2 (undo unbundle)
+  rolling back database to tip revision 2 (undo unbundle)
+  your working directory is now based on revision 2
   $ hg unbundle ../test-bundle-cset-7.hg
   adding changesets
   adding manifests
diff -r 69e69b131458 -r 9705430d311a tests/test-bundle.t
--- a/tests/test-bundle.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-bundle.t	Thu Feb 10 09:03:06 2011 +0100
@@ -91,7 +91,8 @@
 Rollback empty
 
   $ hg -R empty rollback
-  rolling back to revision -1 (undo pull)
+  rolling back database to tip revision -1 (undo pull)
+  your working directory is now based on revision -1
 
 Pull full.hg into empty again (using --cwd)
 
@@ -121,7 +122,8 @@
 Rollback empty
 
   $ hg -R empty rollback
-  rolling back to revision -1 (undo pull)
+  rolling back database to tip revision -1 (undo pull)
+  your working directory is now based on revision -1
 
 Pull full.hg into empty again (using -R)
 
@@ -211,7 +213,8 @@
 Rollback empty
 
   $ hg rollback
-  rolling back to revision -1 (undo pull)
+  rolling back database to tip revision -1 (undo pull)
+  your working directory is now based on revision -1
   $ cd ..
 
 Log -R bundle:empty+full.hg
diff -r 69e69b131458 -r 9705430d311a tests/test-convert-cvs.t
--- a/tests/test-convert-cvs.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-convert-cvs.t	Thu Feb 10 09:03:06 2011 +0100
@@ -111,7 +111,8 @@
   2 Initial revision
   1 import
   filtering out empty revision
-  rolling back to revision 0 (undo commit)
+  rolling back database to tip revision 0 (undo commit)
+  your working directory is now based on revision -1
   0 ci0
   updating tags
   $ hgcat b/c
diff -r 69e69b131458 -r 9705430d311a tests/test-diff-color.t
--- a/tests/test-diff-color.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-diff-color.t	Thu Feb 10 09:03:06 2011 +0100
@@ -97,7 +97,8 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
   $ hg rollback
-  rolling back to revision 0 (undo commit)
+  rolling back database to tip revision 0 (undo commit)
+  your working directory is now based on revision 0
 
 qrecord
 
diff -r 69e69b131458 -r 9705430d311a tests/test-hook.t
--- a/tests/test-hook.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-hook.t	Thu Feb 10 09:03:06 2011 +0100
@@ -223,7 +223,8 @@
   added 1 changesets with 1 changes to 1 files
   (run 'hg update' to get a working copy)
   $ hg rollback
-  rolling back to revision 3 (undo pull)
+  rolling back database to tip revision 3 (undo pull)
+  your working directory is now based on revision 0
 
 preoutgoing hook can prevent outgoing changes
 
diff -r 69e69b131458 -r 9705430d311a tests/test-import.t
--- a/tests/test-import.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-import.t	Thu Feb 10 09:03:06 2011 +0100
@@ -364,7 +364,8 @@
   applying ../patch2
   applied 1d4bd90af0e4
   $ hg --cwd b rollback
-  rolling back to revision 1 (undo commit)
+  rolling back database to tip revision 1 (undo commit)
+  your working directory is now based on revision 1
   $ hg --cwd b parents --template 'parent: {rev}\n'
   parent: 1
   $ rm -r b
diff -r 69e69b131458 -r 9705430d311a tests/test-keyword.t
--- a/tests/test-keyword.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-keyword.t	Thu Feb 10 09:03:06 2011 +0100
@@ -352,7 +352,8 @@
   +bar
 
   $ hg rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2
 
 Record all chunks in file a
 
@@ -394,7 +395,8 @@
   xxx $
   bar
   $ hg --verbose rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2
   overwriting a expanding keywords
   $ hg status a
   M a
@@ -411,7 +413,8 @@
   $ cat z
   $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
   $ hg --verbose rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2
   overwriting z shrinking keywords
 
 Only z should be overwritten
@@ -437,7 +440,8 @@
   committed changeset 3:899491280810
   overwriting r expanding keywords
   $ hg --verbose rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2
   overwriting r shrinking keywords
   $ hg forget r
   $ rm msg r
@@ -601,7 +605,8 @@
 Status after rollback:
 
   $ hg rollback
-  rolling back to revision 1 (undo commit)
+  rolling back database to tip revision 1 (undo commit)
+  your working directory is now based on revision 1
   $ hg status
   A c
   $ hg update --clean
@@ -622,7 +627,8 @@
   $ rm x
 
   $ hg rollback
-  rolling back to revision 1 (undo commit)
+  rolling back database to tip revision 1 (undo commit)
+  your working directory is now based on revision 1
   $ hg update --clean
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ rm i symignored
@@ -735,7 +741,8 @@
 Rollback, revert, and check expansion
 
   $ hg rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2
   $ hg status
   R a
   ? c
@@ -811,7 +818,8 @@
   ignore $Id$
 
   $ hg rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2
   $ hg update --clean
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
diff -r 69e69b131458 -r 9705430d311a tests/test-newbranch.t
--- a/tests/test-newbranch.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-newbranch.t	Thu Feb 10 09:03:06 2011 +0100
@@ -105,7 +105,8 @@
 Test for invalid branch cache:
 
   $ hg rollback
-  rolling back to revision 4 (undo commit)
+  rolling back database to tip revision 4 (undo commit)
+  your working directory is now based on revision 4 and 3
 
   $ cp $branchcache .hg/bc-invalid
 
diff -r 69e69b131458 -r 9705430d311a tests/test-notify.t
--- a/tests/test-notify.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-notify.t	Thu Feb 10 09:03:06 2011 +0100
@@ -152,7 +152,8 @@
 fail for config file is missing
 
   $ hg --cwd b rollback
-  rolling back to revision 0 (undo pull)
+  rolling back database to tip revision 0 (undo pull)
+  your working directory is now based on revision 0
   $ hg --cwd b pull ../a 2>&1 | grep 'error.*\.notify\.conf' > /dev/null && echo pull failed
   pull failed
   $ touch ".notify.conf"
@@ -160,7 +161,8 @@
 pull
 
   $ hg --cwd b rollback
-  rolling back to revision 0 (undo pull)
+  rolling back database to tip revision 0 (undo pull)
+  your working directory is now based on revision 0
   $ hg --traceback --cwd b pull ../a  | \
   >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
@@ -204,7 +206,8 @@
 pull
 
   $ hg --cwd b rollback
-  rolling back to revision 0 (undo pull)
+  rolling back database to tip revision 0 (undo pull)
+  your working directory is now based on revision 0
   $ hg --traceback --cwd b pull ../a | \
   >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
diff -r 69e69b131458 -r 9705430d311a tests/test-pull-r.t
--- a/tests/test-pull-r.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-pull-r.t	Thu Feb 10 09:03:06 2011 +0100
@@ -42,7 +42,8 @@
   $ hg -q parents
   0:bbd179dfa0a7
   $ hg rollback
-  rolling back to revision -1 (undo pull)
+  rolling back database to tip revision -1 (undo pull)
+  your working directory is now based on revision -1
 
   $ hg pull -qr 0 ../repo
   $ hg log
diff -r 69e69b131458 -r 9705430d311a tests/test-pull.t
--- a/tests/test-pull.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-pull.t	Thu Feb 10 09:03:06 2011 +0100
@@ -49,7 +49,7 @@
   no changes found
 
   $ hg rollback --dry-run --verbose
-  rolling back to revision -1 (undo pull: http://foo:***@localhost:$HGPORT/)
+  rolling back database to tip revision -1 (undo pull: http://foo:***@localhost:$HGPORT/)
 
 Issue622: hg init && hg pull -u URL doesn't checkout default branch
 
diff -r 69e69b131458 -r 9705430d311a tests/test-push-http.t
--- a/tests/test-push-http.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-push-http.t	Thu Feb 10 09:03:06 2011 +0100
@@ -64,7 +64,8 @@
   remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http 
   % serve errors
   $ hg rollback
-  rolling back to revision 0 (undo serve)
+  rolling back database to tip revision 0 (undo serve)
+  your working directory is now based on revision 0
 
 expect authorization error: all users denied
 
diff -r 69e69b131458 -r 9705430d311a tests/test-rename-after-merge.t
--- a/tests/test-rename-after-merge.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-rename-after-merge.t	Thu Feb 10 09:03:06 2011 +0100
@@ -97,7 +97,8 @@
   copies:      c2 (c1)
 
   $ hg rollback
-  rolling back to revision 2 (undo commit)
+  rolling back database to tip revision 2 (undo commit)
+  your working directory is now based on revision 2 and 1
 
   $ hg up -C .
   2 files updated, 0 files merged, 2 files removed, 0 files unresolved
diff -r 69e69b131458 -r 9705430d311a tests/test-rollback.t
--- a/tests/test-rollback.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-rollback.t	Thu Feb 10 09:03:06 2011 +0100
@@ -20,7 +20,8 @@
   
   $ hg status
   $ hg rollback
-  rolling back to revision -1 (undo commit)
+  rolling back database to tip revision -1 (undo commit)
+  your working directory is now based on revision -1
   $ hg verify
   checking changesets
   checking manifests
@@ -37,7 +38,8 @@
   $ hg branch test
   marked working directory as branch test
   $ hg rollback
-  rolling back to revision -1 (undo commit)
+  rolling back database to tip revision -1 (undo commit)
+  your working directory is now based on revision -1
   $ hg branch
   default
 
@@ -54,8 +56,9 @@
   marked working directory as branch test
   $ rm .hg/undo.branch
   $ hg rollback
-  rolling back to revision -1 (undo commit)
+  rolling back database to tip revision -1 (undo commit)
   Named branch could not be reset, current branch still is: test
+  your working directory is now based on revision -1
   $ hg branch
   test
 
diff -r 69e69b131458 -r 9705430d311a tests/test-tag.t
--- a/tests/test-tag.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-tag.t	Thu Feb 10 09:03:06 2011 +0100
@@ -210,7 +210,8 @@
 
   $ hg tag hgtags-modified
   $ hg rollback
-  rolling back to revision 11 (undo commit)
+  rolling back database to tip revision 11 (undo commit)
+  your working directory is now based on revision 11
   $ hg st
   M .hgtags
   ? .hgtags.orig
diff -r 69e69b131458 -r 9705430d311a tests/test-tags.t
--- a/tests/test-tags.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-tags.t	Thu Feb 10 09:03:06 2011 +0100
@@ -265,7 +265,8 @@
 Undo a tag with rollback:
 
   $ hg rollback             # destroy rev 5 (restore bar)
-  rolling back to revision 4 (undo commit)
+  rolling back database to tip revision 4 (undo commit)
+  your working directory is now based on revision 4
   $ hg tags
   tip                                4:0c192d7d5e6b
   bar                                1:78391a272241
diff -r 69e69b131458 -r 9705430d311a tests/test-url-rev.t
--- a/tests/test-url-rev.t	Fri Feb 04 09:17:07 2011 +0100
+++ b/tests/test-url-rev.t	Thu Feb 10 09:03:06 2011 +0100
@@ -101,7 +101,8 @@
 
   $ cd clone
   $ hg rollback
-  rolling back to revision 1 (undo push)
+  rolling back database to tip revision 1 (undo push)
+  your working directory is now based on revision 1
 
   $ hg -q incoming
   2:faba9097cad4
@@ -145,7 +146,8 @@
   0:1f0dee641bb7
 
   $ hg rollback
-  rolling back to revision 1 (undo pull)
+  rolling back database to tip revision 1 (undo pull)
+  your working directory is now based on revision 1
 
   $ hg up -C 0
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -166,7 +168,8 @@
   summary:     new head of branch foo
   
   $ hg rollback
-  rolling back to revision 1 (undo pull)
+  rolling back database to tip revision 1 (undo pull)
+  your working directory is now based on revision 0
 
   $ hg up -C 0
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list