##// END OF EJS Templates
patch: handle 0 context lines (diff.unified=0) when parsing patches...
Kyle Lippincott -
r41497:d1d3094b default
parent child Browse files
Show More
@@ -1609,6 +1609,7 b' def parsepatch(originalchunks, maxcontex'
1609 self.headers = []
1609 self.headers = []
1610
1610
1611 def addrange(self, limits):
1611 def addrange(self, limits):
1612 self.addcontext([])
1612 fromstart, fromend, tostart, toend, proc = limits
1613 fromstart, fromend, tostart, toend, proc = limits
1613 self.fromline = int(fromstart)
1614 self.fromline = int(fromstart)
1614 self.toline = int(tostart)
1615 self.toline = int(tostart)
@@ -1629,6 +1630,8 b' def parsepatch(originalchunks, maxcontex'
1629 if self.context:
1630 if self.context:
1630 self.before = self.context
1631 self.before = self.context
1631 self.context = []
1632 self.context = []
1633 if self.hunk:
1634 self.addcontext([])
1632 self.hunk = hunk
1635 self.hunk = hunk
1633
1636
1634 def newfile(self, hdr):
1637 def newfile(self, hdr):
@@ -1807,3 +1807,38 b' even if none of mode, size and timestamp'
1807 n 0 -1 unset subdir/f1
1807 n 0 -1 unset subdir/f1
1808 $ hg status -A subdir/f1
1808 $ hg status -A subdir/f1
1809 M subdir/f1
1809 M subdir/f1
1810
1811 Test diff.unified=0
1812
1813 $ hg init $TESTTMP/b
1814 $ cd $TESTTMP/b
1815 $ cat > foo <<EOF
1816 > 1
1817 > 2
1818 > 3
1819 > 4
1820 > 5
1821 > EOF
1822 $ hg ci -qAm initial
1823 $ cat > foo <<EOF
1824 > 1
1825 > change1
1826 > 2
1827 > 3
1828 > change2
1829 > 4
1830 > 5
1831 > EOF
1832 $ printf 'y\ny\ny\n' | hg ci -im initial --config diff.unified=0
1833 diff --git a/foo b/foo
1834 2 hunks, 2 lines changed
1835 examine changes to 'foo'? [Ynesfdaq?] y
1836
1837 @@ -1,0 +2,1 @@ 1
1838 +change1
1839 record change 1/2 to 'foo'? [Ynesfdaq?] y
1840
1841 @@ -3,0 +5,1 @@ 3
1842 +change2
1843 record change 2/2 to 'foo'? [Ynesfdaq?] y
1844
@@ -103,6 +103,12 b' Split a head'
103 abort: cannot split multiple revisions
103 abort: cannot split multiple revisions
104 [255]
104 [255]
105
105
106 This function splits a bit strangely primarily to avoid changing the behavior of
107 the test after a bug was fixed with how split/commit --interactive handled
108 `diff.unified=0`: when there were no context lines, it kept only the last diff
109 hunk. When running split, this meant that runsplit was always recording three commits,
110 one for each diff hunk, in reverse order (the base commit was the last diff hunk
111 in the file).
106 $ runsplit() {
112 $ runsplit() {
107 > cat > $TESTTMP/messages <<EOF
113 > cat > $TESTTMP/messages <<EOF
108 > split 1
114 > split 1
@@ -113,8 +119,11 b' Split a head'
113 > EOF
119 > EOF
114 > cat <<EOF | hg split "$@"
120 > cat <<EOF | hg split "$@"
115 > y
121 > y
122 > n
123 > n
116 > y
124 > y
117 > y
125 > y
126 > n
118 > y
127 > y
119 > y
128 > y
120 > y
129 > y
@@ -123,13 +132,23 b' Split a head'
123
132
124 $ HGEDITOR=false runsplit
133 $ HGEDITOR=false runsplit
125 diff --git a/a b/a
134 diff --git a/a b/a
126 1 hunks, 1 lines changed
135 3 hunks, 3 lines changed
127 examine changes to 'a'? [Ynesfdaq?] y
136 examine changes to 'a'? [Ynesfdaq?] y
128
137
138 @@ -1,1 +1,1 @@
139 -1
140 +11
141 record change 1/3 to 'a'? [Ynesfdaq?] n
142
143 @@ -3,1 +3,1 @@ 2
144 -3
145 +33
146 record change 2/3 to 'a'? [Ynesfdaq?] n
147
129 @@ -5,1 +5,1 @@ 4
148 @@ -5,1 +5,1 @@ 4
130 -5
149 -5
131 +55
150 +55
132 record this change to 'a'? [Ynesfdaq?] y
151 record change 3/3 to 'a'? [Ynesfdaq?] y
133
152
134 transaction abort!
153 transaction abort!
135 rollback completed
154 rollback completed
@@ -140,13 +159,23 b' Split a head'
140 $ HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py"
159 $ HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py"
141 $ runsplit
160 $ runsplit
142 diff --git a/a b/a
161 diff --git a/a b/a
143 1 hunks, 1 lines changed
162 3 hunks, 3 lines changed
144 examine changes to 'a'? [Ynesfdaq?] y
163 examine changes to 'a'? [Ynesfdaq?] y
145
164
165 @@ -1,1 +1,1 @@
166 -1
167 +11
168 record change 1/3 to 'a'? [Ynesfdaq?] n
169
170 @@ -3,1 +3,1 @@ 2
171 -3
172 +33
173 record change 2/3 to 'a'? [Ynesfdaq?] n
174
146 @@ -5,1 +5,1 @@ 4
175 @@ -5,1 +5,1 @@ 4
147 -5
176 -5
148 +55
177 +55
149 record this change to 'a'? [Ynesfdaq?] y
178 record change 3/3 to 'a'? [Ynesfdaq?] y
150
179
151 EDITOR: HG: Splitting 1df0d5c5a3ab. Write commit message for the first split changeset.
180 EDITOR: HG: Splitting 1df0d5c5a3ab. Write commit message for the first split changeset.
152 EDITOR: a2
181 EDITOR: a2
@@ -160,13 +189,18 b' Split a head'
160 EDITOR: HG: changed a
189 EDITOR: HG: changed a
161 created new head
190 created new head
162 diff --git a/a b/a
191 diff --git a/a b/a
163 1 hunks, 1 lines changed
192 2 hunks, 2 lines changed
164 examine changes to 'a'? [Ynesfdaq?] y
193 examine changes to 'a'? [Ynesfdaq?] y
165
194
195 @@ -1,1 +1,1 @@
196 -1
197 +11
198 record change 1/2 to 'a'? [Ynesfdaq?] n
199
166 @@ -3,1 +3,1 @@ 2
200 @@ -3,1 +3,1 @@ 2
167 -3
201 -3
168 +33
202 +33
169 record this change to 'a'? [Ynesfdaq?] y
203 record change 2/2 to 'a'? [Ynesfdaq?] y
170
204
171 EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into:
205 EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into:
172 EDITOR: HG: - e704349bd21b: split 1
206 EDITOR: HG: - e704349bd21b: split 1
General Comments 0
You need to be logged in to leave comments. Login now