##// END OF EJS Templates
patch: make diff --git to differentiate b/w file is empty or doesn't exists...
Sushil khanchi -
r47664:33350deb stable
parent child Browse files
Show More
@@ -20,6 +20,7 b' import zlib'
20 from .i18n import _
20 from .i18n import _
21 from .node import (
21 from .node import (
22 hex,
22 hex,
23 nullhex,
23 short,
24 short,
24 )
25 )
25 from .pycompat import open
26 from .pycompat import open
@@ -3099,11 +3100,13 b' def diffcontent(data1, data2, header, bi'
3099
3100
3100 ctx1, fctx1, path1, flag1, content1, date1 = data1
3101 ctx1, fctx1, path1, flag1, content1, date1 = data1
3101 ctx2, fctx2, path2, flag2, content2, date2 = data2
3102 ctx2, fctx2, path2, flag2, content2, date2 = data2
3103 index1 = _gitindex(content1) if path1 in ctx1 else nullhex
3104 index2 = _gitindex(content2) if path2 in ctx2 else nullhex
3102 if binary and opts.git and not opts.nobinary:
3105 if binary and opts.git and not opts.nobinary:
3103 text = mdiff.b85diff(content1, content2)
3106 text = mdiff.b85diff(content1, content2)
3104 if text:
3107 if text:
3105 header.append(
3108 header.append(
3106 b'index %s..%s' % (_gitindex(content1), _gitindex(content2))
3109 b'index %s..%s' % (index1, index2)
3107 )
3110 )
3108 hunks = ((None, [text]),)
3111 hunks = ((None, [text]),)
3109 else:
3112 else:
@@ -3114,8 +3117,8 b' def diffcontent(data1, data2, header, bi'
3114 header.append(
3117 header.append(
3115 b'index %s..%s %s'
3118 b'index %s..%s %s'
3116 % (
3119 % (
3117 _gitindex(content1)[0 : opts.index],
3120 index1[0 : opts.index],
3118 _gitindex(content2)[0 : opts.index],
3121 index2[0 : opts.index],
3119 _gitmode[flag],
3122 _gitmode[flag],
3120 )
3123 )
3121 )
3124 )
@@ -467,7 +467,7 b' for git blob oids'
467 $ hg ci -Am "empty a"
467 $ hg ci -Am "empty a"
468 adding a
468 adding a
469 $ hg diff -c 0 --git --config experimental.extendedheader.index=full | grep index
469 $ hg diff -c 0 --git --config experimental.extendedheader.index=full | grep index
470 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
470 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
471
471
472 Make sure `hg diff --git` differentiate "file was empty" and "file is removed"
472 Make sure `hg diff --git` differentiate "file was empty" and "file is removed"
473 for git blob oids
473 for git blob oids
@@ -476,6 +476,6 b' for git blob oids'
476 $ hg ci -Am "removed a"
476 $ hg ci -Am "removed a"
477 removing a
477 removing a
478 $ hg diff -c 1 --git --config experimental.extendedheader.index=full | grep index
478 $ hg diff -c 1 --git --config experimental.extendedheader.index=full | grep index
479 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
479 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 100644
480
480
481 $ cd ..
481 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now