mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2025-10-26 14:16:07 +01:00
Adjust to modified internals of Mercurial 4.5
Fixes mnauw/git-remote-hg#12
This commit is contained in:
@@ -203,18 +203,16 @@ class GitHgRepo:
|
||||
context.memctx.__init__(self, repo, (p1, p2),
|
||||
data, files.keys(), self.getfilectx)
|
||||
self.files = files
|
||||
self.remotehg = import_sibling('remotehg', 'git-remote-hg')
|
||||
self.remotehg.hg_version = hg_version
|
||||
|
||||
def __contains__(self, item):
|
||||
return item in self.files
|
||||
|
||||
def getfilectx(self, repo, memctx, path):
|
||||
is_exec = is_link = rename = False
|
||||
if check_version(3, 1):
|
||||
return context.memfilectx(repo, path, self.files[path],
|
||||
is_link, is_exec, rename)
|
||||
else:
|
||||
return context.memfilectx(path, self.files[path],
|
||||
is_link, is_exec, rename)
|
||||
return self.remotehg.make_memfilectx(repo, memctx, path, self.files[path],
|
||||
is_link, is_exec, rename)
|
||||
|
||||
def read(self, relpath, rev=None):
|
||||
rev = rev if rev else ':0'
|
||||
|
||||
@@ -830,6 +830,15 @@ def c_style_unescape(string):
|
||||
return string.decode('string-escape')[1:-1]
|
||||
return string
|
||||
|
||||
# sigh; handle context creation for various (incompatible) versions
|
||||
def make_memfilectx(repo, memctx, path, data, is_link, is_exec, *args):
|
||||
if check_version(4, 5):
|
||||
return context.memfilectx(repo, memctx, path, data, is_link, is_exec, *args)
|
||||
if check_version(3, 1):
|
||||
return context.memfilectx(repo, path, data, is_link, is_exec, *args)
|
||||
else:
|
||||
return context.memfilectx(path, data, is_link, is_exec, *args)
|
||||
|
||||
def parse_commit(parser):
|
||||
from_mark = merge_mark = None
|
||||
|
||||
@@ -945,23 +954,13 @@ def parse_commit(parser):
|
||||
ctx = of['ctx']
|
||||
is_exec = ctx.isexec()
|
||||
is_link = ctx.islink()
|
||||
if check_version(3, 1):
|
||||
return context.memfilectx(repo, f, ctx.data(),
|
||||
is_link, is_exec)
|
||||
else:
|
||||
return context.memfilectx(f, ctx.data(),
|
||||
is_link, is_exec)
|
||||
return make_memfilectx(repo, memctx, f, ctx.data(), is_link, is_exec)
|
||||
else:
|
||||
return of['ctx']
|
||||
is_exec = of['mode'] == 'x'
|
||||
is_link = of['mode'] == 'l'
|
||||
rename = of.get('rename', None)
|
||||
if check_version(3, 1):
|
||||
return context.memfilectx(repo, f, of['data'],
|
||||
is_link, is_exec, rename)
|
||||
else:
|
||||
return context.memfilectx(f, of['data'],
|
||||
is_link, is_exec, rename)
|
||||
return make_memfilectx(repo, memctx, f, of['data'], is_link, is_exec, rename)
|
||||
|
||||
repo = parser.repo
|
||||
|
||||
@@ -1071,10 +1070,7 @@ def write_tag(repo, tag, node, msg, author):
|
||||
except error.ManifestLookupError:
|
||||
data = ""
|
||||
content = data + "%s %s\n" % (node, tag)
|
||||
if check_version(3, 1):
|
||||
return context.memfilectx(repo, f, content, False, False, None)
|
||||
else:
|
||||
return context.memfilectx(f, content, False, False, None)
|
||||
return make_memfilectx(repo, memctx, f, content, False, False, None)
|
||||
|
||||
p1 = tip.hex()
|
||||
p2 = '0' * 40
|
||||
|
||||
Reference in New Issue
Block a user