##// END OF EJS Templates
Merge with crew-stable
Patrick Mezard -
r5853:deb0d351 merge default
parent child Browse files
Show More
@@ -505,7 +505,7 b' class patchfile:'
505 return -1
505 return -1
506
506
507 class hunk:
507 class hunk:
508 def __init__(self, desc, num, lr, context):
508 def __init__(self, desc, num, lr, context, gitpatch=None):
509 self.number = num
509 self.number = num
510 self.desc = desc
510 self.desc = desc
511 self.hunk = [ desc ]
511 self.hunk = [ desc ]
@@ -515,6 +515,7 b' class hunk:'
515 self.read_context_hunk(lr)
515 self.read_context_hunk(lr)
516 else:
516 else:
517 self.read_unified_hunk(lr)
517 self.read_unified_hunk(lr)
518 self.gitpatch = gitpatch
518
519
519 def read_unified_hunk(self, lr):
520 def read_unified_hunk(self, lr):
520 m = unidesc.match(self.desc)
521 m = unidesc.match(self.desc)
@@ -669,10 +670,12 b' class hunk:'
669 return len(self.a) == self.lena and len(self.b) == self.lenb
670 return len(self.a) == self.lena and len(self.b) == self.lenb
670
671
671 def createfile(self):
672 def createfile(self):
672 return self.starta == 0 and self.lena == 0
673 create = self.gitpatch is None or self.gitpatch.op == 'ADD'
674 return self.starta == 0 and self.lena == 0 and create
673
675
674 def rmfile(self):
676 def rmfile(self):
675 return self.startb == 0 and self.lenb == 0
677 remove = self.gitpatch is None or self.gitpatch.op == 'DELETE'
678 return self.startb == 0 and self.lenb == 0 and remove
676
679
677 def fuzzit(self, l, fuzz, toponly):
680 def fuzzit(self, l, fuzz, toponly):
678 # this removes context lines from the top and bottom of list 'l'. It
681 # this removes context lines from the top and bottom of list 'l'. It
@@ -773,7 +776,7 b' class binhunk:'
773
776
774 def parsefilename(str):
777 def parsefilename(str):
775 # --- filename \t|space stuff
778 # --- filename \t|space stuff
776 s = str[4:]
779 s = str[4:].rstrip('\r\n')
777 i = s.find('\t')
780 i = s.find('\t')
778 if i < 0:
781 if i < 0:
779 i = s.find(' ')
782 i = s.find(' ')
@@ -905,7 +908,8 b' def iterhunks(ui, fp, sourcefile=None):'
905 try:
908 try:
906 if context == None and x.startswith('***************'):
909 if context == None and x.startswith('***************'):
907 context = True
910 context = True
908 current_hunk = hunk(x, hunknum + 1, lr, context)
911 gpatch = changed.get(bfile[2:], (None, None))[1]
912 current_hunk = hunk(x, hunknum + 1, lr, context, gpatch)
909 except PatchError, err:
913 except PatchError, err:
910 ui.debug(err)
914 ui.debug(err)
911 current_hunk = None
915 current_hunk = None
@@ -153,3 +153,31 b' echo line0 >> a'
153 hg ci -m brancha
153 hg ci -m brancha
154 hg import -v tip.patch
154 hg import -v tip.patch
155 cd ..
155 cd ..
156
157 # Test hunk touching empty files (issue906)
158 hg init empty
159 cd empty
160 touch a
161 touch b1
162 touch c1
163 echo d > d
164 hg ci -Am init
165 echo a > a
166 echo b > b1
167 hg mv b1 b2
168 echo c > c1
169 hg copy c1 c2
170 rm d
171 touch d
172 hg diff --git
173 hg ci -m empty
174 hg export --git tip > empty.diff
175 hg up -C 0
176 hg import empty.diff
177 for name in a b1 b2 c1 c2 d;
178 do
179 echo % $name file
180 test -f $name && cat $name
181 done
182 cd ..
183
@@ -134,3 +134,48 b' applying tip.patch'
134 patching file a
134 patching file a
135 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
135 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
136 a
136 a
137 adding a
138 adding b1
139 adding c1
140 adding d
141 diff --git a/a b/a
142 --- a/a
143 +++ b/a
144 @@ -0,0 +1,1 @@
145 +a
146 diff --git a/b1 b/b2
147 rename from b1
148 rename to b2
149 --- a/b1
150 +++ b/b2
151 @@ -0,0 +1,1 @@
152 +b
153 diff --git a/c1 b/c1
154 --- a/c1
155 +++ b/c1
156 @@ -0,0 +1,1 @@
157 +c
158 diff --git a/c1 b/c2
159 copy from c1
160 copy to c2
161 --- a/c1
162 +++ b/c2
163 @@ -0,0 +1,1 @@
164 +c
165 diff --git a/d b/d
166 --- a/d
167 +++ b/d
168 @@ -1,1 +0,0 @@
169 -d
170 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
171 applying empty.diff
172 % a file
173 a
174 % b1 file
175 % b2 file
176 b
177 % c1 file
178 c
179 % c2 file
180 c
181 % d file
General Comments 0
You need to be logged in to leave comments. Login now