comparison mercurial/patch.py @ 19875:c172660eee01 stable

patch: Fix nullid for binary git diffs (issue4054) The index for an empty file in git is not 0, but sha-1("blobl 0\0").
author Johan Bjork <jbjoerk@gmail.com>
date Mon, 07 Oct 2013 17:47:19 -0400
parents 9e8298a324ac
children 7032dcff290c
comparison
equal deleted inserted replaced
19851:4d513f96a565 19875:c172660eee01
8 8
9 import cStringIO, email.Parser, os, errno, re, posixpath 9 import cStringIO, email.Parser, os, errno, re, posixpath
10 import tempfile, zlib, shutil 10 import tempfile, zlib, shutil
11 11
12 from i18n import _ 12 from i18n import _
13 from node import hex, nullid, short 13 from node import hex, short
14 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error 14 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error
15 import context 15 import context
16 16
17 gitre = re.compile('diff --git a/(.*) b/(.*)') 17 gitre = re.compile('diff --git a/(.*) b/(.*)')
18 18
1656 elif i==3: 1656 elif i==3:
1657 meta.append('index %s,%s..%s\n' % tuple(revs)) 1657 meta.append('index %s,%s..%s\n' % tuple(revs))
1658 1658
1659 def gitindex(text): 1659 def gitindex(text):
1660 if not text: 1660 if not text:
1661 return hex(nullid) 1661 text = ""
1662 l = len(text) 1662 l = len(text)
1663 s = util.sha1('blob %d\0' % l) 1663 s = util.sha1('blob %d\0' % l)
1664 s.update(text) 1664 s.update(text)
1665 return s.hexdigest() 1665 return s.hexdigest()
1666 1666