Mercurial > hg
changeset 44624:7cab8dbd0497
git: implement basic bookmark activation
This is very limited, but it allows 'hg update foo' when already on foo.
The caching is based on bmstore's caching.
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 26 Mar 2020 17:49:30 -0400 |
parents | bb3e05ca21ca |
children | e9e7156a8d6c |
files | hgext/git/__init__.py |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/git/__init__.py Thu Mar 26 17:24:54 2020 -0400 +++ b/hgext/git/__init__.py Thu Mar 26 17:49:30 2020 -0400 @@ -144,6 +144,8 @@ class gitbmstore(object): def __init__(self, gitrepo): self.gitrepo = gitrepo + self._aclean = True + self._active = gitrepo.references['HEAD'] # git head, not mark def __contains__(self, name): return ( @@ -181,7 +183,18 @@ @active.setter def active(self, mark): - raise NotImplementedError + githead = mark is not None and (_BMS_PREFIX + mark) or None + if githead is not None and githead not in self.gitrepo.references: + raise AssertionError(b'bookmark %s does not exist!' % mark) + + self._active = githead + self._aclean = False + + def _writeactive(self): + if self._aclean: + return + self.gitrepo.references.create('HEAD', self._active, True) + self._aclean = True def names(self, node): r = []