bookmarks: respect rollbacks dryrun parameter stable
authorDavid Soria Parra <dsp@php.net>
Thu, 27 Jan 2011 02:58:48 +0100
branchstable
changeset 13307 7f2b8aac7bdc
parent 13306 146bad852ede
child 13312 9f188734dbb0
bookmarks: respect rollbacks dryrun parameter
hgext/bookmarks.py
tests/test-bookmarks-strip.t
--- a/hgext/bookmarks.py	Thu Jan 27 02:55:11 2011 +0100
+++ b/hgext/bookmarks.py	Thu Jan 27 02:58:48 2011 +0100
@@ -261,10 +261,14 @@
                 file.close()
             return mark
 
-        def rollback(self, *args):
+        def rollback(self, dryrun=False):
             if os.path.exists(self.join('undo.bookmarks')):
-                util.rename(self.join('undo.bookmarks'), self.join('bookmarks'))
-            return super(bookmark_repo, self).rollback(*args)
+                if not dryrun:
+                    util.rename(self.join('undo.bookmarks'), self.join('bookmarks'))
+                elif not os.path.exists(self.sjoin("undo")):
+                    # avoid "no rollback information available" message
+                    return 0
+            return super(bookmark_repo, self).rollback(dryrun)
 
         def lookup(self, key):
             if key in self._bookmarks:
--- a/tests/test-bookmarks-strip.t	Thu Jan 27 02:55:11 2011 +0100
+++ b/tests/test-bookmarks-strip.t	Thu Jan 27 02:58:48 2011 +0100
@@ -6,6 +6,12 @@
 
   $ echo qqq>qqq.txt
 
+rollback dry run without rollback information
+
+  $ hg rollback
+  no rollback information available
+  [1]
+
 add file
 
   $ hg add
@@ -83,5 +89,12 @@
   $ hg bookmarks markb
   $ hg bookmarks
    * markb                     0:07f494440405
+
+rollback dry run with rollback information
+
+  $ hg rollback -n
+  $ hg bookmarks
+   * markb                     0:07f494440405
+
   $ cd ..