##// END OF EJS Templates
diff: add a fast path to avoid loading binary contents...
Jun Wu -
r32191:31f42e68 default
parent child Browse files
Show More
@@ -2532,12 +2532,10 b' def trydiff(repo, revs, ctx1, ctx2, modi'
2532 flag2 = None
2532 flag2 = None
2533 if f1:
2533 if f1:
2534 fctx1 = getfilectx(f1, ctx1)
2534 fctx1 = getfilectx(f1, ctx1)
2535 content1 = fctx1.data()
2536 if opts.git or losedatafn:
2535 if opts.git or losedatafn:
2537 flag1 = ctx1.flags(f1)
2536 flag1 = ctx1.flags(f1)
2538 if f2:
2537 if f2:
2539 fctx2 = getfilectx(f2, ctx2)
2538 fctx2 = getfilectx(f2, ctx2)
2540 content2 = fctx2.data()
2541 if opts.git or losedatafn:
2539 if opts.git or losedatafn:
2542 flag2 = ctx2.flags(f2)
2540 flag2 = ctx2.flags(f2)
2543 # if binary is True, output "summary" or "base85", but not "text diff"
2541 # if binary is True, output "summary" or "base85", but not "text diff"
@@ -2595,6 +2593,25 b' def trydiff(repo, revs, ctx1, ctx2, modi'
2595 # yes | yes * * * | text diff | yes
2593 # yes | yes * * * | text diff | yes
2596 # no | * * * * | text diff | yes
2594 # no | * * * * | text diff | yes
2597 # [1]: hash(fctx.data()) is outputted. so fctx.data() cannot be faked
2595 # [1]: hash(fctx.data()) is outputted. so fctx.data() cannot be faked
2596 if binary and (not opts.git or (opts.git and opts.nobinary and not
2597 opts.index)):
2598 # fast path: no binary content will be displayed, content1 and
2599 # content2 are only used for equivalent test. cmp() could have a
2600 # fast path.
2601 if fctx1 is not None:
2602 content1 = b'\0'
2603 if fctx2 is not None:
2604 if fctx1 is not None and not fctx1.cmp(fctx2):
2605 content2 = b'\0' # not different
2606 else:
2607 content2 = b'\0\0'
2608 else:
2609 # normal path: load contents
2610 if fctx1 is not None:
2611 content1 = fctx1.data()
2612 if fctx2 is not None:
2613 content2 = fctx2.data()
2614
2598 if binary and opts.git and not opts.nobinary:
2615 if binary and opts.git and not opts.nobinary:
2599 text = mdiff.b85diff(content1, content2)
2616 text = mdiff.b85diff(content1, content2)
2600 if text:
2617 if text:
General Comments 0
You need to be logged in to leave comments. Login now