Mercurial > hg
changeset 27187:d9dcc5c09d77
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.
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 11 Nov 2015 21:01:23 -0500 |
parents | 34d26e22a2b0 |
children | 6a1301e22bd7 |
files | mercurial/bookmarks.py |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Wed Nov 11 20:45:38 2015 -0500 +++ b/mercurial/bookmarks.py Wed Nov 11 21:01:23 2015 -0500 @@ -78,6 +78,15 @@ 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 @@ 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 @@ 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): """