changeset 13352:f9cd37fca5ba

bookmarks: move update into core
author Matt Mackall <mpm@selenic.com>
date Thu, 10 Feb 2011 13:46:27 -0600
parents 6c5368cd2df9
children 689bf32b3bbd
files hgext/bookmarks.py mercurial/bookmarks.py
diffstat 2 files changed, 18 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
+++ b/hgext/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
@@ -164,7 +164,6 @@
         return
 
     class bookmark_repo(repo.__class__):
-
         @util.propertycache
         def _bookmarks(self):
             return bookmarks.read(self)
@@ -187,22 +186,6 @@
                 key = self._bookmarks[key]
             return super(bookmark_repo, self).lookup(key)
 
-        def _bookmarksupdate(self, parents, node):
-            marks = self._bookmarks
-            update = False
-            if ui.configbool('bookmarks', 'track.current'):
-                mark = self._bookmarkcurrent
-                if mark and marks[mark] in parents:
-                    marks[mark] = node
-                    update = True
-            else:
-                for mark, n in marks.items():
-                    if n in parents:
-                        marks[mark] = node
-                        update = True
-            if update:
-                bookmarks.write(self)
-
         def commitctx(self, ctx, error=False):
             """Add a revision to the repository and
             move the bookmark"""
@@ -215,7 +198,7 @@
                 if parents[1] == nullid:
                     parents = (parents[0],)
 
-                self._bookmarksupdate(parents, node)
+                bookmarks.update(self, parents, node)
                 return node
             finally:
                 wlock.release()
@@ -275,7 +258,7 @@
                 return result
             node = self.changelog.tip()
             parents = self.dirstate.parents()
-            self._bookmarksupdate(parents, node)
+            bookmarks.update(self, parents, node)
             return result
 
         def _findtags(self):
--- a/mercurial/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
+++ b/mercurial/bookmarks.py	Thu Feb 10 13:46:27 2011 -0600
@@ -105,3 +105,19 @@
     finally:
         wlock.release()
     repo._bookmarkcurrent = mark
+
+def update(repo, parents, node):
+    marks = repo._bookmarks
+    update = False
+    if repo.ui.configbool('bookmarks', 'track.current'):
+        mark = repo._bookmarkcurrent
+        if mark and marks[mark] in parents:
+            marks[mark] = node
+            update = True
+    else:
+        for mark, n in marks.items():
+            if n in parents:
+                marks[mark] = node
+                update = True
+    if update:
+        write(repo)