Show More
@@ -767,9 +767,8 b' def bisect(ui, repo, rev=None, extra=Non' | |||
|
767 | 767 | ('d', 'delete', False, _('delete a given bookmark')), |
|
768 | 768 | ('m', 'rename', '', _('rename a given bookmark'), _('NAME')), |
|
769 | 769 | ('i', 'inactive', False, _('mark a bookmark inactive'))], |
|
770 |
_('hg bookmarks [ |
|
|
771 | def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, | |
|
772 | rename=None, inactive=False): | |
|
770 | _('hg bookmarks [OPTIONS]... [NAME]...')) | |
|
771 | def bookmark(ui, repo, *names, **opts): | |
|
773 | 772 | '''track a line of development with movable markers |
|
774 | 773 | |
|
775 | 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 | 795 | active even if -i/--inactive is not given. If no NAME is given, the |
|
797 | 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 | 804 | hexfn = ui.debugflag and hex or short |
|
800 | 805 | marks = repo._bookmarks |
|
801 | 806 | cur = repo.changectx('.').node() |
@@ -846,21 +851,24 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
846 | 851 | raise util.Abort(_("--rev is incompatible with --delete")) |
|
847 | 852 | if rename and rev: |
|
848 | 853 | raise util.Abort(_("--rev is incompatible with --rename")) |
|
849 |
if |
|
|
854 | if not names and (delete or rev): | |
|
850 | 855 | raise util.Abort(_("bookmark name required")) |
|
851 | 856 | |
|
852 | 857 | if delete: |
|
853 |
|
|
|
854 | raise util.Abort(_("bookmark '%s' does not exist") % mark) | |
|
855 | if mark == repo._bookmarkcurrent: | |
|
856 |
|
|
|
857 | del marks[mark] | |
|
858 | for mark in names: | |
|
859 | if mark not in marks: | |
|
860 | raise util.Abort(_("bookmark '%s' does not exist") % mark) | |
|
861 | if mark == repo._bookmarkcurrent: | |
|
862 | bookmarks.setcurrent(repo, None) | |
|
863 | del marks[mark] | |
|
858 | 864 | marks.write() |
|
859 | 865 | |
|
860 | 866 | elif rename: |
|
861 |
if |
|
|
867 | if not names: | |
|
862 | 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 | 872 | if rename not in marks: |
|
865 | 873 | raise util.Abort(_("bookmark '%s' does not exist") % rename) |
|
866 | 874 | checkconflict(repo, mark, force) |
@@ -870,19 +878,23 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
870 | 878 | del marks[rename] |
|
871 | 879 | marks.write() |
|
872 | 880 | |
|
873 |
elif |
|
|
874 | mark = checkformat(mark) | |
|
875 | if inactive and mark == repo._bookmarkcurrent: | |
|
876 | bookmarks.setcurrent(repo, None) | |
|
877 |
|
|
|
878 | tgt = cur | |
|
879 | if rev: | |
|
880 | tgt = scmutil.revsingle(repo, rev).node() | |
|
881 | checkconflict(repo, mark, force, tgt) | |
|
882 | marks[mark] = tgt | |
|
883 | if not inactive and cur == marks[mark] and not rev: | |
|
884 | bookmarks.setcurrent(repo, mark) | |
|
885 | elif cur != tgt and mark == repo._bookmarkcurrent: | |
|
881 | elif names: | |
|
882 | newact = None | |
|
883 | for mark in names: | |
|
884 | mark = checkformat(mark) | |
|
885 | if newact is None: | |
|
886 | newact = mark | |
|
887 | if inactive and mark == repo._bookmarkcurrent: | |
|
888 | bookmarks.setcurrent(repo, None) | |
|
889 | return | |
|
890 | tgt = cur | |
|
891 | if rev: | |
|
892 | tgt = scmutil.revsingle(repo, rev).node() | |
|
893 | checkconflict(repo, mark, force, tgt) | |
|
894 | marks[mark] = tgt | |
|
895 | if not inactive and cur == marks[newact] and not rev: | |
|
896 | bookmarks.setcurrent(repo, newact) | |
|
897 | elif cur != tgt and newact == repo._bookmarkcurrent: | |
|
886 | 898 | bookmarks.setcurrent(repo, None) |
|
887 | 899 | marks.write() |
|
888 | 900 |
@@ -43,16 +43,19 b' list bookmarks' | |||
|
43 | 43 | $ hg bookmarks |
|
44 | 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 | 50 | list bookmarks |
|
51 | 51 | |
|
52 | 52 | $ hg bookmark |
|
53 | X -1:000000000000 | |
|
53 | 54 | * Y -1:000000000000 |
|
54 | 55 | Z -1:000000000000 |
|
55 | 56 | |
|
57 | $ hg bookmark -d X | |
|
58 | ||
|
56 | 59 | commit |
|
57 | 60 | |
|
58 | 61 | $ echo 'b' > b |
@@ -168,11 +168,14 b' bookmarks from a revset' | |||
|
168 | 168 | $ hg bookmark -d REVSET |
|
169 | 169 | $ hg bookmark -d TIP |
|
170 | 170 | |
|
171 | rename without new name | |
|
171 | rename without new name or multiple names | |
|
172 | 172 | |
|
173 | 173 | $ hg bookmark -m Y |
|
174 | 174 | abort: new bookmark name required |
|
175 | 175 | [255] |
|
176 | $ hg bookmark -m Y Y2 Y3 | |
|
177 | abort: only one new bookmark name allowed | |
|
178 | [255] | |
|
176 | 179 | |
|
177 | 180 | delete without name |
|
178 | 181 | |
@@ -417,8 +420,9 b' test clone with pull protocol' | |||
|
417 | 420 | a@ 2:db815d6d32e6 |
|
418 | 421 | x y 2:db815d6d32e6 |
|
419 | 422 | |
|
420 | $ hg bookmark -d @ | |
|
421 | $ hg bookmark -d a@ | |
|
423 | delete multiple bookmarks at once | |
|
424 | ||
|
425 | $ hg bookmark -d @ a@ | |
|
422 | 426 | |
|
423 | 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