diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1609,6 +1609,7 @@ self.headers = [] def addrange(self, limits): + self.addcontext([]) fromstart, fromend, tostart, toend, proc = limits self.fromline = int(fromstart) self.toline = int(tostart) @@ -1629,6 +1630,8 @@ if self.context: self.before = self.context self.context = [] + if self.hunk: + self.addcontext([]) self.hunk = hunk def newfile(self, hdr): diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t --- a/tests/test-commit-interactive.t +++ b/tests/test-commit-interactive.t @@ -1807,3 +1807,38 @@ n 0 -1 unset subdir/f1 $ hg status -A subdir/f1 M subdir/f1 + +Test diff.unified=0 + + $ hg init $TESTTMP/b + $ cd $TESTTMP/b + $ cat > foo < 1 + > 2 + > 3 + > 4 + > 5 + > EOF + $ hg ci -qAm initial + $ cat > foo < 1 + > change1 + > 2 + > 3 + > change2 + > 4 + > 5 + > EOF + $ printf 'y\ny\ny\n' | hg ci -im initial --config diff.unified=0 + diff --git a/foo b/foo + 2 hunks, 2 lines changed + examine changes to 'foo'? [Ynesfdaq?] y + + @@ -1,0 +2,1 @@ 1 + +change1 + record change 1/2 to 'foo'? [Ynesfdaq?] y + + @@ -3,0 +5,1 @@ 3 + +change2 + record change 2/2 to 'foo'? [Ynesfdaq?] y + diff --git a/tests/test-split.t b/tests/test-split.t --- a/tests/test-split.t +++ b/tests/test-split.t @@ -103,6 +103,12 @@ abort: cannot split multiple revisions [255] +This function splits a bit strangely primarily to avoid changing the behavior of +the test after a bug was fixed with how split/commit --interactive handled +`diff.unified=0`: when there were no context lines, it kept only the last diff +hunk. When running split, this meant that runsplit was always recording three commits, +one for each diff hunk, in reverse order (the base commit was the last diff hunk +in the file). $ runsplit() { > cat > $TESTTMP/messages < split 1 @@ -113,8 +119,11 @@ > EOF > cat < y + > n + > n > y > y + > n > y > y > y @@ -123,13 +132,23 @@ $ HGEDITOR=false runsplit diff --git a/a b/a - 1 hunks, 1 lines changed + 3 hunks, 3 lines changed examine changes to 'a'? [Ynesfdaq?] y + @@ -1,1 +1,1 @@ + -1 + +11 + record change 1/3 to 'a'? [Ynesfdaq?] n + + @@ -3,1 +3,1 @@ 2 + -3 + +33 + record change 2/3 to 'a'? [Ynesfdaq?] n + @@ -5,1 +5,1 @@ 4 -5 +55 - record this change to 'a'? [Ynesfdaq?] y + record change 3/3 to 'a'? [Ynesfdaq?] y transaction abort! rollback completed @@ -140,13 +159,23 @@ $ HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py" $ runsplit diff --git a/a b/a - 1 hunks, 1 lines changed + 3 hunks, 3 lines changed examine changes to 'a'? [Ynesfdaq?] y + @@ -1,1 +1,1 @@ + -1 + +11 + record change 1/3 to 'a'? [Ynesfdaq?] n + + @@ -3,1 +3,1 @@ 2 + -3 + +33 + record change 2/3 to 'a'? [Ynesfdaq?] n + @@ -5,1 +5,1 @@ 4 -5 +55 - record this change to 'a'? [Ynesfdaq?] y + record change 3/3 to 'a'? [Ynesfdaq?] y EDITOR: HG: Splitting 1df0d5c5a3ab. Write commit message for the first split changeset. EDITOR: a2 @@ -160,13 +189,18 @@ EDITOR: HG: changed a created new head diff --git a/a b/a - 1 hunks, 1 lines changed + 2 hunks, 2 lines changed examine changes to 'a'? [Ynesfdaq?] y + @@ -1,1 +1,1 @@ + -1 + +11 + record change 1/2 to 'a'? [Ynesfdaq?] n + @@ -3,1 +3,1 @@ 2 -3 +33 - record this change to 'a'? [Ynesfdaq?] y + record change 2/2 to 'a'? [Ynesfdaq?] y EDITOR: HG: Splitting 1df0d5c5a3ab. So far it has been split into: EDITOR: HG: - e704349bd21b: split 1