[PATCH 2 of 2 bmstore] bmstore: add handling of the active bookmark
Yuya Nishihara
yuya at tcha.org
Fri Jan 8 20:57:34 CST 2016
On Tue, 05 Jan 2016 11:16:52 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1447294682 18000
> # Wed Nov 11 21:18:02 2015 -0500
> # Node ID 5425674048be7629af2d650bb11628e8cbd30c3c
> # Parent 2347e29b209dfb2b64a9c2f57f8ecacf9bf9af3a
> # EXP-Topic bmstore
> bmstore: add handling of the active bookmark
> @@ -79,6 +78,20 @@ class bmstore(dict):
> if inst.errno != errno.ENOENT:
> raise
> self._clean = True
> + self._active = _readactive(repo, self)
> + self._aclean = True
> +
> + def _getactive(self):
> + return self._active
> +
> + def _setactive(self, mark):
> + if mark is not None and mark not in self:
> + raise AssertionError('bookmark %s does not exist!' % mark)
> +
> + self._active = mark
> + self._aclean = False
> +
> + active = property(_getactive, _setactive)
We can use @active.setter now.
> + def _writeactive(self):
> + if self._aclean:
> + return
> + wlock = self._repo.wlock()
> + try:
> + if self._active is not None:
> + f = self._repo.vfs('bookmarks.current', 'w', atomictemp=True)
> + try:
> + f.write(encoding.fromlocal(self._active))
> + finally:
> + f.close()
> + else:
> + try:
> + self._repo.vfs.unlink('bookmarks.current')
> + except OSError as inst:
> + if inst.errno != errno.ENOENT:
> + raise
> + finally:
> + wlock.release()
Perhaps self._aclean should be asserted here to skip _writeactive() next time.
More information about the Mercurial-devel
mailing list