Mercurial > hgsubversion
changeset 1549:8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
See hg change 8a0cac20a1ad. Since the interface has changed
more than one time, switch to explicit keywords arguments to avoid
surprises.
Since hgsubversion targets hg >= 3.2.4, drop support for hg 3.0 and 3.1
here.
author | Jun Wu <quark@fb.com> |
---|---|
date | Tue, 19 Dec 2017 14:29:55 -0800 |
parents | 7f83be82d03f |
children | 67b28d657f62 |
files | hgsubversion/compathacks.py hgsubversion/replay.py hgsubversion/stupid.py hgsubversion/svnmeta.py tests/test_push_command.py tests/test_single_dir_push.py tests/test_util.py tests/test_utility_commands.py |
diffstat | 8 files changed, 39 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/compathacks.py +++ b/hgsubversion/compathacks.py @@ -20,16 +20,19 @@ def pickle_load(f): f.seek(0) return pickle.load(f) -def makememfilectx(repo, path, data, islink, isexec, copied): +def makememfilectx(repo, memctx, path, data, islink, isexec, copied): """Return a memfilectx - Works around memfilectx() adding a repo argument between 3.0 and 3.1. + Works around API change by 8a0cac20a1ad (first in 4.5). """ from mercurial import context try: - return context.memfilectx(repo, path, data, islink, isexec, copied) + return context.memfilectx(repo=repo, path=path, data=data, + islink=islink, isexec=isexec, copied=copied, + changectx=memctx) except TypeError: - return context.memfilectx(path, data, islink, isexec, copied) + return context.memfilectx(repo=repo, path=path, data=data, + islink=islink, isexec=isexec, copied=copied) def filectxfn_deleted(memctx, path): """
--- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -174,6 +174,7 @@ def _convert_rev(ui, meta, svn, r, tbdel else: data = parentctx.filectx(path).data() return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=data, islink=islink,
--- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -347,6 +347,7 @@ def diff_branchrev(ui, svn, meta, branch if copied not in parentctx.manifest(): copied = None return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=data, islink=islink, @@ -559,6 +560,7 @@ def fetch_branchrev(svn, meta, branch, b if copied not in parentctx.manifest(): copied = None return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=data, islink=islink, @@ -736,6 +738,7 @@ def convert_rev(ui, meta, svn, r, tbdelt if externals[path] is None: raise IOError(errno.ENOENT, 'no externals') return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=externals[path], islink=False,
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -800,6 +800,7 @@ class SVNMeta(object): def hgtagsfn(repo, memctx, path): assert path == '.hgtags' return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=tagdata, islink=False, @@ -871,6 +872,7 @@ class SVNMeta(object): # add new changeset containing updated .hgtags def fctxfun(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path='.hgtags', data=src, islink=False,
--- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -35,6 +35,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -61,6 +62,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -109,6 +111,7 @@ class PushTests(test_util.TestBase): repo = self.repo def file_callback(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -194,6 +197,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -242,6 +246,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -271,6 +276,7 @@ class PushTests(test_util.TestBase): def test_push_two_revs_different_local_branch(self): def filectxfn(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=path, islink=False, @@ -313,6 +319,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'adding_file2': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo2', islink=False, @@ -349,6 +356,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -431,6 +439,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'gamma': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -463,6 +472,7 @@ class PushTests(test_util.TestBase): def file_callback(repo, memctx, path): if path == 'gamma': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=True, @@ -493,6 +503,7 @@ class PushTests(test_util.TestBase): def file_callback2(repo, memctx, path): if path == 'gamma': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='a' * 129, islink=True, @@ -520,6 +531,7 @@ class PushTests(test_util.TestBase): def file_callback3(repo, memctx, path): if path == 'gamma': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='a' * 64 + 'b' * 65, islink=True, @@ -555,6 +567,7 @@ class PushTests(test_util.TestBase): repo = self.repo def file_callback(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=link, @@ -581,6 +594,7 @@ class PushTests(test_util.TestBase): repo = self.repo def file_callback2(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='bar', islink=link, @@ -606,6 +620,7 @@ class PushTests(test_util.TestBase): repo = self.repo def file_callback3(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='bar', islink=False, @@ -755,6 +770,7 @@ class PushTests(test_util.TestBase): if path == 'newdir/new_file': testData = 'fooNewFile' return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=testData, islink=False,
--- a/tests/test_single_dir_push.py +++ b/tests/test_single_dir_push.py @@ -24,6 +24,7 @@ class TestSingleDirPush(test_util.TestBa def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False, @@ -31,6 +32,7 @@ class TestSingleDirPush(test_util.TestBa copied=False) elif path == 'adding_binary': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='\0binary', islink=False, @@ -65,6 +67,7 @@ class TestSingleDirPush(test_util.TestBa subdir='trunk') def filectxfn(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='contents of %s' % path, islink=False, @@ -99,6 +102,7 @@ class TestSingleDirPush(test_util.TestBa self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'}) def file_callback(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='data of %s' % path, islink=False, @@ -131,6 +135,7 @@ class TestSingleDirPush(test_util.TestBa def cb(repo, memctx, path): if path == data: return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data=data, islink=False, @@ -180,6 +185,7 @@ class TestSingleDirPush(test_util.TestBa def file_callback(repo, memctx, path): if path == 'adding_file': return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='foo', islink=False,
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -712,6 +712,7 @@ class TestBase(unittest.TestCase): if source != dest: copied = source return compathacks.makememfilectx(repo, + memctx=memctx, path=dest, data=newdata, islink=False,
--- a/tests/test_utility_commands.py +++ b/tests/test_utility_commands.py @@ -162,6 +162,7 @@ class UtilityTests(test_util.TestBase): parents = (self.repo['the_branch'].node(), revlog.nullid,) def filectxfn(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='added', islink=False, @@ -207,6 +208,7 @@ class UtilityTests(test_util.TestBase): parents = (self.repo['the_branch'].node(), revlog.nullid,) def filectxfn(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='added', islink=False, @@ -239,6 +241,7 @@ class UtilityTests(test_util.TestBase): parents = (self.repo[0].node(), revlog.nullid,) def filectxfn(repo, memctx, path): return compathacks.makememfilectx(repo, + memctx=memctx, path=path, data='added', islink=False,