Message ID | CAPgZwKbZ0g+VXjnD03hGkRXfwU2DpygLhLBFG3xv1W9c8oQ1fQ@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | git-p4 cannot use perforce client created by p4java — "Expected view key View1 missing" | expand |
On Tue, 7 Jan 2020 at 15:53, Ivan Selin <ivan.selin@toptal.com> wrote: > > Hello! > > If I create a perforce client from java using p4java, it gets created > with an extra key "ViewDepotType" in client definition. When I try to > do `git p4 sync --use-client-spec`, git-p4 dies with message like > "Expected view key View1 missing" — because it assumes that all keys > starting with "View" are "View0", "View1" and so on. > > How to reproduce: > 1) Create perforce repository; > 2) Create a perforce client (let's name it "my-client") in said > perforce repository using p4java; add one view mapping to the client > on creation; > 3) Run `P4CLIENT=my-client git p4 sync --use-client-spec`; > 4) git p4 finishes with error "Expected view key View1 missing". > > Attaching hexdumped/unmarshalled examples of "regular" client > definition and client created with p4java. Note that p4java's version > has "ViewDepotType" key and regular client does not. Also, > "ViewDepotType" key is not showing up in text output of `p4 client > -o`, only in binary format (`p4 -G client -o`). And I'm attaching a > patch that solved the issue for me. > > Is that information enough or should I add anything else? I'm new to > git community, but willing to help. I suspect the problem lies at around line 4220 of git-p4, where it does this: view_keys = [ k for k in entry.keys() if k.startswith("View") ] I think changing that startswith to a regex match would fix this, although I have not tried it. Something like: is_view = re.compile(r'^View\d+$') view_keys = [ k for k in entry.keys() if is_view.match(k) ] > > Regards, > Ivan.
Yes, that's exactly the way that I've tried it and it worked for me. Can we have that integrated into git-p4? What can I do to make it happen? On Wed, Jan 29, 2020 at 1:35 PM Luke Diamand <luke@diamand.org> wrote: > > On Tue, 7 Jan 2020 at 15:53, Ivan Selin <ivan.selin@toptal.com> wrote: > > > > Hello! > > > > If I create a perforce client from java using p4java, it gets created > > with an extra key "ViewDepotType" in client definition. When I try to > > do `git p4 sync --use-client-spec`, git-p4 dies with message like > > "Expected view key View1 missing" — because it assumes that all keys > > starting with "View" are "View0", "View1" and so on. > > > > How to reproduce: > > 1) Create perforce repository; > > 2) Create a perforce client (let's name it "my-client") in said > > perforce repository using p4java; add one view mapping to the client > > on creation; > > 3) Run `P4CLIENT=my-client git p4 sync --use-client-spec`; > > 4) git p4 finishes with error "Expected view key View1 missing". > > > > Attaching hexdumped/unmarshalled examples of "regular" client > > definition and client created with p4java. Note that p4java's version > > has "ViewDepotType" key and regular client does not. Also, > > "ViewDepotType" key is not showing up in text output of `p4 client > > -o`, only in binary format (`p4 -G client -o`). And I'm attaching a > > patch that solved the issue for me. > > > > Is that information enough or should I add anything else? I'm new to > > git community, but willing to help. > > I suspect the problem lies at around line 4220 of git-p4, where it does this: > > view_keys = [ k for k in entry.keys() if k.startswith("View") ] > > I think changing that startswith to a regex match would fix this, > although I have not tried it. > Something like: > > is_view = re.compile(r'^View\d+$') > view_keys = [ k for k in entry.keys() if is_view.match(k) ] > > > > > > Regards, > > Ivan.
On Fri, 31 Jan 2020 at 13:43, Ivan Selin <ivan.selin@toptal.com> wrote: > > Yes, that's exactly the way that I've tried it and it worked for me. > Can we have that integrated into git-p4? What can I do to make it > happen? A patch would be very welcome! See Documentation/SubmittingPatches for details, but it's likely enough to just make the change, and then use git format-patch and git send-email. Please ensure you add a "Signed-off-by" (git commit -s). Thanks! Luke > > On Wed, Jan 29, 2020 at 1:35 PM Luke Diamand <luke@diamand.org> wrote: > > > > On Tue, 7 Jan 2020 at 15:53, Ivan Selin <ivan.selin@toptal.com> wrote: > > > > > > Hello! > > > > > > If I create a perforce client from java using p4java, it gets created > > > with an extra key "ViewDepotType" in client definition. When I try to > > > do `git p4 sync --use-client-spec`, git-p4 dies with message like > > > "Expected view key View1 missing" — because it assumes that all keys > > > starting with "View" are "View0", "View1" and so on. > > > > > > How to reproduce: > > > 1) Create perforce repository; > > > 2) Create a perforce client (let's name it "my-client") in said > > > perforce repository using p4java; add one view mapping to the client > > > on creation; > > > 3) Run `P4CLIENT=my-client git p4 sync --use-client-spec`; > > > 4) git p4 finishes with error "Expected view key View1 missing". > > > > > > Attaching hexdumped/unmarshalled examples of "regular" client > > > definition and client created with p4java. Note that p4java's version > > > has "ViewDepotType" key and regular client does not. Also, > > > "ViewDepotType" key is not showing up in text output of `p4 client > > > -o`, only in binary format (`p4 -G client -o`). And I'm attaching a > > > patch that solved the issue for me. > > > > > > Is that information enough or should I add anything else? I'm new to > > > git community, but willing to help. > > > > I suspect the problem lies at around line 4220 of git-p4, where it does this: > > > > view_keys = [ k for k in entry.keys() if k.startswith("View") ] > > > > I think changing that startswith to a regex match would fix this, > > although I have not tried it. > > Something like: > > > > is_view = re.compile(r'^View\d+$') > > view_keys = [ k for k in entry.keys() if is_view.match(k) ] > > > > > > > > > > Regards, > > > Ivan.
Luke Diamand <luke@diamand.org> writes: > On Fri, 31 Jan 2020 at 13:43, Ivan Selin <ivan.selin@toptal.com> wrote: >> >> Yes, that's exactly the way that I've tried it and it worked for me. >> Can we have that integrated into git-p4? What can I do to make it >> happen? > > A patch would be very welcome! > > See Documentation/SubmittingPatches for details, but it's likely > enough to just make the change, and then use git format-patch and git > send-email. > > Please ensure you add a "Signed-off-by" (git commit -s). Thanks for helping. Another area a new person struggles is to propose a good commit log message. I'd expect this change to be explained something like this: Subject: git-p4: tighten detection of view names The current "git p4" code expects that all keys starting with "View" are view names (i.e. "View0", "View1", etc.), but a Perforce client created using p4java gets an extra key "ViewDepotType", which is not something we want to be treated as a view key. Tighten the filter of keys to accept only string "View" followed by nothing but digits. Helped-by: Luke Diamand <luke@diamand.org> Signed-off-by: ... Note that I am not a Perforce person, so the phrase "view names" I used in the above may totally be wrong as P4-lingo, in which case please replace them with what is acceptable by our Perforce friends ;-) Thanks. >> ... >> > is_view = re.compile(r'^View\d+$') >> > view_keys = [ k for k in entry.keys() if is_view.match(k) ]
git-p4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git git-p4.py git-p4.py index ca0a874501..1dc1588255 100755 --- git-p4.py +++ git-p4.py @@ -1108,8 +1108,8 @@ def getClientSpec(): # the //client/ name client_name = entry["Client"] - # just the keys that start with "View" - view_keys = [ k for k in entry.keys() if k.startswith("View") ] + # just the keys "View0", "View1", ... + view_keys = [ k for k in entry.keys() if re.match(r"View\d+", k) ] # hold this new View view = View(client_name)