equal
deleted
inserted
replaced
955 rev = opts.get('rev') |
955 rev = opts.get('rev') |
956 delete = opts.get('delete') |
956 delete = opts.get('delete') |
957 rename = opts.get('rename') |
957 rename = opts.get('rename') |
958 inactive = opts.get('inactive') |
958 inactive = opts.get('inactive') |
959 |
959 |
960 def checkformat(mark): |
|
961 mark = mark.strip() |
|
962 if not mark: |
|
963 raise error.Abort(_("bookmark names cannot consist entirely of " |
|
964 "whitespace")) |
|
965 scmutil.checknewlabel(repo, mark, 'bookmark') |
|
966 return mark |
|
967 |
|
968 def checkconflict(repo, mark, cur, force=False, target=None): |
960 def checkconflict(repo, mark, cur, force=False, target=None): |
969 if mark in marks and not force: |
961 if mark in marks and not force: |
970 if target: |
962 if target: |
971 if marks[mark] == target and target == cur: |
963 if marks[mark] == target and target == cur: |
972 # re-activating a bookmark |
964 # re-activating a bookmark |
1037 tr = repo.transaction('bookmark') |
1029 tr = repo.transaction('bookmark') |
1038 if not names: |
1030 if not names: |
1039 raise error.Abort(_("new bookmark name required")) |
1031 raise error.Abort(_("new bookmark name required")) |
1040 elif len(names) > 1: |
1032 elif len(names) > 1: |
1041 raise error.Abort(_("only one new bookmark name allowed")) |
1033 raise error.Abort(_("only one new bookmark name allowed")) |
1042 mark = checkformat(names[0]) |
1034 mark = bookmarks.checkformat(repo, names[0]) |
1043 if rename not in marks: |
1035 if rename not in marks: |
1044 raise error.Abort(_("bookmark '%s' does not exist") |
1036 raise error.Abort(_("bookmark '%s' does not exist") |
1045 % rename) |
1037 % rename) |
1046 checkconflict(repo, mark, cur, force) |
1038 checkconflict(repo, mark, cur, force) |
1047 marks[mark] = marks[rename] |
1039 marks[mark] = marks[rename] |
1050 del marks[rename] |
1042 del marks[rename] |
1051 elif names: |
1043 elif names: |
1052 tr = repo.transaction('bookmark') |
1044 tr = repo.transaction('bookmark') |
1053 newact = None |
1045 newact = None |
1054 for mark in names: |
1046 for mark in names: |
1055 mark = checkformat(mark) |
1047 mark = bookmarks.checkformat(repo, mark) |
1056 if newact is None: |
1048 if newact is None: |
1057 newact = mark |
1049 newact = mark |
1058 if inactive and mark == repo._activebookmark: |
1050 if inactive and mark == repo._activebookmark: |
1059 bookmarks.deactivate(repo) |
1051 bookmarks.deactivate(repo) |
1060 return |
1052 return |