git-p4: support multiple depot paths in p4 submit
PATCH 1/2 git-p4: support multiple depot paths in p4 submit
When submitting from a repository that was cloned using a client spec, use the full list of paths when ruling out files that are outside the view. This fixes a bug where only files pertaining to the first path would be included in the p4 submit.
--- git-p4.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
git-p4.py +9 -2
@@ -1253,6 +1253,8 @@ class P4Submit(Command, P4UserMap): Remove lines in the Files section that show changes to files outside the depot path we're committing into.""" + [upstream, settings] = findUpstreamBranchPoint() + template = "" inFilesSection = False for line in p4_read_pipe_lines(['change', '-o']):
@@ -1265,8 +1267,13 @@ class P4Submit(Command, P4UserMap): lastTab = path.rfind("\t") if lastTab != -1: path = path[:lastTab] - if not p4PathStartsWith(path, self.depotPath): - continue + if settings.has_key('depot-paths'): + if not [p for p in settings['depot-paths'] + if p4PathStartsWith(path, p)]: + continue + else: + if not p4PathStartsWith(path, self.depotPath): + continue else: inFilesSection = False else:
Signature · 1 line
2.6.2
Thanks for the patch! Do you see a way to demonstrate the bug in a test case similar to t9821 [1]?
Cheers,
Lars
[1] https://github.com/git/git/blob/master/t/t9821-git-p4-path-variations.sh
Quoted 43 lines · Sam Hocevar
When submitting from a repository that was cloned using a client spec, use the full list of paths when ruling out files that are outside the view. This fixes a bug where only files pertaining to the first path would be included in the p4 submit.
Signed-off-by Sam Hocevar <[email protected]>---
git-p4.py| 11 +++++++++--1 file changed, 9 insertions(+), 2 deletions(-)git-p4.py +9
-2@@ -1253,6 +1253,8 @@ class P4Submit(Command, P4UserMap): Remove lines in the Files section that show changes to files outside the depot path we're committing into.""" + [upstream, settings] = findUpstreamBranchPoint() + template = "" inFilesSection = False for line in p4_read_pipe_lines(['change', '-o']):@@ -1265,8 +1267,13 @@ class P4Submit(Command, P4UserMap): lastTab = path.rfind("\t") if lastTab != -1: path = path[:lastTab] - if not p4PathStartsWith(path, self.depotPath): - continue + if settings.has_key('depot-paths'): + if not [p for p in settings['depot-paths'] + if p4PathStartsWith(path, p)]: + continue + else: + if not p4PathStartsWith(path, self.depotPath): + continue else: inFilesSection = False else:Signature · 1 line
2.6.2
Quoted 1 line · Lars Schneider
Thanks for the patch! Do you see a way to demonstrate the bug in a test case similar to t9821 [1]?
Not yet, I'm afraid. It's proving trickier than expected because for
now I can only reproduce the bug when the view uses multiples depots (solution #2 on http://answers.perforce.com/articles/KB/2437), and unfortunately the test case system in Git was designed for a single depot.
Would a refactor of lib-git-p4.sh (and probably all git-p4 tests) to
support multiple depots be acceptable and/or welcome? I prefer to ask before I dig into the task.
Regards,
Signature · 1 line
Sam.
Quoted 9 lines · Sam Hocevar
Quoted 1 line · Lars Schneider
Thanks for the patch! Do you see a way to demonstrate the bug in a test case similar to t9821 [1]?
Not yet, I'm afraid. It's proving trickier than expected because for
now I can only reproduce the bug when the view uses multiples depots (solution #2 on http://answers.perforce.com/articles/KB/2437), and unfortunately the test case system in Git was designed for a single depot.
Quoted 3 lines
Would a refactor of
lib-git-p4.sh(and probably all git-p4 tests) to
support multiple depots be acceptable and/or welcome? I prefer to ask before I dig into the task.
Can you outline your idea a bit? Are you aware of the following way to define client specs: [1] ? Would that help? I haven't used multiple depots, yet. Therefore please bare with me :-)
Thanks,
Lars
Quoted 5 lines · Lars Schneider
Quoted 3 lines
Would a refactor of
lib-git-p4.sh(and probably all git-p4 tests) to
support multiple depots be acceptable and/or welcome? I prefer to ask before I dig into the task.Can you outline your idea a bit? Are you aware of the following way to define client specs: [1] ? Would that help?
That's the idea, but the bug occurs when the client view looks like this:
//depot/... //client/dir1/...
//depot2/... //client/dir2/... And is then cloned with (it is not legal in Perforce to specify //...
directly to grab both depots at once):
git p4 clone --use-client-spec //depot/... //depot2/...
Then when a file is modified in dir2/, git p4 submit does not elect it
for the changelist. A file in dir1/ will work fine.
Unfortunately the current test suite assumes everything is under
//depot/ so in order to write a test for this situation there are a few things to change in lib-git-p4.sh.
Regards,
Signature · 1 line
Sam.
Quoted 16 lines · Sam Hocevar
Quoted 5 lines · Lars Schneider
Quoted 3 lines
Would a refactor of
lib-git-p4.sh(and probably all git-p4 tests) to
support multiple depots be acceptable and/or welcome? I prefer to ask before I dig into the task.Can you outline your idea a bit? Are you aware of the following way to define client specs: [1] ? Would that help?
That's the idea, but the bug occurs when the client view looks like this:
//depot/... //client/dir1/... //depot2/... //client/dir2/...And is then cloned with (it is not legal in Perforce to specify //...
directly to grab both depots at once):
Quoted 8 lines
git p4 clone --use-client-spec //depot/... //depot2/...Then when a file is modified in dir2/, git p4 submit does not elect it
for the changelist. A file in dir1/ will work fine.Unfortunately the current test suite assumes everything is under
//depot/ so in order to write a test for this situation there are a few things to change inlib-git-p4.sh.
I think the existing structure ought to mostly work, but it might need a bit of tweaking.
You would need to create a new depot, but you can do that in your test script.
And you would need a client spec that pointed at this depot, but again you can do that in your script with the client_view shell function.
I've not tried it myself though, so maybe it's harder than that.
Luke
Quoted 4 lines
Regards,
--
Sam.