Show More
@@ -789,6 +789,24 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
789 | 789 | marks = repo._bookmarks |
|
790 | 790 | cur = repo.changectx('.').node() |
|
791 | 791 | |
|
792 | def checkformat(mark): | |
|
793 | if "\n" in mark: | |
|
794 | raise util.Abort(_("bookmark name cannot contain newlines")) | |
|
795 | mark = mark.strip() | |
|
796 | if not mark: | |
|
797 | raise util.Abort(_("bookmark names cannot consist entirely of " | |
|
798 | "whitespace")) | |
|
799 | return mark | |
|
800 | ||
|
801 | def checkconflict(repo, mark, force=False): | |
|
802 | if mark in marks and not force: | |
|
803 | raise util.Abort(_("bookmark '%s' already exists " | |
|
804 | "(use -f to force)") % mark) | |
|
805 | if ((mark in repo.branchmap() or mark == repo.dirstate.branch()) | |
|
806 | and not force): | |
|
807 | raise util.Abort( | |
|
808 | _("a bookmark cannot have the name of an existing branch")) | |
|
809 | ||
|
792 | 810 | if delete: |
|
793 | 811 | if mark is None: |
|
794 | 812 | raise util.Abort(_("bookmark name required")) |
@@ -801,13 +819,12 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
801 | 819 | return |
|
802 | 820 | |
|
803 | 821 | if rename: |
|
822 | if mark is None: | |
|
823 | raise util.Abort(_("new bookmark name required")) | |
|
824 | mark = checkformat(mark) | |
|
804 | 825 | if rename not in marks: |
|
805 | 826 | raise util.Abort(_("bookmark '%s' does not exist") % rename) |
|
806 | if mark in marks and not force: | |
|
807 | raise util.Abort(_("bookmark '%s' already exists " | |
|
808 | "(use -f to force)") % mark) | |
|
809 | if mark is None: | |
|
810 | raise util.Abort(_("new bookmark name required")) | |
|
827 | checkconflict(repo, mark, force) | |
|
811 | 828 | marks[mark] = marks[rename] |
|
812 | 829 | if repo._bookmarkcurrent == rename and not inactive: |
|
813 | 830 | bookmarks.setcurrent(repo, mark) |
@@ -816,22 +833,11 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
816 | 833 | return |
|
817 | 834 | |
|
818 | 835 | if mark is not None: |
|
819 | if "\n" in mark: | |
|
820 | raise util.Abort(_("bookmark name cannot contain newlines")) | |
|
821 | mark = mark.strip() | |
|
822 | if not mark: | |
|
823 | raise util.Abort(_("bookmark names cannot consist entirely of " | |
|
824 | "whitespace")) | |
|
836 | mark = checkformat(mark) | |
|
825 | 837 | if inactive and mark == repo._bookmarkcurrent: |
|
826 | 838 | bookmarks.setcurrent(repo, None) |
|
827 | 839 | return |
|
828 | if mark in marks and not force: | |
|
829 | raise util.Abort(_("bookmark '%s' already exists " | |
|
830 | "(use -f to force)") % mark) | |
|
831 | if ((mark in repo.branchmap() or mark == repo.dirstate.branch()) | |
|
832 | and not force): | |
|
833 | raise util.Abort( | |
|
834 | _("a bookmark cannot have the name of an existing branch")) | |
|
840 | checkconflict(repo, mark, force) | |
|
835 | 841 | if rev: |
|
836 | 842 | marks[mark] = scmutil.revsingle(repo, rev).node() |
|
837 | 843 | else: |
@@ -217,12 +217,31 b' reject bookmark name with newline' | |||
|
217 | 217 | abort: bookmark name cannot contain newlines |
|
218 | 218 | [255] |
|
219 | 219 | |
|
220 | $ hg bookmark -m Z ' | |
|
221 | > ' | |
|
222 | abort: bookmark name cannot contain newlines | |
|
223 | [255] | |
|
224 | ||
|
220 | 225 | bookmark with existing name |
|
221 | 226 | |
|
222 | 227 | $ hg bookmark Z |
|
223 | 228 | abort: bookmark 'Z' already exists (use -f to force) |
|
224 | 229 | [255] |
|
225 | 230 | |
|
231 | $ hg bookmark -m Y Z | |
|
232 | abort: bookmark 'Z' already exists (use -f to force) | |
|
233 | [255] | |
|
234 | ||
|
235 | bookmark with name of branch | |
|
236 | ||
|
237 | $ hg bookmark default | |
|
238 | abort: a bookmark cannot have the name of an existing branch | |
|
239 | [255] | |
|
240 | ||
|
241 | $ hg bookmark -m Y default | |
|
242 | abort: a bookmark cannot have the name of an existing branch | |
|
243 | [255] | |
|
244 | ||
|
226 | 245 | force bookmark with existing name |
|
227 | 246 | |
|
228 | 247 | $ hg bookmark -f Z |
@@ -247,6 +266,10 b' bookmark name with whitespace only' | |||
|
247 | 266 | abort: bookmark names cannot consist entirely of whitespace |
|
248 | 267 | [255] |
|
249 | 268 | |
|
269 | $ hg bookmark -m Y ' ' | |
|
270 | abort: bookmark names cannot consist entirely of whitespace | |
|
271 | [255] | |
|
272 | ||
|
250 | 273 | invalid bookmark |
|
251 | 274 | |
|
252 | 275 | $ hg bookmark 'foo:bar' |
General Comments 0
You need to be logged in to leave comments.
Login now