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
--- a/hgext/strip.py Sun Nov 15 21:03:44 2015 +0530
+++ b/hgext/strip.py Thu Nov 19 12:50:10 2015 +0530
@@ -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):
@@ -146,8 +144,8 @@
nodetobookmarks.setdefault(node, []).append(mark)
for marks in nodetobookmarks.values():
if bookmarks.issuperset(marks):
- rsrevs = repair.stripbmrevset(repo, marks[0])
- revs.update(set(rsrevs))
+ rsrevs = repair.stripbmrevset(repo, marks[0])
+ revs.update(set(rsrevs))
if not revs:
for bookmark in bookmarks:
del repomarks[bookmark]
--- a/tests/test-strip.t Sun Nov 15 21:03:44 2015 +0530
+++ b/tests/test-strip.t Thu Nov 19 12:50:10 2015 +0530
@@ -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]