Show More
@@ -19,6 +19,7 from . import ( | |||||
19 | error, |
|
19 | error, | |
20 | lock as lockmod, |
|
20 | lock as lockmod, | |
21 | obsolete, |
|
21 | obsolete, | |
|
22 | scmutil, | |||
22 | txnutil, |
|
23 | txnutil, | |
23 | util, |
|
24 | util, | |
24 | ) |
|
25 | ) | |
@@ -622,3 +623,15 def validdest(repo, old, new): | |||||
622 | else: |
|
623 | else: | |
623 | # still an independent clause as it is lazier (and therefore faster) |
|
624 | # still an independent clause as it is lazier (and therefore faster) | |
624 | return old.descendant(new) |
|
625 | return old.descendant(new) | |
|
626 | ||||
|
627 | def checkformat(repo, mark): | |||
|
628 | """return a valid version of a potential bookmark name | |||
|
629 | ||||
|
630 | Raises an abort error if the bookmark name is not valid. | |||
|
631 | """ | |||
|
632 | mark = mark.strip() | |||
|
633 | if not mark: | |||
|
634 | raise error.Abort(_("bookmark names cannot consist entirely of " | |||
|
635 | "whitespace")) | |||
|
636 | scmutil.checknewlabel(repo, mark, 'bookmark') | |||
|
637 | return mark |
@@ -957,14 +957,6 def bookmark(ui, repo, *names, **opts): | |||||
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: | |
@@ -1039,7 +1031,7 def bookmark(ui, repo, *names, **opts): | |||||
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) | |
@@ -1052,7 +1044,7 def bookmark(ui, repo, *names, **opts): | |||||
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: |
General Comments 0
You need to be logged in to leave comments.
Login now