mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2026-05-06 16:26:31 +02:00
Refactor memfilectx() method
It's getting hairy. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
@@ -771,6 +771,12 @@ def c_style_unescape(string):
|
||||
return string.decode('string-escape')[1:-1]
|
||||
return string
|
||||
|
||||
def make_memfilectx(repo, changectx, path, data, islink=False, isexec=False, copied=None):
|
||||
if check_version(3, 1):
|
||||
return context.memfilectx(repo, path, data, islink, isexec, copied)
|
||||
else:
|
||||
return context.memfilectx(path, data, islink, isexec, copied)
|
||||
|
||||
def parse_commit(parser):
|
||||
from_mark = merge_mark = None
|
||||
|
||||
@@ -831,23 +837,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
|
||||
|
||||
@@ -956,10 +952,7 @@ def write_tag(repo, tag, node, msg, author):
|
||||
except error.LookupError:
|
||||
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)
|
||||
|
||||
p1 = tip.hex()
|
||||
p2 = '0' * 40
|
||||
|
||||
Reference in New Issue
Block a user