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 4 insertions and 40 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -5,25 +5,25 @@ from kallithea.lib.vcs.conf import setti
 
from kallithea.lib.vcs.backends.base import BaseChangeset
 
from kallithea.lib.vcs.exceptions import (
 
    ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError,
 
    NodeDoesNotExistError, VCSError
 
)
 
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):
 
    """
 
    Represents state of the repository at the single revision.
 
    """
 

	
 
    def __init__(self, repository, revision):
 
        self.repository = repository
 
        assert isinstance(revision, basestring), repr(revision)
 
@@ -79,53 +79,35 @@ class MercurialChangeset(BaseChangeset):
 

	
 
    @LazyProperty
 
    def phase(self):
 
        if(self._ctx.phase() == 1):
 
            return 'Draft'
 
        elif(self._ctx.phase() == 2):
 
            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())
 
        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
 

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

	
 
    @LazyProperty
 
    def message(self):
 
        return safe_unicode(self._ctx.description())
 

	
 
    @LazyProperty
 
    def committer(self):
 
        return safe_unicode(self.author)
 
@@ -311,28 +293,25 @@ class MercurialChangeset(BaseChangeset):
 

	
 
        return [self.repository.get_changeset(node) for node in hist]
 

	
 
    def get_file_annotate(self, path):
 
        """
 
        Returns a generator of four element tuples with
 
            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]
 
        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):
 
        """
 
        Fills up given stream.
 

	
 
        :param stream: file like object.
 
        :param kind: one of following: ``zip``, ``tgz`` or ``tbz2``.
 
            Default: ``tgz``.
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -3,52 +3,37 @@ Mercurial libs compatibility
 
"""
 

	
 
import mercurial
 
from mercurial import demandimport
 
# patch demandimport, due to bug in mercurial when it always triggers demandimport.enable()
 
demandimport.enable = lambda *args, **kwargs: 1
 
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
 
from mercurial.mdiff import diffopts
 
from mercurial.node import hex
 
from mercurial.encoding import tolocal
 
from mercurial.discovery import findcommonoutgoing
 
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
 
@@ -48,25 +48,25 @@ requirements = [
 
    "SQLAlchemy >= 1.1, < 1.3",
 
    "Mako >= 0.9.0, < 1.1",
 
    "Pygments >= 2.0, < 2.3",
 
    "Whoosh >= 2.5.0, < 2.8",
 
    "celery >= 3.1, < 4.0", # celery 4 doesn't work
 
    "Babel >= 1.3, < 2.7",
 
    "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",
 
]
 

	
 
if sys.version_info < (2, 7):
 
    requirements.append("importlib == 1.0.1")
 
    requirements.append("argparse")
 

	
 
if not is_windows:
 
    requirements.append("bcrypt >= 3.1.0, < 3.2")
0 comments (0 inline, 0 general)