Fix rbt patch for SVN backend
Review Request #7095 — Created March 20, 2015 and submitted
Previously,
rbt patch
would not work with SVN repositories. This was
because the the value for patch's-p
flag was being calculated
incorrectly for SVN repositories. This has been corrected and now we use
svn patch
to apply the patch instead of thepatch
executable. This
allows patches containing SVN keywords to be applied.
Ran unit tests.
Successfully used
rbt patch
to apply a patch to an SVN repository.
Successfully usedrbt patch
to apply a patch to an SVN repository that
used SVN keywords (e.g.$Rev$
).
Description | From | Last Updated |
---|---|---|
These parens aren't useful. |
david | |
The logic in _get_p_number() does not seem correct in all cases, particularly when the working copy where the patch is … |
gmyers | |
If I provide a --px NUM option on the command line, then I get an exception here: ... File "/xxxx/rbtools/rbtools/clients/svn.py", … |
gmyers |
-
Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py Tool: Pyflakes Processed Files: rbtools/clients/svn.py
-
Tool: Pyflakes Processed Files: rbtools/clients/svn.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py
-
I've been leveraging
svn patch
for a while as an indirect mechanism for applying patches from RB, so I like this change. But, I did want to note thatsvn patch
didn't come into existence until Subversion 1.7 (https://subversion.apache.org/docs/release-notes/1.7.html#patch) so I suppose it's possible this could lead to a regression for users of older SVN releases, although it sounds likerbt patch
for SVN was broken to begin with.
-
-
The logic in
_get_p_number()
does not seem correct in all cases, particularly when the working copy where the patch is being applied does not correspond to the repository root. Suppose I have a repo that looks something like:/
|-- branches
|-- tags
|-- trunk
|-- a.txtI might have two different checkouts here, one from the repository root and one from trunk:
wcRoot: svn checkout file://URL/repo /tmp/wcRoot
wcTrunk: svn checkout file://URL/repo/trunk /tmp/wcTrunkSuppose then I make a trivial modification to a.txt in wcRoot. I can execute
rbt post
from either /tmp/wcRoot (post-method-A) or /tmp/wcRoot/trunk (post-method-B). These appear to result in different base_path metadata, although it is not clear to me if this is really desired. The underlying content of the diffs is identical.Anyway with these two working copies and two post methods, I now have several possible combinations for applying a patch with
rbt patch
:Case 1
Post from: post-method-A
Patch to: wcRoot (executerbt patch
in /tmp/wcRoot)
base_dir: /
base_path: /
p_num: 1
Result: SuccessCase 2
Post from: post-method-B
Patch to: wcRoot (executerbt patch
in /tmp/wcRoot)
base_dir: /trunk
base_path: /
p_num: 1
Result: SuccessCase 3
Post from: post-method-A
Patch to: wcRoot (executerbt patch
in /tmp/wcRoot/trunk)
base_dir: /
base_path: /trunk
p_num: None
Result: Failure to patch (Skipped missing target: '/trunk/a.txt')Case 4
Post from: post-method-B
Patch to: wcRoot (executerbt patch
in /tmp/wcRoot/trunk)
base_dir: /trunk
base_path: /trunk
p_num: 1
Result: Failure to patch (Skipped missing target: '/trunk/a.txt')Case 5
Post from: post-method-A
Patch to: wcTrunk (executerbt patch
in /tmp/wcTrunk)
base_dir: /
base_path: /trunk
p_num: None
Result: Failure to patch (Skipped missing target: '/trunk/a.txt')Case 6
Post from: post-method-B
Patch to: wcTrunk (executerbt patch
in /tmp/wcTrunk)
base_dir: /trunk
base_path: /trunk
p_num: 1
Result: Failure to patch (Skipped missing target: '/trunk/a.txt')Cases 3 and 5 and cases 4 and 6 are effectively identical. Cases 3-6 would all work as expected if
p_num
was 2 rather than None or 1. -
If I provide a
--px NUM
option on the command line, then I get an exception here:... File "/xxxx/rbtools/rbtools/clients/svn.py", line 682, in apply_patch cmd.append('--strip=%d' % p_num) TypeError: %d format: a number is required, not str