[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnu-arch-users] --forward mostly harmless
From: |
David Allouche |
Subject: |
[Gnu-arch-users] --forward mostly harmless |
Date: |
Mon, 13 Sep 2004 02:06:20 +0200 |
I was writing some test cases for PyArch, when I found myself having
trouble identifying the behaviour enabled by the --forward option to
apply-changeset.
The intended behaviour of the --forward option, according to Tom:
As with `patch(1)', --forward means "ignore hunks that appear to
already have been applied".
For some time, I had a gnawing doubt about what the --forward option to
patch really meant. So I looked at the documentation really closely.
`-N'
`--forward'
Ignore patches that `patch' thinks are reversed or already applied.
See also `-R'. *Note Reversed Patches::.
Note that the documentation says "ignore patches", not "ignore hunks".
The "Reversed Patches" page says:
Often `patch' can guess that the patch is reversed. If the first
hunk of a patch fails, `patch' reverses the hunk to see if it can apply
it that way. If it can, `patch' asks you if you want to have the `-R'
option set; if it can't, `patch' continues to apply the patch normally.
In other words, `patch' thinks that a patch is reversed if the _first_
hunk of the patch can only be applied in reverse, and then --forward
tells it to ignore the _whole_ patch.
This behaviour is demonstrated in the attached test case.
I believe we can agree that is not a useful behaviour for tla.
However the test case fails to expose any difference in the behaviour of
tla when --forward is used with a simple changeset which only changes
the contents of a file.
The reason for that surprising result is that tla invokes patch with the
options "[--forward] -f -s --posix" and -f effectively disables
--forward.
The fact this problem was not found so far strongly suggests that nobody
is actually using --forward.
Since he intended functionality of the --forward option to tla is
currently not implemented by patch, and since the current implementation
of --forward in tla is no-op as far as I can tell, I suggest the
--forward option be removed.
--
-- ddaa
apply-forward.sh
Description: Test cases for patch and tla
method set: names
method set: names
method set: names
~ ~
* produced diff
--- treeA/file.txt 2004-09-13 02:00:09.070591396 +0200
+++ treeC/file.txt 2004-09-13 02:00:09.077590164 +0200
@@ -1,5 +1,5 @@
1 ---
-2 hello world
+2 Hello, World!
3 ---
4 --
5 -
@@ -7,5 +7,5 @@
7 -
8 --
9 ---
-A yadda yadda
+A Yadda, Yadda!
B ---
patching file file.txt
Reversed (or previously applied) patch detected! Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file file.txt.rej
* patch exits with status 0
* produced reject
***************
*** 1,5 ****
1 ---
- 2 hello world
3 ---
4 --
5 -
--- 1,5 ----
1 ---
+ 2 Hello, World!
3 ---
4 --
5 -
***************
*** 7,11 ****
7 -
8 --
9 ---
- A yadda yadda
B ---
--- 7,11 ----
7 -
8 --
9 ---
+ A Yadda, Yadda!
B ---
~
M file.txt
** Redundant patch
C file.txt
* apply-changeset failed
* produced reject
***************
--- 1,5 ****
1 ---
- 2 hello world
3 ---
4 --
5 -
--- 1,5 ----
1 ---
+ 2 Hello, World!
3 ---
4 --
5 -
***************
--- 7,11 ****
7 -
8 --
9 ---
- A yadda yadda
B ---
--- 7,11 ----
7 -
8 --
9 ---
+ A Yadda, Yadda!
B ---
* no tree changes (normal)
** Only first hunk reversable
C file.txt
* apply-changeset failed
* produced reject
***************
--- 1,5 ****
1 ---
- 2 hello world
3 ---
4 --
5 -
--- 1,5 ----
1 ---
+ 2 Hello, World!
3 ---
4 --
5 -
M file.txt
- [Gnu-arch-users] --forward mostly harmless,
David Allouche <=
- Re: [Gnu-arch-users] --forward mostly harmless, Tom Lord, 2004/09/12
- Re: [Gnu-arch-users] --forward mostly harmless, Miles Bader, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, David Allouche, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, Miles Bader, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, Aaron Bentley, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, David Allouche, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, Phil Frost, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, Aaron Bentley, 2004/09/13
- Re: [Gnu-arch-users] --forward mostly harmless, David Allouche, 2004/09/13
- [Gnu-arch-users] Re: --forward mostly harmless, Stefan Monnier, 2004/09/13