Changeset - 1e8b300b0540
[Not reviewed]
default
0 7 0
Mads Kiilerich - 6 years ago 2019-12-25 15:39:33
mads@kiilerich.com
Grafted from: 812dba3a7a54
hg: bump minimum version to 5.1

We will soon move to Python 3 which only will support 5.1 or later.

Remove old hacks and tech debt.

Also avoids future warning:
DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
7 files changed with 11 insertions and 66 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -88,30 +88,25 @@ class CompareController(BaseRepoControll
 
        :param other_repo: repo object, most likely the fork of org_repo. It has
 
            all changesets that we need to obtain
 
        :param other_rev: revision we want out compare to be made on other_repo
 
        """
 
        ancestors = None
 
        if org_rev == other_rev:
 
            org_changesets = []
 
            other_changesets = []
 

	
 
        elif alias == 'hg':
 
            # case two independent repos
 
            if org_repo != other_repo:
 
                try:
 
                    hgrepo = unionrepo.makeunionrepository(other_repo.baseui,
 
                                                           other_repo.path,
 
                                                           org_repo.path)
 
                except AttributeError: # makeunionrepository was introduced in Mercurial 4.8 23f2299e9e53
 
                    hgrepo = unionrepo.unionrepository(other_repo.baseui,
 
                hgrepo = unionrepo.makeunionrepository(other_repo.baseui,
 
                                                       other_repo.path,
 
                                                       org_repo.path)
 
                # all ancestors of other_rev will be in other_repo and
 
                # rev numbers from hgrepo can be used in other_repo - org_rev ancestors cannot
 

	
 
            # no remote compare do it on the same repository
 
            else:
 
                hgrepo = other_repo._repo
 

	
 
            ancestors = [hgrepo[ancestor].hex() for ancestor in
 
                         hgrepo.revs("id(%s) & ::id(%s)", other_rev, org_rev)]
 
            if ancestors:
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -526,30 +526,25 @@ class PullrequestsController(BaseRepoCon
 
                elif c.pull_request.is_closed():
 
                    c.update_msg = _('This pull request has been closed and can not be updated.')
 
                else: # look for descendants of PR head on source branch in org repo
 
                    avail_revs = org_scm_instance._repo.revs('%s:: & branch(%s)',
 
                                                             revs[0], c.cs_branch_name)
 
                    if len(avail_revs) > 1: # more than just revs[0]
 
                        # also show changesets that not are descendants but would be merged in
 
                        targethead = other_scm_instance.get_changeset(c.a_branch_name).raw_id
 
                        if org_scm_instance.path != other_scm_instance.path:
 
                            # Note: org_scm_instance.path must come first so all
 
                            # valid revision numbers are 100% org_scm compatible
 
                            # - both for avail_revs and for revset results
 
                            try:
 
                                hgrepo = unionrepo.makeunionrepository(org_scm_instance.baseui,
 
                                                                       org_scm_instance.path,
 
                                                                       other_scm_instance.path)
 
                            except AttributeError: # makeunionrepository was introduced in Mercurial 4.8 23f2299e9e53
 
                                hgrepo = unionrepo.unionrepository(org_scm_instance.baseui,
 
                            hgrepo = unionrepo.makeunionrepository(org_scm_instance.baseui,
 
                                                                   org_scm_instance.path,
 
                                                                   other_scm_instance.path)
 
                        else:
 
                            hgrepo = org_scm_instance._repo
 
                        show = set(hgrepo.revs('::%ld & !::parents(%s) & !::%s',
 
                                               avail_revs, revs[0], targethead))
 
                        if show:
 
                            c.update_msg = _('The following additional changes are available on %s:') % c.cs_branch_name
 
                        else:
 
                            c.update_msg = _('No additional changesets found for iterating on this pull request.')
 
                    else:
 
                        show = set()
kallithea/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -38,46 +38,37 @@ class MercurialChangeset(BaseChangeset):
 
        return [safe_unicode(self._ctx.branch())]
 

	
 
    @LazyProperty
 
    def closesbranch(self):
 
        return self._ctx.closesbranch()
 

	
 
    @LazyProperty
 
    def obsolete(self):
 
        return self._ctx.obsolete()
 

	
 
    @LazyProperty
 
    def bumped(self):
 
        try:
 
            return self._ctx.phasedivergent()
 
        except AttributeError: # renamed in Mercurial 4.6 (9fa874fb34e1)
 
            return self._ctx.bumped()
 
        return self._ctx.phasedivergent()
 

	
 
    @LazyProperty
 
    def divergent(self):
 
        try:
 
            return self._ctx.contentdivergent()
 
        except AttributeError: # renamed in Mercurial 4.6 (8b2d7684407b)
 
            return self._ctx.divergent()
 
        return self._ctx.contentdivergent()
 

	
 
    @LazyProperty
 
    def extinct(self):
 
        return self._ctx.extinct()
 

	
 
    @LazyProperty
 
    def unstable(self):
 
        try:
 
            return self._ctx.orphan()
 
        except AttributeError: # renamed in Mercurial 4.6 (03039ff3082b)
 
            return self._ctx.unstable()
 
        return self._ctx.orphan()
 

	
 
    @LazyProperty
 
    def phase(self):
 
        if(self._ctx.phase() == 1):
 
            return 'Draft'
 
        elif(self._ctx.phase() == 2):
 
            return 'Secret'
 
        else:
 
            return ''
 

	
 
    @LazyProperty
 
    def successors(self):
 
@@ -283,28 +274,25 @@ class MercurialChangeset(BaseChangeset):
 
            hist.append(hex(fctx.filectx(cs).node()))
 
            if limit is not None and cnt == limit:
 
                break
 

	
 
        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)
 
            annotation_lines = [(aline.fctx, l) for aline, l in annotations]
 
        annotation_lines = [(annotateline.fctx, annotateline.text) for annotateline 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/backends/hg/repository.py
Show inline comments
 
@@ -413,28 +413,25 @@ class MercurialRepository(BaseRepository
 
        if isinstance(revision, unicode):
 
            revision = safe_str(revision)
 

	
 
        if self._empty:
 
            raise EmptyRepositoryError("There are no changesets yet")
 

	
 
        if revision in [-1, None]:
 
            revision = 'tip'
 

	
 
        try:
 
            if isinstance(revision, int):
 
                return self._repo[revision].hex()
 
            try:
 
                return scmutil.revsymbol(self._repo, revision).hex()
 
            except AttributeError: # revsymbol was introduced in Mercurial 4.6
 
                return self._repo[revision].hex()
 
            return scmutil.revsymbol(self._repo, revision).hex()
 
        except (IndexError, ValueError, RepoLookupError, TypeError):
 
            msg = ("Revision %s does not exist for %s" % (revision, self))
 
            raise ChangesetDoesNotExistError(msg)
 
        except (LookupError, ):
 
            msg = ("Ambiguous identifier `%s` for %s" % (revision, self))
 
            raise ChangesetDoesNotExistError(msg)
 

	
 
    def get_ref_revision(self, ref_type, ref_name):
 
        """
 
        Returns revision number for the given reference.
 
        """
 
        ref_name = safe_str(ref_name)
 
@@ -449,29 +446,25 @@ class MercurialRepository(BaseRepository
 
            }
 
        # avoid expensive branch(x) iteration over whole repo
 
        rev_spec = "%%s & %s(%%s)" % _revset_predicates[ref_type]
 
        try:
 
            revs = self._repo.revs(rev_spec, ref_name, ref_name)
 
        except LookupError:
 
            msg = ("Ambiguous identifier %s:%s for %s" % (ref_type, ref_name, self.name))
 
            raise ChangesetDoesNotExistError(msg)
 
        except RepoLookupError:
 
            msg = ("Revision %s:%s does not exist for %s" % (ref_type, ref_name, self.name))
 
            raise ChangesetDoesNotExistError(msg)
 
        if revs:
 
            try:
 
                revision = revs.last()
 
            except AttributeError:
 
                # removed in hg 3.2
 
                revision = revs[-1]
 
            revision = revs.last()
 
        else:
 
            # TODO: just report 'not found'?
 
            revision = ref_name
 

	
 
        return self._get_revision(revision)
 

	
 
    def _get_archives(self, archive_name='tip'):
 
        allowed = self.baseui.configlist("web", "allow_archive",
 
                                         untrusted=True)
 
        for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
 
            if i[0] in allowed or self._repo.ui.configbool("web",
 
                                                           "allow" + i[0],
 
@@ -556,29 +549,26 @@ class MercurialRepository(BaseRepository
 
        if reverse:
 
            revs.reverse()
 

	
 
        return CollectionGenerator(self, revs)
 

	
 
    def pull(self, url):
 
        """
 
        Tries to pull changes from external location.
 
        """
 
        url = self._get_url(url)
 
        other = peer(self._repo, {}, url)
 
        try:
 
            # hg 3.2 moved push / pull to exchange module
 
            from mercurial import exchange
 
            exchange.pull(self._repo, other, heads=None, force=None)
 
        except ImportError:
 
            self._repo.pull(other, heads=None, force=None)
 
        except Abort as err:
 
            # Propagate error but with vcs's type
 
            raise RepositoryError(str(err))
 

	
 
    @LazyProperty
 
    def workdir(self):
 
        """
 
        Returns ``Workdir`` instance for this repository.
 
        """
 
        return MercurialWorkdir(self)
 

	
 
    def get_config_value(self, section, name=None, config_file=None):
kallithea/lib/vcs/backends/hg/ssh.py
Show inline comments
 
@@ -6,37 +6,31 @@
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import logging
 

	
 
from mercurial import hg
 
from mercurial.wireprotoserver import sshserver
 

	
 
from kallithea.lib.utils import make_ui
 
from kallithea.lib.utils2 import safe_str, safe_unicode
 
from kallithea.lib.vcs.backends.ssh import BaseSshHandler
 

	
 

	
 
try:
 
    from mercurial.wireprotoserver import sshserver
 
except ImportError:
 
    from mercurial.sshserver import sshserver # moved in Mercurial 4.6 (1bf5263fe5cc)
 

	
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class MercurialSshHandler(BaseSshHandler):
 
    vcs_type = 'hg'
 

	
 
    @classmethod
 
    def make(cls, ssh_command_parts):
 
        r"""
 
        >>> import shlex
 

	
 
        >>> MercurialSshHandler.make(shlex.split('hg -R "foo bar" serve --stdio')).repo_name
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
"""
 
Mercurial libs compatibility
 
"""
 

	
 
# Mercurial 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
 
import inspect
 

	
 
import mercurial
 
from mercurial import archival, config, demandimport, discovery, httppeer, localrepo
 
from mercurial import merge as hg_merge
 
from mercurial import obsutil, patch, scmutil, sshpeer, ui, unionrepo
 
from mercurial.commands import clone, nullid, pull
 
from mercurial.context import memctx, memfilectx
 
from mercurial.discovery import findcommonoutgoing
 
from mercurial.encoding import tolocal
 
from mercurial.error import Abort, RepoError, RepoLookupError
 
from mercurial.hg import peer
 
from mercurial.hgweb import hgweb_mod
 
from mercurial.hgweb.common import get_contact
 
from mercurial.match import exact as match_exact
 
from mercurial.match import match
 
from mercurial.mdiff import diffopts
 
from mercurial.node import hex, nullrev
 
from mercurial.scmutil import revrange
 
from mercurial.tags import tag
 
from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
 
from mercurial.util import url as hg_url
 

	
 

	
 
# patch demandimport, due to bug in mercurial when it always triggers demandimport.enable()
 
demandimport.enable = lambda *args, **kwargs: 1
 

	
 

	
 
# workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
 
# workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly, and test_archival failing
 
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
 

	
 
if inspect.getargspec(memfilectx.__init__).args[7] != 'copysource':
 
    assert inspect.getargspec(memfilectx.__init__).args[7] == 'copied', inspect.getargspec(memfilectx.__init__).args
 
    __org_memfilectx_ = memfilectx
 
    memfilectx = lambda repo, changectx, path, data, islink=False, isexec=False, copysource=None: \
 
        __org_memfilectx_(repo, changectx, path, data, islink=islink, isexec=isexec, copied=copysource)
 

	
 
# Mercurial 5.0 dropped exact argument for match in 635a12c53ea6, and 0531dff73d0b made the exact function stable with a single parameter
 
if inspect.getargspec(match_exact).args[0] != 'files':
 
    match_exact = lambda path: match(None, '', [path], exact=True)
setup.py
Show inline comments
 
@@ -53,25 +53,25 @@ requirements = [
 
    "SQLAlchemy >= 1.1, < 1.4",
 
    "Mako >= 0.9.0, < 1.1",
 
    "Pygments >= 2.2.0, < 2.5",
 
    "Whoosh >= 2.5.0, < 2.8",
 
    "celery >= 3.1, < 4.0", # TODO: celery 4 doesn't work
 
    "Babel >= 1.3, < 2.8",
 
    "python-dateutil >= 1.5.0, < 2.9",
 
    "Markdown >= 2.2.1, < 3.2",
 
    "docutils >= 0.11, < 0.15",
 
    "URLObject >= 2.3.4, < 2.5",
 
    "Routes >= 2.0, < 2.5",
 
    "dulwich >= 0.14.1, < 0.20",
 
    "mercurial >= 4.5, < 5.3",
 
    "mercurial >= 5.1, < 5.3",
 
    "decorator >= 3.3.2, < 4.5",
 
    "Paste >= 2.0.3, < 3.1",
 
    "bleach >= 3.0, < 3.2",
 
    "Click >= 7.0, < 8",
 
    "ipaddr >= 2.1.10, < 2.3",
 
    "paginate >= 0.5, < 0.6",
 
    "paginate_sqlalchemy >= 0.3.0, < 0.4",
 
]
 

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

	
0 comments (0 inline, 0 general)