[PATCH 3 of 3] strip: changing bookmark argument to be a list

Shubhanshu Agrawal agrawal.shubhanshu at gmail.com
Wed Nov 18 07:45:54 CST 2015


# HG changeset patch
# User Shubhanshu Agrawal <agrawal.shubhanshu at gmail.com>
# Date 1447603596 -19800
#      Sun Nov 15 21:36:36 2015 +0530
# Node ID 66b6b5792a6e863911c6a27039b1d208aac35d44
# Parent  35e416149468f0c5aaf1ddaccc0c7c360b6bded1
strip: changing bookmark argument to be a list

Currently strip works with a single bookmark,
the changes in this patch modifies the strip
extension to accept a list of bookmarks

diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -69,7 +69,7 @@
             for bookmark in bookmarks:
                 del repomarks[bookmark]
             repomarks.write()
-            for bookmark in bookmarks:
+            for bookmark in sorted(bookmarks):
                 ui.write(_("bookmark '%s' deleted\n") % bookmark)
     finally:
         release(lock, wlock)
@@ -87,7 +87,7 @@
           ('n', '', None, _('ignored  (DEPRECATED)')),
           ('k', 'keep', None, _("do not modify working directory during "
                                 "strip")),
-          ('B', 'bookmark', '', _("remove revs only reachable from given"
+          ('B', 'bookmark', [], _("remove revs only reachable from given"
                                   " bookmark"))],
           _('hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...'))
 def stripcmd(ui, repo, *revs, **opts):
@@ -129,9 +129,7 @@
 
     wlock = repo.wlock()
     try:
-        bookmarks = None
-        if opts.get('bookmark'):
-            bookmarks = set([opts.get('bookmark')])
+        bookmarks = set(opts.get('bookmark'))
         if bookmarks: 
             repomarks = repo._bookmarks
             if not bookmarks.issubset(repomarks):
@@ -152,7 +150,7 @@
                 for bookmark in bookmarks:
                     del repomarks[bookmark]
                 repomarks.write()
-                for bookmark in bookmarks:
+                for bookmark in sorted(bookmarks):
                     ui.write(_("bookmark '%s' deleted\n") % bookmark)
 
         if not revs:
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -573,11 +573,15 @@
   $ cd ..
   $ hg init bookmarks
   $ cd bookmarks
-  $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b'
+  $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b<m+2:d<2.:e<m+1:f'
   $ hg bookmark -r 'a' 'todelete'
   $ hg bookmark -r 'b' 'B'
   $ hg bookmark -r 'b' 'nostrip'
   $ hg bookmark -r 'c' 'delete'
+  $ hg bookmark -r 'd' 'multipledelete1'
+  $ hg bookmark -r 'e' 'multipledelete2'
+  $ hg bookmark -r 'f' 'singlenode1'
+  $ hg bookmark -r 'f' 'singlenode2'
   $ hg up -C todelete
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark todelete)
@@ -597,6 +601,36 @@
   $ hg bookmarks
      B                         9:ff43616e5d0f
      delete                    6:2702dd0c91e7
+     multipledelete1           11:e46a4836065c
+     multipledelete2           12:b4594d867745
+     singlenode1               13:43227190fef8
+     singlenode2               13:43227190fef8
+  $ hg strip -B multipledelete1 -B multipledelete2
+  saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/e46a4836065c-89ec65c2-backup.hg (glob)
+  bookmark 'multipledelete1' deleted
+  bookmark 'multipledelete2' deleted
+  $ hg id -ir e46a4836065c
+  abort: unknown revision 'e46a4836065c'!
+  [255]
+  $ hg id -ir b4594d867745
+  abort: unknown revision 'b4594d867745'!
+  [255]
+  $ hg strip -B singlenode1 -B singlenode2
+  saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg (glob)
+  bookmark 'singlenode1' deleted
+  bookmark 'singlenode2' deleted
+  $ hg id -ir 43227190fef8
+  abort: unknown revision '43227190fef8'!
+  [255]
+  $ hg strip -B unknownbookmark
+  abort: bookmark 'unknownbookmark' not found
+  [255]
+  $ hg strip -B unknownbookmark1 -B unknownbookmark2
+  abort: bookmark 'unknownbookmark1,unknownbookmark2' not found
+  [255]
+  $ hg strip -B delete -B unknownbookmark
+  abort: bookmark 'unknownbookmark' not found
+  [255]
   $ hg strip -B delete
   saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
   bookmark 'delete' deleted
@@ -626,14 +660,14 @@
   
   options ([+] can be repeated):
   
-   -r --rev REV [+]    strip specified revision (optional, can specify revisions
-                       without this option)
-   -f --force          force removal of changesets, discard uncommitted changes
-                       (no backup)
-      --no-backup      no backups
-   -k --keep           do not modify working directory during strip
-   -B --bookmark VALUE remove revs only reachable from given bookmark
-      --mq             operate on patch repository
+   -r --rev REV [+]        strip specified revision (optional, can specify
+                           revisions without this option)
+   -f --force              force removal of changesets, discard uncommitted
+                           changes (no backup)
+      --no-backup          no backups
+   -k --keep               do not modify working directory during strip
+   -B --bookmark VALUE [+] remove revs only reachable from given bookmark
+      --mq                 operate on patch repository
   
   (use "hg strip -h" to show more help)
   [255]


More information about the Mercurial-devel mailing list