# HG changeset patch # User Mads Kiilerich # Date 2017-09-14 02:08:06 # Node ID 5f1af779bddf6e800af00161b55923dbdf651933 # Parent 1ba4fee6b27cb44694d001825278e62a513c9670 hg: prepare for Mercurial 4.2 or later where tagging moved from localrepo to the tags module diff --git a/kallithea/lib/vcs/backends/hg/repository.py b/kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py +++ b/kallithea/lib/vcs/backends/hg/repository.py @@ -31,7 +31,7 @@ from kallithea.lib.vcs.utils.paths impor from kallithea.lib.vcs.utils.hgcompat import ( ui, nullid, match, patch, diffopts, clone, get_contact, localrepository, RepoLookupError, Abort, RepoError, hex, scmutil, hg_url, - httpbasicauthhandler, httpdigestauthhandler, peer, httppeer, sshpeer + httpbasicauthhandler, httpdigestauthhandler, peer, httppeer, sshpeer, tag ) from .changeset import MercurialChangeset @@ -175,8 +175,7 @@ class MercurialRepository(BaseRepository date = datetime.datetime.now().strftime('%a, %d %b %Y %H:%M:%S') try: - self._repo.tag(name, changeset._ctx.node(), message, local, user, - date) + tag(self._repo, name, changeset._ctx.node(), message, local, user, date) except Abort as e: raise RepositoryError(e.message) @@ -206,7 +205,7 @@ class MercurialRepository(BaseRepository local = False try: - self._repo.tag(name, nullid, message, local, user, date) + tag(self._repo, name, nullid, message, local, user, date) self.tags = self._get_tags() except Abort as e: raise RepositoryError(e.message) diff --git a/kallithea/lib/vcs/utils/hgcompat.py b/kallithea/lib/vcs/utils/hgcompat.py --- a/kallithea/lib/vcs/utils/hgcompat.py +++ b/kallithea/lib/vcs/utils/hgcompat.py @@ -12,6 +12,7 @@ from mercurial import localrepo from mercurial import unionrepo from mercurial import scmutil from mercurial import config +from mercurial import tags as tagsmod from mercurial.commands import clone, nullid, pull from mercurial.context import memctx, memfilectx from mercurial.error import RepoError, RepoLookupError, Abort @@ -47,3 +48,11 @@ if inspect.getargspec(memfilectx.__init_ localrepository._lfstatuswriters = [lambda *msg, **opts: None] # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive localrepository.lfstatus = False + +# Mercurial 4.2 moved tag from localrepo to the tags module +def tag(repo, *args): + try: + tag_f = tagsmod.tag + except AttributeError: + return repo.tag(*args) + tag_f(repo, *args)