diff mercurial/commands.py @ 33007:ee081f91b179

bookmarks: factor out adding a list of bookmarks logic from commands We keep the lock in the caller so that future devs are aware of the locking implications.
author Sean Farley <sean@farley.io>
date Tue, 20 Jun 2017 15:18:40 -0700
parents e0a8dd6c87c7
children ac57603a44fe
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Jun 13 11:10:22 2017 -0700
+++ b/mercurial/commands.py	Tue Jun 20 15:18:40 2017 -0700
@@ -971,7 +971,6 @@
         try:
             wlock = repo.wlock()
             lock = repo.lock()
-            cur = repo.changectx('.').node()
             marks = repo._bookmarks
             if delete:
                 tr = repo.transaction('bookmark')
@@ -985,23 +984,7 @@
                 bookmarks.rename(repo, tr, rename, names[0], force, inactive)
             elif names:
                 tr = repo.transaction('bookmark')
-                newact = None
-                for mark in names:
-                    mark = bookmarks.checkformat(repo, mark)
-                    if newact is None:
-                        newact = mark
-                    if inactive and mark == repo._activebookmark:
-                        bookmarks.deactivate(repo)
-                        return
-                    tgt = cur
-                    if rev:
-                        tgt = scmutil.revsingle(repo, rev).node()
-                    marks.checkconflict(mark, force, tgt)
-                    marks[mark] = tgt
-                if not inactive and cur == marks[newact] and not rev:
-                    bookmarks.activate(repo, newact)
-                elif cur != tgt and newact == repo._activebookmark:
-                    bookmarks.deactivate(repo)
+                bookmarks.addbookmarks(repo, tr, names, rev, force, inactive)
             elif inactive:
                 if len(marks) == 0:
                     ui.status(_("no bookmarks set\n"))