Patchwork [3,of,3,evolve-ext,v2] prune: changing bookmark argument to be a list

login
register
mail settings
Submitter Shubhanshu Agrawal
Date Dec. 11, 2015, 8:28 p.m.
Message ID <3a9a7fde9489b523d256.1449865713@shubhanshu-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/11978/
State Accepted
Headers show

Comments

Shubhanshu Agrawal - Dec. 11, 2015, 8:28 p.m.
# HG changeset patch
# User Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
# Date 1449865657 28800
#      Fri Dec 11 12:27:37 2015 -0800
# Node ID 3a9a7fde9489b523d25658766decda73065e5059
# Parent  dd37098b0235b9bd3f2d43b5fa7c14c2fa12e19d
prune: changing bookmark argument to be a list

Currently prune works with a single bookmark
the changes in this patch modifies the prune
command to accept a list of bookmarks
Also changes to inhibit module which internally
calls the cmdprune function. the change is to
wrap the bookmark input into a list.
Pierre-Yves David - Dec. 12, 2015, 7:28 a.m.
On 12/11/2015 08:28 PM, Shubhanshu Agrawal wrote:
> # HG changeset patch
> # User Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
> # Date 1449865657 28800
> #      Fri Dec 11 12:27:37 2015 -0800
> # Node ID 3a9a7fde9489b523d25658766decda73065e5059
> # Parent  dd37098b0235b9bd3f2d43b5fa7c14c2fa12e19d
> prune: changing bookmark argument to be a list

Pushed to main, thanks.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2268,7 +2268,7 @@ 
         _("record a fold (multiple precursors, one successors)")),
      ('', 'split', False,
         _("record a split (on precursor, multiple successors)")),
-     ('B', 'bookmark', '', _("remove revs only reachable from given"
+     ('B', 'bookmark', [], _("remove revs only reachable from given"
                              " bookmark"))] + metadataopts,
     _('[OPTION] [-r] REV...'))
     # -U  --noupdate option to prevent wc update and or bookmarks update ?
@@ -2297,9 +2297,7 @@ 
     """
     revs = scmutil.revrange(repo, list(revs) + opts.get('rev'))
     succs = opts['new'] + opts['succ']
-    bookmarks = None
-    if opts.get('bookmark'):
-        bookmarks = set([opts.get('bookmark')])
+    bookmarks = set(opts.get('bookmark'))
     metadata = _getmetadata(**opts)
     biject = opts.get('biject')
     fold = opts.get('fold')
diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -89,7 +89,7 @@ 
         'new': [],
         'succ': [],
         'rev': [],
-        'bookmark': bookmarks[0],
+        'bookmark': [bookmarks[0]],
         'keep': None,
         'biject': False,
     }
diff --git a/tests/test-prune.t b/tests/test-prune.t
--- a/tests/test-prune.t
+++ b/tests/test-prune.t
@@ -279,11 +279,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)
@@ -307,6 +311,27 @@ 
   $ hg bookmarks
      B                         10:ff43616e5d0f
      delete                    6:2702dd0c91e7
+     multipledelete1           12:e46a4836065c
+     multipledelete2           13:b4594d867745
+     singlenode1               14:43227190fef8
+     singlenode2               14:43227190fef8
+  $ hg prune -B multipledelete1 -B multipledelete2
+  bookmark 'multipledelete1' deleted
+  bookmark 'multipledelete2' deleted
+  2 changesets pruned
+  $ hg prune -B singlenode1 -B singlenode2
+  bookmark 'singlenode1' deleted
+  bookmark 'singlenode2' deleted
+  1 changesets pruned
+  $ hg prune -B unknownbookmark
+  abort: bookmark 'unknownbookmark' not found
+  [255]
+  $ hg prune -B unknownbookmark1 -B unknownbookmark2
+  abort: bookmark 'unknownbookmark1,unknownbookmark2' not found
+  [255]
+  $ hg prune -B delete -B unknownbookmark
+  abort: bookmark 'unknownbookmark' not found
+  [255]
   $ hg prune -B delete
   bookmark 'delete' deleted
   3 changesets pruned
@@ -317,23 +342,23 @@ 
   [255]
 
   $ hg debugobsstorestat
-  markers total:                      4
-      for known precursors:           4
+  markers total:                      7
+      for known precursors:           7
       with parents data:              [04] (re)
-  markers with no successors:         4
+  markers with no successors:         7
                 1 successors:         0
                 2 successors:         0
       more than 2 successors:         0
       available  keys:
-                 user:                4
-  disconnected clusters:              4
-          any known node:             4
+                 user:                7
+  disconnected clusters:              7
+          any known node:             7
           smallest length:            1
           longer length:              1
           median length:              1
           mean length:                1
-      using parents data:             4
-          any known node:             4
+      using parents data:             7
+          any known node:             7
           smallest length:            1
           longer length:              1
           median length:              1
@@ -347,14 +372,22 @@ 
   (leaving bookmark rg)
   $ hg bookmark r10
   $ hg log -G
-  o  11:cd0038e05e1b[rg] (stable/draft) add rg
+  o  15:cd0038e05e1b[rg] (stable/draft) add rg
   |
-  | @  10:ff43616e5d0f[B r10] (stable/draft) r10
+  | x  14:43227190fef8[] (extinct/draft) r14
+  | |
+  | | x  13:b4594d867745[] (extinct/draft) r13
+  | | |
+  | | | x  12:e46a4836065c[] (extinct/draft) r12
+  | | |/
+  | | o  11:bab5d5bf48bd[] (stable/draft) r11
+  | |/
+  +---@  10:ff43616e5d0f[B r10] (stable/draft) r10
+  | |
+  o |  8:d62d843c9a01[] (stable/draft) r8
+  | |
+  o |  7:e7d9710d9fc6[] (stable/draft) r7
   |/
-  o  8:d62d843c9a01[] (stable/draft) r8
-  |
-  o  7:e7d9710d9fc6[] (stable/draft) r7
-  |
   o    3:2b6d669947cd[] (stable/draft) r3
   |\
   | o  2:fa942426a6fd[] (stable/draft) r2
@@ -366,12 +399,22 @@ 
   $ hg prune 11
   1 changesets pruned
   $ hg log -G
-  @  10:ff43616e5d0f[B r10] (stable/draft) r10
+  o  15:cd0038e05e1b[rg] (stable/draft) add rg
   |
-  o  8:d62d843c9a01[rg] (stable/draft) r8
-  |
-  o  7:e7d9710d9fc6[] (stable/draft) r7
-  |
+  | x  14:43227190fef8[] (extinct/draft) r14
+  | |
+  | | x  13:b4594d867745[] (extinct/draft) r13
+  | | |
+  | | | x  12:e46a4836065c[] (extinct/draft) r12
+  | | |/
+  | | x  11:bab5d5bf48bd[] (extinct/draft) r11
+  | |/
+  +---@  10:ff43616e5d0f[B r10] (stable/draft) r10
+  | |
+  o |  8:d62d843c9a01[] (stable/draft) r8
+  | |
+  o |  7:e7d9710d9fc6[] (stable/draft) r7
+  |/
   o    3:2b6d669947cd[] (stable/draft) r3
   |\
   | o  2:fa942426a6fd[] (stable/draft) r2
@@ -387,5 +430,5 @@ 
      B                         8:d62d843c9a01
    * CELESTE                   8:d62d843c9a01
      r10                       8:d62d843c9a01
-     rg                        8:d62d843c9a01
+     rg                        15:cd0038e05e1b