mirror of
				https://github.com/mnauw/git-remote-hg.git
				synced 2025-10-31 08:35:48 +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), |             context.memctx.__init__(self, repo, (p1, p2), | ||||||
|                 data, files.keys(), self.getfilectx) |                 data, files.keys(), self.getfilectx) | ||||||
|             self.files = files |             self.files = files | ||||||
|  |             self.remotehg = import_sibling('remotehg', 'git-remote-hg') | ||||||
|  |             self.remotehg.hg_version = hg_version | ||||||
|  |  | ||||||
|         def __contains__(self, item): |         def __contains__(self, item): | ||||||
|             return item in self.files |             return item in self.files | ||||||
|  |  | ||||||
|         def getfilectx(self, repo, memctx, path): |         def getfilectx(self, repo, memctx, path): | ||||||
|             is_exec = is_link = rename = False |             is_exec = is_link = rename = False | ||||||
|             if check_version(3, 1): |             return self.remotehg.make_memfilectx(repo, memctx, path, self.files[path], | ||||||
|                 return context.memfilectx(repo, path, self.files[path], |                 is_link, is_exec, rename) | ||||||
|                         is_link, is_exec, rename) |  | ||||||
|             else: |  | ||||||
|                 return context.memfilectx(path, self.files[path], |  | ||||||
|                         is_link, is_exec, rename) |  | ||||||
|  |  | ||||||
|     def read(self, relpath, rev=None): |     def read(self, relpath, rev=None): | ||||||
|         rev = rev if rev else ':0' |         rev = rev if rev else ':0' | ||||||
|   | |||||||
| @@ -830,6 +830,15 @@ def c_style_unescape(string): | |||||||
|         return string.decode('string-escape')[1:-1] |         return string.decode('string-escape')[1:-1] | ||||||
|     return string |     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): | def parse_commit(parser): | ||||||
|     from_mark = merge_mark = None |     from_mark = merge_mark = None | ||||||
|  |  | ||||||
| @@ -945,23 +954,13 @@ def parse_commit(parser): | |||||||
|                 ctx = of['ctx'] |                 ctx = of['ctx'] | ||||||
|                 is_exec = ctx.isexec() |                 is_exec = ctx.isexec() | ||||||
|                 is_link = ctx.islink() |                 is_link = ctx.islink() | ||||||
|                 if check_version(3, 1): |                 return make_memfilectx(repo, memctx, f, ctx.data(), is_link, is_exec) | ||||||
|                     return context.memfilectx(repo, f, ctx.data(), |  | ||||||
|                             is_link, is_exec) |  | ||||||
|                 else: |  | ||||||
|                     return context.memfilectx(f, ctx.data(), |  | ||||||
|                             is_link, is_exec) |  | ||||||
|             else: |             else: | ||||||
|                 return of['ctx'] |                 return of['ctx'] | ||||||
|         is_exec = of['mode'] == 'x' |         is_exec = of['mode'] == 'x' | ||||||
|         is_link = of['mode'] == 'l' |         is_link = of['mode'] == 'l' | ||||||
|         rename = of.get('rename', None) |         rename = of.get('rename', None) | ||||||
|         if check_version(3, 1): |         return make_memfilectx(repo, memctx, f, of['data'], is_link, is_exec, rename) | ||||||
|             return context.memfilectx(repo, f, of['data'], |  | ||||||
|                     is_link, is_exec, rename) |  | ||||||
|         else: |  | ||||||
|             return context.memfilectx(f, of['data'], |  | ||||||
|                     is_link, is_exec, rename) |  | ||||||
|  |  | ||||||
|     repo = parser.repo |     repo = parser.repo | ||||||
|  |  | ||||||
| @@ -1071,10 +1070,7 @@ def write_tag(repo, tag, node, msg, author): | |||||||
|         except error.ManifestLookupError: |         except error.ManifestLookupError: | ||||||
|             data = "" |             data = "" | ||||||
|         content = data + "%s %s\n" % (node, tag) |         content = data + "%s %s\n" % (node, tag) | ||||||
|         if check_version(3, 1): |         return make_memfilectx(repo, memctx, f, content, False, False, None) | ||||||
|             return context.memfilectx(repo, f, content, False, False, None) |  | ||||||
|         else: |  | ||||||
|             return context.memfilectx(f, content, False, False, None) |  | ||||||
|  |  | ||||||
|     p1 = tip.hex() |     p1 = tip.hex() | ||||||
|     p2 = '0' * 40 |     p2 = '0' * 40 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user