##// END OF EJS Templates
bookmarks: allow bookmark command to take multiple arguments...
Kevin Bullock -
r19147:5b183548 default
parent child Browse files
Show More
@@ -767,9 +767,8 b' def bisect(ui, repo, rev=None, extra=Non'
767 ('d', 'delete', False, _('delete a given bookmark')),
767 ('d', 'delete', False, _('delete a given bookmark')),
768 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
768 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
769 ('i', 'inactive', False, _('mark a bookmark inactive'))],
769 ('i', 'inactive', False, _('mark a bookmark inactive'))],
770 _('hg bookmarks [-f] [-d] [-i] [-m NAME] [-r REV] [NAME]'))
770 _('hg bookmarks [OPTIONS]... [NAME]...'))
771 def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False,
771 def bookmark(ui, repo, *names, **opts):
772 rename=None, inactive=False):
773 '''track a line of development with movable markers
772 '''track a line of development with movable markers
774
773
775 Bookmarks are pointers to certain commits that move when committing.
774 Bookmarks are pointers to certain commits that move when committing.
@@ -796,6 +795,12 b' def bookmark(ui, repo, mark=None, rev=No'
796 active even if -i/--inactive is not given. If no NAME is given, the
795 active even if -i/--inactive is not given. If no NAME is given, the
797 current active bookmark will be marked inactive.
796 current active bookmark will be marked inactive.
798 '''
797 '''
798 force = opts.get('force')
799 rev = opts.get('rev')
800 delete = opts.get('delete')
801 rename = opts.get('rename')
802 inactive = opts.get('inactive')
803
799 hexfn = ui.debugflag and hex or short
804 hexfn = ui.debugflag and hex or short
800 marks = repo._bookmarks
805 marks = repo._bookmarks
801 cur = repo.changectx('.').node()
806 cur = repo.changectx('.').node()
@@ -846,10 +851,11 b' def bookmark(ui, repo, mark=None, rev=No'
846 raise util.Abort(_("--rev is incompatible with --delete"))
851 raise util.Abort(_("--rev is incompatible with --delete"))
847 if rename and rev:
852 if rename and rev:
848 raise util.Abort(_("--rev is incompatible with --rename"))
853 raise util.Abort(_("--rev is incompatible with --rename"))
849 if mark is None and (delete or rev):
854 if not names and (delete or rev):
850 raise util.Abort(_("bookmark name required"))
855 raise util.Abort(_("bookmark name required"))
851
856
852 if delete:
857 if delete:
858 for mark in names:
853 if mark not in marks:
859 if mark not in marks:
854 raise util.Abort(_("bookmark '%s' does not exist") % mark)
860 raise util.Abort(_("bookmark '%s' does not exist") % mark)
855 if mark == repo._bookmarkcurrent:
861 if mark == repo._bookmarkcurrent:
@@ -858,9 +864,11 b' def bookmark(ui, repo, mark=None, rev=No'
858 marks.write()
864 marks.write()
859
865
860 elif rename:
866 elif rename:
861 if mark is None:
867 if not names:
862 raise util.Abort(_("new bookmark name required"))
868 raise util.Abort(_("new bookmark name required"))
863 mark = checkformat(mark)
869 elif len(names) > 1:
870 raise util.Abort(_("only one new bookmark name allowed"))
871 mark = checkformat(names[0])
864 if rename not in marks:
872 if rename not in marks:
865 raise util.Abort(_("bookmark '%s' does not exist") % rename)
873 raise util.Abort(_("bookmark '%s' does not exist") % rename)
866 checkconflict(repo, mark, force)
874 checkconflict(repo, mark, force)
@@ -870,8 +878,12 b' def bookmark(ui, repo, mark=None, rev=No'
870 del marks[rename]
878 del marks[rename]
871 marks.write()
879 marks.write()
872
880
873 elif mark is not None:
881 elif names:
882 newact = None
883 for mark in names:
874 mark = checkformat(mark)
884 mark = checkformat(mark)
885 if newact is None:
886 newact = mark
875 if inactive and mark == repo._bookmarkcurrent:
887 if inactive and mark == repo._bookmarkcurrent:
876 bookmarks.setcurrent(repo, None)
888 bookmarks.setcurrent(repo, None)
877 return
889 return
@@ -880,9 +892,9 b' def bookmark(ui, repo, mark=None, rev=No'
880 tgt = scmutil.revsingle(repo, rev).node()
892 tgt = scmutil.revsingle(repo, rev).node()
881 checkconflict(repo, mark, force, tgt)
893 checkconflict(repo, mark, force, tgt)
882 marks[mark] = tgt
894 marks[mark] = tgt
883 if not inactive and cur == marks[mark] and not rev:
895 if not inactive and cur == marks[newact] and not rev:
884 bookmarks.setcurrent(repo, mark)
896 bookmarks.setcurrent(repo, newact)
885 elif cur != tgt and mark == repo._bookmarkcurrent:
897 elif cur != tgt and newact == repo._bookmarkcurrent:
886 bookmarks.setcurrent(repo, None)
898 bookmarks.setcurrent(repo, None)
887 marks.write()
899 marks.write()
888
900
@@ -43,16 +43,19 b' list bookmarks'
43 $ hg bookmarks
43 $ hg bookmarks
44 * Z -1:000000000000
44 * Z -1:000000000000
45
45
46 new bookmark Y
46 new bookmarks X and Y, first one made active
47
47
48 $ hg bookmark Y
48 $ hg bookmark Y X
49
49
50 list bookmarks
50 list bookmarks
51
51
52 $ hg bookmark
52 $ hg bookmark
53 X -1:000000000000
53 * Y -1:000000000000
54 * Y -1:000000000000
54 Z -1:000000000000
55 Z -1:000000000000
55
56
57 $ hg bookmark -d X
58
56 commit
59 commit
57
60
58 $ echo 'b' > b
61 $ echo 'b' > b
@@ -168,11 +168,14 b' bookmarks from a revset'
168 $ hg bookmark -d REVSET
168 $ hg bookmark -d REVSET
169 $ hg bookmark -d TIP
169 $ hg bookmark -d TIP
170
170
171 rename without new name
171 rename without new name or multiple names
172
172
173 $ hg bookmark -m Y
173 $ hg bookmark -m Y
174 abort: new bookmark name required
174 abort: new bookmark name required
175 [255]
175 [255]
176 $ hg bookmark -m Y Y2 Y3
177 abort: only one new bookmark name allowed
178 [255]
176
179
177 delete without name
180 delete without name
178
181
@@ -417,8 +420,9 b' test clone with pull protocol'
417 a@ 2:db815d6d32e6
420 a@ 2:db815d6d32e6
418 x y 2:db815d6d32e6
421 x y 2:db815d6d32e6
419
422
420 $ hg bookmark -d @
423 delete multiple bookmarks at once
421 $ hg bookmark -d a@
424
425 $ hg bookmark -d @ a@
422
426
423 test clone with a bookmark named "default" (issue3677)
427 test clone with a bookmark named "default" (issue3677)
424
428
General Comments 0
You need to be logged in to leave comments. Login now