diff hggit/git_handler.py @ 1104:e326b349eba6

compat: extract function for memfilectx signature variants
author Kevin Bullock <kbullock@ringworld.org>
date Tue, 06 Feb 2018 08:45:48 -0600
parents 93cb29247d61
children aae2d15de6af
line wrap: on
line diff
--- a/hggit/git_handler.py	Tue Feb 06 08:37:11 2018 -0600
+++ b/hggit/git_handler.py	Tue Feb 06 08:45:48 2018 -0600
@@ -985,22 +985,10 @@
                 if copied:
                     copied_path = copied[0]
 
-            # Different versions of mercurial have different parameters to
-            # memfilectx.  Try them from newest to oldest.
-            args_to_try = (
-                (self.repo, memctx, f, data),   # hg 4.5+
-                (self.repo, f, data),           # hg 3.1 - 4.5
-                (f, data),                      # hg < 3.1
-            )
-            for args in args_to_try:
-                try:
-                    return context.memfilectx(*args,
-                                              islink='l' in e,
-                                              isexec='x' in e,
-                                              copied=copied_path)
-                except TypeError as ex:
-                    last_ex = ex
-            raise last_ex
+            return compat.memfilectx(self.repo, memctx, f, data,
+                                     islink='l' in e,
+                                     isexec='x' in e,
+                                     copied=copied_path)
 
         p1, p2 = (nullid, nullid)
         octopus = False