Show More
@@ -19,6 +19,7 from . import ( | |||
|
19 | 19 | error, |
|
20 | 20 | lock as lockmod, |
|
21 | 21 | obsolete, |
|
22 | scmutil, | |
|
22 | 23 | txnutil, |
|
23 | 24 | util, |
|
24 | 25 | ) |
@@ -622,3 +623,15 def validdest(repo, old, new): | |||
|
622 | 623 | else: |
|
623 | 624 | # still an independent clause as it is lazier (and therefore faster) |
|
624 | 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 | 957 | rename = opts.get('rename') |
|
958 | 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 | 960 | def checkconflict(repo, mark, cur, force=False, target=None): |
|
969 | 961 | if mark in marks and not force: |
|
970 | 962 | if target: |
@@ -1039,7 +1031,7 def bookmark(ui, repo, *names, **opts): | |||
|
1039 | 1031 | raise error.Abort(_("new bookmark name required")) |
|
1040 | 1032 | elif len(names) > 1: |
|
1041 | 1033 | raise error.Abort(_("only one new bookmark name allowed")) |
|
1042 | mark = checkformat(names[0]) | |
|
1034 | mark = bookmarks.checkformat(repo, names[0]) | |
|
1043 | 1035 | if rename not in marks: |
|
1044 | 1036 | raise error.Abort(_("bookmark '%s' does not exist") |
|
1045 | 1037 | % rename) |
@@ -1052,7 +1044,7 def bookmark(ui, repo, *names, **opts): | |||
|
1052 | 1044 | tr = repo.transaction('bookmark') |
|
1053 | 1045 | newact = None |
|
1054 | 1046 | for mark in names: |
|
1055 | mark = checkformat(mark) | |
|
1047 | mark = bookmarks.checkformat(repo, mark) | |
|
1056 | 1048 | if newact is None: |
|
1057 | 1049 | newact = mark |
|
1058 | 1050 | if inactive and mark == repo._activebookmark: |
General Comments 0
You need to be logged in to leave comments.
Login now