remote-hg: match hg merge behavior
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
Felipe Contreras committed
Nov 4, 2012 at 03:13 UTC
6497a2bab5880dc353b83bb5d4615074d6552959
1 file changed
+17
contrib/remote-helpers/git-remote-hg
+17
@@ -427,6 +427,14 @@ def parse_blob(parser):
427
parser.next()
428
return
429
430
+def get_merge_files(repo, p1, p2, files):
431
+ for e in repo[p1].files():
432
+ if e not in files:
433
+ if e not in repo[p1].manifest():
434
+ continue
435
+ f = { 'ctx' : repo[p1][e] }
436
+ files[e] = f
437
+
438
def parse_commit(parser):
439
global marks, blob_marks, bmarks, parsed_refs
440
@@ -470,6 +478,8 @@ def parse_commit(parser):
478
of = files[f]
479
if 'deleted' in of:
480
raise IOError
481
+ if 'ctx' in of:
482
+ return of['ctx']
483
is_exec = of['mode'] == 'x'
484
is_link = of['mode'] == 'l'
485
return context.memfilectx(f, of['data'], is_link, is_exec, None)
@@ -492,6 +502,13 @@ def parse_commit(parser):
502
else:
503
p2 = '\0' * 20
504
505
+ #
506
+ # If files changed from any of the parents, hg wants to know, but in git if
507
+ # nothing changed from the first parent, nothing changed.
508
+ #
509
+ if merge_mark:
510
+ get_merge_files(repo, p1, p2, files)
511
+
512
ctx = context.memctx(repo, (p1, p2), data,
513
files.keys(), getfilectx,
514
user, (date, tz), extra)