Changeset - 0572d5d132c2
[Not reviewed]
default
0 3 0
Mads Kiilerich - 6 years ago 2019-05-26 23:20:58
mads@kiilerich.com
setup: bump Mercurial minimum version to 4.5 - that allow us to drop some hacks, and it was released more than one year ago
3 files changed with 7 insertions and 43 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -11,13 +11,13 @@ from kallithea.lib.vcs.nodes import (
 
    AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode,
 
    NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode
 
)
 
from kallithea.lib.vcs.utils import safe_str, safe_unicode, date_fromtimestamp
 
from kallithea.lib.vcs.utils.lazy import LazyProperty
 
from kallithea.lib.vcs.utils.paths import get_dirs_for_path
 
from kallithea.lib.vcs.utils.hgcompat import archival, hex
 
from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
 

	
 
from mercurial import obsolete
 

	
 

	
 
class MercurialChangeset(BaseChangeset):
 
    """
 
@@ -85,41 +85,23 @@ class MercurialChangeset(BaseChangeset):
 
            return 'Secret'
 
        else:
 
            return ''
 

	
 
    @LazyProperty
 
    def successors(self):
 
        try:
 
            # This works starting from Mercurial 4.3: the function `successorssets` was moved to the mercurial.obsutil module and gained the `closest` parameter.
 
            from mercurial import obsutil
 
            successors = obsutil.successorssets(self._ctx._repo, self._ctx.node(), closest=True)
 
        except ImportError:
 
            # fallback for older versions
 
            successors = obsolete.successorssets(self._ctx._repo, self._ctx.node())
 
        successors = obsutil.successorssets(self._ctx._repo, self._ctx.node(), closest=True)
 
        if successors:
 
            # flatten the list here handles both divergent (len > 1)
 
            # and the usual case (len = 1)
 
            successors = [hex(n)[:12] for sub in successors for n in sub if n != self._ctx.node()]
 

	
 
        return successors
 

	
 
    @LazyProperty
 
    def predecessors(self):
 
        try:
 
            # This works starting from Mercurial 4.3: the function `closestpredecessors` was added.
 
            from mercurial import obsutil
 
            return [hex(n)[:12] for n in obsutil.closestpredecessors(self._ctx._repo, self._ctx.node())]
 
        except ImportError:
 
            # fallback for older versions
 
            predecessors = set()
 
            nm = self._ctx._repo.changelog.nodemap
 
            for p in self._ctx._repo.obsstore.precursors.get(self._ctx.node(), ()):
 
                pr = nm.get(p[0])
 
                if pr is not None:
 
                    predecessors.add(hex(p[0])[:12])
 
            return predecessors
 
        return [hex(n)[:12] for n in obsutil.closestpredecessors(self._ctx._repo, self._ctx.node())]
 

	
 
    @LazyProperty
 
    def bookmarks(self):
 
        return map(safe_unicode, self._ctx.bookmarks())
 

	
 
    @LazyProperty
 
@@ -317,16 +299,13 @@ class MercurialChangeset(BaseChangeset):
 
            lineno, sha, changeset lazy loader and line
 
        """
 
        annotations = self._get_filectx(path).annotate()
 
        try:
 
            annotation_lines = [(annotateline.fctx, annotateline.text) for annotateline in annotations]
 
        except AttributeError: # annotateline was introduced in Mercurial 4.6 (b33b91ca2ec2)
 
            try:
 
                annotation_lines = [(aline.fctx, l) for aline, l in annotations]
 
            except AttributeError: # aline.fctx was introduced in Mercurial 4.4
 
                annotation_lines = [(aline[0], l) for aline, l in annotations]
 
            annotation_lines = [(aline.fctx, l) for aline, l in annotations]
 
        for i, (fctx, l) in enumerate(annotation_lines):
 
            sha = fctx.hex()
 
            yield (i + 1, sha, lambda sha=sha, l=l: self.repository.get_changeset(sha), l)
 

	
 
    def fill_archive(self, stream=None, kind='tgz', prefix=None,
 
                     subrepos=False):
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -9,15 +9,16 @@ demandimport.enable = lambda *args, **kw
 
from mercurial import archival, merge as hg_merge, patch, ui
 
from mercurial import discovery
 
from mercurial import localrepo
 
from mercurial import unionrepo
 
from mercurial import scmutil
 
from mercurial import config
 
from mercurial import tags as tagsmod
 
from mercurial.tags import tag
 
from mercurial import httppeer
 
from mercurial import sshpeer
 
from mercurial import obsutil
 
from mercurial.commands import clone, nullid, pull
 
from mercurial.context import memctx, memfilectx
 
from mercurial.error import RepoError, RepoLookupError, Abort
 
from mercurial.hgweb import hgweb_mod
 
from mercurial.hgweb.common import get_contact
 
from mercurial.match import match
 
@@ -29,26 +30,10 @@ from mercurial.hg import peer
 
from mercurial.util import url as hg_url
 
from mercurial.scmutil import revrange
 
from mercurial.node import nullrev
 
from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
 

	
 

	
 
# Mercurial 4.5 8a0cac20a1ad introduced an extra memctx changectx argument
 
# - introduce an optional wrapper factory that doesn't pass it on
 
import inspect
 
if inspect.getargspec(memfilectx.__init__).args[2] != 'changectx':
 
    __org_memfilectx = memfilectx
 
    memfilectx = lambda repo, changectx, *args, **kwargs: __org_memfilectx(repo, *args, **kwargs)
 

	
 

	
 
# workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
 
localrepo.localrepository._lfstatuswriters = [lambda *msg, **opts: None]
 
# 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
 
localrepo.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)
setup.py
Show inline comments
 
@@ -54,13 +54,13 @@ requirements = [
 
    "python-dateutil >= 1.5.0, < 2.8",
 
    "Markdown >= 2.2.1, < 2.7",
 
    "docutils >= 0.11, < 0.15",
 
    "URLObject >= 2.3.4, < 2.5",
 
    "Routes >= 1.13, < 2",
 
    "dulwich >= 0.14.1, < 0.20",
 
    "mercurial >= 4.1.1, < 4.10",
 
    "mercurial >= 4.5, < 4.10",
 
    "decorator >= 3.3.2, < 4.4",
 
    "Paste >= 2.0.3, < 3.1",
 
    "bleach >= 3.0, < 3.1",
 
    "Click >= 7.0, < 8",
 
]
 

	
0 comments (0 inline, 0 general)