Show More
@@ -705,3 +705,24 b' def delete(repo, tr, names):' | |||||
705 | deactivate(repo) |
|
705 | deactivate(repo) | |
706 | del marks[mark] |
|
706 | del marks[mark] | |
707 | marks.recordchange(tr) |
|
707 | marks.recordchange(tr) | |
|
708 | ||||
|
709 | def rename(repo, tr, old, new, force=False, inactive=False): | |||
|
710 | """rename a bookmark from old to new | |||
|
711 | ||||
|
712 | If force is specified, then the new name can overwrite an existing | |||
|
713 | bookmark. | |||
|
714 | ||||
|
715 | If inactive is specified, then do not activate the new bookmark. | |||
|
716 | ||||
|
717 | Raises an abort error if old is not in the bookmark store. | |||
|
718 | """ | |||
|
719 | marks = repo._bookmarks | |||
|
720 | mark = checkformat(repo, new) | |||
|
721 | if old not in marks: | |||
|
722 | raise error.Abort(_("bookmark '%s' does not exist") % old) | |||
|
723 | marks.checkconflict(mark, force) | |||
|
724 | marks[mark] = marks[old] | |||
|
725 | if repo._activebookmark == old and not inactive: | |||
|
726 | activate(repo, mark) | |||
|
727 | del marks[old] | |||
|
728 | marks.recordchange(tr) |
@@ -982,15 +982,7 b' def bookmark(ui, repo, *names, **opts):' | |||||
982 | raise error.Abort(_("new bookmark name required")) |
|
982 | raise error.Abort(_("new bookmark name required")) | |
983 | elif len(names) > 1: |
|
983 | elif len(names) > 1: | |
984 | raise error.Abort(_("only one new bookmark name allowed")) |
|
984 | raise error.Abort(_("only one new bookmark name allowed")) | |
985 |
|
|
985 | bookmarks.rename(repo, tr, rename, names[0], force, inactive) | |
986 | if rename not in marks: |
|
|||
987 | raise error.Abort(_("bookmark '%s' does not exist") |
|
|||
988 | % rename) |
|
|||
989 | marks.checkconflict(mark, force) |
|
|||
990 | marks[mark] = marks[rename] |
|
|||
991 | if repo._activebookmark == rename and not inactive: |
|
|||
992 | bookmarks.activate(repo, mark) |
|
|||
993 | del marks[rename] |
|
|||
994 | elif names: |
|
986 | elif names: | |
995 | tr = repo.transaction('bookmark') |
|
987 | tr = repo.transaction('bookmark') | |
996 | newact = None |
|
988 | newact = None |
General Comments 0
You need to be logged in to leave comments.
Login now