comparison hggit/git_handler.py @ 1101:843f409526fb

compat: pass memctx to memfilectx constructor on hg 4.5+
author Tony Tung <tonytung@merly.org>
date Mon, 05 Feb 2018 23:21:35 -0800
parents c64b73b9783f
children 93cb29247d61
comparison
equal deleted inserted replaced
1100:6dc827703bfb 1101:843f409526fb
983 copied_path = None 983 copied_path = None
984 copied = fc.renamed() 984 copied = fc.renamed()
985 if copied: 985 if copied:
986 copied_path = copied[0] 986 copied_path = copied[0]
987 987
988 try: 988 # Different versions of mercurial have different parameters to
989 return context.memfilectx(self.repo, f, data, 989 # memfilectx. Try them from newest to oldest.
990 islink='l' in e, 990 args_to_try = (
991 isexec='x' in e, 991 (self.repo, memctx, f, data), # hg 4.5+
992 copied=copied_path) 992 (self.repo, f, data), # hg 3.1 - 4.5
993 except TypeError: 993 (f, data), # hg < 3.1
994 return context.memfilectx(f, data, 994 )
995 islink='l' in e, 995 for args in args_to_try:
996 isexec='x' in e, 996 try:
997 copied=copied_path) 997 return context.memfilectx(*args,
998 islink='l' in e,
999 isexec='x' in e,
1000 copied=copied_path)
1001 except TypeError as ex:
1002 last_ex = ex
1003 raise last_ex
998 1004
999 p1, p2 = (nullid, nullid) 1005 p1, p2 = (nullid, nullid)
1000 octopus = False 1006 octopus = False
1001 1007
1002 if len(gparents) > 1: 1008 if len(gparents) > 1: