Allow rbt patch to work in SVN subdirectories
Review Request #7110 — Created March 24, 2015 and submitted
Previously
rbt patch
would not work in a subdirectory or subdirectory
checkout. This was because the incorrect number of leading directories
were being stripped (due to our SVN diffs having absolute paths). We now
compute the correct number of leading directories to strip when applying
patches and they now apply correctly.If a patch for SVN is generated in a different directory, files included
in the patch that are not under the current directory will not be
applied. If this occurs, the user will be informed.This patch also fixes the issue of passing a value
--px
flag on the
commandline causing a formatting error.
Ran unit tests.
Manually tested the cases that gmyers outlined in
https://reviews.reviewboard.org/r/7095/.rbt patch
works in all of
these cases.
Description | From | Last Updated |
---|---|---|
I don't understand what you are trying to protect against here. If I remove this, then all of the test … |
gmyers | |
Very minor, but should this be self.INDEX_FILE_RE? |
gmyers | |
Not sure if this is important, but I was looking at filter_diff() in utils/diffs.py which follows a similar recipe, and … |
gmyers | |
local variable 'filtered_diff' is assigned to but never used |
reviewbot |
- Change Summary:
-
Wrong commit.
- Commit:
-
6b045e1bce55c84d0bfcd0241023f44376279361a20cc632ff8984a607bac6ca710fa75b47560ec0
-
Tool: Pyflakes Processed Files: rbtools/clients/svn.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py rbtools/clients/errors.py
-
-
I don't understand what you are trying to protect against here. If I remove this, then all of the test cases from https://reviews.reviewboard.org/r/7095/ work correctly, whereas with this code in place cases 3 and 5 throw the exception.
As far as I understand it
base_dir
is metadata that describes whererbt post
was executed from in terms of the directory hierarchy in the repository. But, for any particular file in a diff, it doesn't matter whererbt post
is executed from because the path in the diff is always an absolute path. So in 7095, cases 1 and 2 have differentbase_dir
metadata but the contents of the diff are identical:Index: /trunk/a.txt =================================================================== --- /trunk/a.txt (revision 4) +++ /trunk/a.txt (working copy) @@ -1 +1,2 @@ This is a file. +I'm from wcRoot
base_path
is analogous tobase_dir
in that it describes where the current working directory (on the local filesystem) in the working copy is in terms of the repository hierarchy. For the purposes of patching we need to know this current location in the hierarchy so we can strip the appropriate number of leading paths from the absolute paths in the diff. I don't see whybase_dir
, which again only describes where the post originated from, should have any bearing on where and how the patch can be applied.Is there a case that I'm overlooking?
- Description:
-
Previously
rbt patch
would not work in a subdirectory or subdirectorycheckout. This was because the incorrect number of leading directories were being stripped (due to our SVN diffs having absolute paths). We now compute the correct number of leading directories to strip when applying patches and they now apply correctly. ~ Patches for SVN must now be applied in the directory they were generated
~ or a higher level directory. You can not apply a patch from a higher ~ level directory in a lower level directory or rbt
will exit with an~ If a patch for SVN is generated in a different directory, files included
~ in the patch that are not under the current directory will not be ~ applied. If this occurs, the user will be informed. - error message indicating where the patch should be applied. This patch also fixes the issue of passing a value
--px
flag on thecommandline causing a formatting error. - Testing Done:
-
Ran unit tests.
Manually tested the cases that gmyers outlined in
~ https://reviews.reviewboard.org/r/7095/. rbt patch
works in cases~ except where the diff was created in a higher level directory; those ~ https://reviews.reviewboard.org/r/7095/. rbt patch
works in all of~ these cases. - cases correctly raise an exception. - Commit:
-
a20cc632ff8984a607bac6ca710fa75b47560ec0c5fb7d3a90726053f51e3d04484c42b153b47432
- Diff:
-
Revision 3 (+62 -5)
- Change Summary:
-
PEP8 / documentation fixes.
- Commit:
-
c5fb7d3a90726053f51e3d04484c42b153b47432bb5692c82d1bbf9776c39acfbfe5d4a4cf3be2e7
- Diff:
-
Revision 4 (+66 -5)
-
Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py Tool: Pyflakes Processed Files: rbtools/clients/svn.py
- Commit:
-
bb5692c82d1bbf9776c39acfbfe5d4a4cf3be2e7fa6e6595b2dcbcada70a0ad7f5e4446c585fcf10
- Diff:
-
Revision 5 (+65 -5)
-
Tool: Pyflakes Processed Files: rbtools/clients/svn.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py
- Change Summary:
-
Remove debug print statement.
- Commit:
-
fa6e6595b2dcbcada70a0ad7f5e4446c585fcf10867c5a4bc5dfce3d098c1583eaeccc33b6523e1a
- Diff:
-
Revision 6 (+64 -5)
-
Tool: Pyflakes Processed Files: rbtools/clients/svn.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py
-
Looks great, Barret! I really like the new filtering approach.
-
-
Not sure if this is important, but I was looking at
filter_diff()
in utils/diffs.py which follows a similar recipe, and therem.group(1).decode('utf-8')
is used. -
Is there any need to and/or value in returning early from
apply_patch()
or returning a differentPatchResult.applied
value in the special case where all files are excluded?
- Commit:
-
867c5a4bc5dfce3d098c1583eaeccc33b6523e1a7fd84eed56a5d4f2f16d01c7fce2bcf47b5044f0
- Diff:
-
Revision 7 (+74 -5)