Changeset - eda137096b3f
[Not reviewed]
default
0 2 0
Mads Kiilerich - 6 years ago 2019-05-27 00:17:32
mads@kiilerich.com
Grafted from: 63774e9057c0
hg: prepare for Mercurial 5.0 renaming memfilectx `copied` to `copysource` - add backwards compat wrapper
2 files changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/inmemory.py
Show inline comments
 
@@ -48,35 +48,35 @@ class MercurialInMemoryChangeset(BaseInM
 
            # check if this path is removed
 
            if path in (node.path for node in self.removed):
 
                return None
 

	
 
            # check if this path is added
 
            for node in self.added:
 
                if node.path == path:
 
                    return memfilectx(_repo, memctx, path=node.path,
 
                        data=(node.content.encode('utf-8')
 
                              if not node.is_binary else node.content),
 
                        islink=False,
 
                        isexec=node.is_executable,
 
                        copied=False)
 
                        copysource=False)
 

	
 
            # or changed
 
            for node in self.changed:
 
                if node.path == path:
 
                    return memfilectx(_repo, memctx, path=node.path,
 
                        data=(node.content.encode('utf-8')
 
                              if not node.is_binary else node.content),
 
                        islink=False,
 
                        isexec=node.is_executable,
 
                        copied=False)
 
                        copysource=False)
 

	
 
            raise RepositoryError("Given path haven't been marked as added,"
 
                                  "changed or removed (%s)" % path)
 

	
 
        parents = [None, None]
 
        for i, parent in enumerate(self.parents):
 
            if parent is not None:
 
                parents[i] = parent._ctx.node()
 

	
 
        if date and isinstance(date, datetime.datetime):
 
            date = date.strftime('%a, %d %b %Y %H:%M:%S')
 

	
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -28,12 +28,20 @@ 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
 

	
 

	
 
# 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 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
 
import inspect
 
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)
0 comments (0 inline, 0 general)