##// END OF EJS Templates
strip: introduce -B option to remove a bookmark...
David Soria Parra -
r16718:3290e24b default
parent child Browse files
Show More
@@ -2890,8 +2890,10 b' def save(ui, repo, **opts):'
2890 ('', 'no-backup', None, _('no backups')),
2890 ('', 'no-backup', None, _('no backups')),
2891 ('', 'nobackup', None, _('no backups (DEPRECATED)')),
2891 ('', 'nobackup', None, _('no backups (DEPRECATED)')),
2892 ('n', '', None, _('ignored (DEPRECATED)')),
2892 ('n', '', None, _('ignored (DEPRECATED)')),
2893 ('k', 'keep', None, _("do not modify working copy during strip"))],
2893 ('k', 'keep', None, _("do not modify working copy during strip")),
2894 _('hg strip [-k] [-f] [-n] REV...'))
2894 ('B', 'bookmark', '', _("remove revs only reachable from given"
2895 " bookmark"))],
2896 _('hg strip [-k] [-f] [-n] [-B bookmark] REV...'))
2895 def strip(ui, repo, *revs, **opts):
2897 def strip(ui, repo, *revs, **opts):
2896 """strip changesets and all their descendants from the repository
2898 """strip changesets and all their descendants from the repository
2897
2899
@@ -2926,6 +2928,32 b' def strip(ui, repo, *revs, **opts):'
2926 cl = repo.changelog
2928 cl = repo.changelog
2927 revs = list(revs) + opts.get('rev')
2929 revs = list(revs) + opts.get('rev')
2928 revs = set(scmutil.revrange(repo, revs))
2930 revs = set(scmutil.revrange(repo, revs))
2931
2932 if opts.get('bookmark'):
2933 mark = opts.get('bookmark')
2934 marks = repo._bookmarks
2935 if mark not in marks:
2936 raise util.Abort(_("bookmark '%s' not found") % mark)
2937
2938 # If the requested bookmark is not the only one pointing to a
2939 # a revision we have to only delete the bookmark and not strip
2940 # anything. revsets cannot detect that case.
2941 uniquebm = True
2942 for m, n in marks.iteritems():
2943 if m != mark and n == repo[mark].node():
2944 uniquebm = False
2945 break
2946 if uniquebm:
2947 rsrevs = repo.revs("ancestors(bookmark(%s)) - "
2948 "ancestors(head() and not bookmark(%s)) - "
2949 "ancestors(bookmark() and not bookmark(%s))",
2950 mark, mark, mark)
2951 revs.update(set(rsrevs))
2952 if not revs:
2953 del marks[mark]
2954 repo._writebookmarks(mark)
2955 ui.write(_("bookmark '%s' deleted\n") % mark)
2956
2929 if not revs:
2957 if not revs:
2930 raise util.Abort(_('empty revision set'))
2958 raise util.Abort(_('empty revision set'))
2931
2959
@@ -2973,6 +3001,12 b' def strip(ui, repo, *revs, **opts):'
2973
3001
2974 repo.mq.strip(repo, revs, backup=backup, update=update,
3002 repo.mq.strip(repo, revs, backup=backup, update=update,
2975 force=opts.get('force'))
3003 force=opts.get('force'))
3004
3005 if opts.get('bookmark'):
3006 del marks[mark]
3007 repo._writebookmarks(marks)
3008 ui.write(_("bookmark '%s' deleted\n") % mark)
3009
2976 return 0
3010 return 0
2977
3011
2978 @command("qselect",
3012 @command("qselect",
@@ -430,3 +430,37 b' stripping many nodes on a complex graph '
430 $ hg strip 'not ancestors(x)'
430 $ hg strip 'not ancestors(x)'
431 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
431 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
432
432
433 test hg strip -B bookmark
434
435 $ cd ..
436 $ hg init bookmarks
437 $ cd bookmarks
438 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b'
439 $ hg bookmark -r 'a' 'todelete'
440 $ hg bookmark -r 'b' 'B'
441 $ hg bookmark -r 'b' 'nostrip'
442 $ hg bookmark -r 'c' 'delete'
443 $ hg up -C todelete
444 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
445 $ hg strip -B nostrip
446 bookmark 'nostrip' deleted
447 abort: empty revision set
448 [255]
449 $ hg strip -B todelete
450 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
451 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
452 bookmark 'todelete' deleted
453 $ hg id -ir dcbb326fdec2
454 abort: unknown revision 'dcbb326fdec2'!
455 [255]
456 $ hg id -ir d62d843c9a01
457 d62d843c9a01
458 $ hg bookmarks
459 B 9:ff43616e5d0f
460 delete 6:2702dd0c91e7
461 $ hg strip -B delete
462 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
463 bookmark 'delete' deleted
464 $ hg id -ir 6:2702dd0c91e7
465 abort: unknown revision '2702dd0c91e7'!
466 [255]
General Comments 0
You need to be logged in to leave comments. Login now