[PATCH 3 of 6 v2] bmstore: add basic clean-state tracking
Augie Fackler
raf at durin42.com
Wed Dec 2 10:58:42 CST 2015
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1447293683 18000
# Wed Nov 11 21:01:23 2015 -0500
# Node ID 6a78f21222c1cee841367433bd354ec0402b6346
# Parent b1772fde2b3225ed90075dfdcb661f8e821fb92a
bmstore: add basic clean-state tracking
I'm about to move active-bookmark management into the bmstore. I'd
like to avoid re-writing the bookmarks data (as distinct from the
active bookmark file) if possible, so let's introduce some
dirty-tracking early.
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -78,6 +78,15 @@ class bmstore(dict):
except IOError as inst:
if inst.errno != errno.ENOENT:
raise
+ self._clean = True
+
+ def __setitem__(self, *args, **kwargs):
+ self._clean = False
+ return dict.__setitem__(self, *args, **kwargs)
+
+ def __delitem__(self, key):
+ self._clean = False
+ return dict.__delitem__(self, key)
def recordchange(self, tr):
"""record that bookmarks have been changed in a transaction
@@ -96,6 +105,8 @@ class bmstore(dict):
We also store a backup of the previous state in undo.bookmarks that
can be copied back on rollback.
'''
+ if self._clean:
+ return
repo = self._repo
if (repo.ui.configbool('devel', 'all-warnings')
or repo.ui.configbool('devel', 'check-locks')):
@@ -131,6 +142,7 @@ class bmstore(dict):
def _write(self, fp):
for name, node in self.iteritems():
fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name)))
+ self._clean = True
def readactive(repo):
"""
More information about the Mercurial-devel
mailing list