From patchwork Tue Jan 7 15:53:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ivan Selin X-Patchwork-Id: 11321131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89A8D930 for ; Tue, 7 Jan 2020 15:53:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 507DE2077B for ; Tue, 7 Jan 2020 15:53:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toptal.com header.i=@toptal.com header.b="elJOIPr7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728156AbgAGPxS (ORCPT ); Tue, 7 Jan 2020 10:53:18 -0500 Received: from mail-ua1-f53.google.com ([209.85.222.53]:35074 "EHLO mail-ua1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbgAGPxS (ORCPT ); Tue, 7 Jan 2020 10:53:18 -0500 Received: by mail-ua1-f53.google.com with SMTP id y23so18658410ual.2 for ; Tue, 07 Jan 2020 07:53:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toptal.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=GLhamo8Qawso8cWV/0obfr8cYDhjNsr3H+icFaKltA4=; b=elJOIPr7+rXcqXzaUTAtloLZ9FNhbgjz5CL7LNtEqU3h+TycsWenC4MBBnSaONjn8a lm9Jn6nhop6nw4+YaKEvtyeXtW1KTM5zLe/Q5I20ScjPqAUnGJJP9SUG1B/RxXW4jU+Z 3uDiHsLBqQlrBdR650E/CiXn94zJtnSV1Dz2E1ljkq4/X6M8gBgk2x1wOrByRALkXk5m rZB/ojnPfSQ2RLdQrMBD06aM+VtQrijInlJlAhgswA+THWwjCe2V0Ch5fz/P4p8kZDvc MqY1kfe19EiRWilqYY3Ute4W0p4ly+LpMw1DVlH3cdAkgL8mc/Ay2GdDhupuFtKqckRA by6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=GLhamo8Qawso8cWV/0obfr8cYDhjNsr3H+icFaKltA4=; b=HkkOhpSXMMwqqtJdPWPeLLvfDY4yMQ0voeSRDaUbxH8zslnw5CrebO4ZoQYW22Qv6D pswm70CWhhAW7axtT2uXCH8YWN+U8iYDme7cSLurBjItcuR7R3CLJwunJSXwgRY707Cc PgZs95iLtjNATpft7cunuaADe7fYwSvGl79MXKwQcu2IbaM+mJPNxqXVwfq8D4q3qMTo 5t9Aj1cMh1VfFWvCeOjGWDMqrr80efpVaB8ed5SMQfQvs/PNpc+9vohZxVhoFxEMl26e 7jUbfeW6Hem5adj17djvw7kO4TvqZ9g4XWvrg/ji4jLcuEwMhLQwRKSjsdvbkqEpIOj+ eDMw== X-Gm-Message-State: APjAAAW4TlTDl2hLV/mhQIwiLqrWIZkaoC7MMS790zfvwsDnTRU4lcMK m1rAbLp53V1wgq5VNPvWI7S4qSKX0MM6ZexlcsHc1JUYmkk= X-Google-Smtp-Source: APXvYqwDBblshiztdwai9Kc3jIbEZ3kYEUMpDyp81h/Eqhl8noJ7Cuq3uttkJm6dFCm8dR9ARtK9EBdmVskAXOMokC0= X-Received: by 2002:ab0:1849:: with SMTP id j9mr29907099uag.77.1578412396207; Tue, 07 Jan 2020 07:53:16 -0800 (PST) MIME-Version: 1.0 From: Ivan Selin Date: Tue, 7 Jan 2020 18:53:04 +0300 Message-ID: Subject: =?utf-8?q?git-p4_cannot_use_perforce_client_created_by_p4java_?= =?utf-8?q?=E2=80=94_=22Expected_view_key_View1_missing=22?= To: git@vger.kernel.org Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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. Regards, Ivan. $ p4 -G client -o c-1 | hexdump -C 00000000 7b 73 04 00 00 00 63 6f 64 65 73 04 00 00 00 73 |{s....codes....s| 00000010 74 61 74 73 06 00 00 00 43 6c 69 65 6e 74 73 03 |tats....Clients.| 00000020 00 00 00 63 2d 31 73 06 00 00 00 55 70 64 61 74 |...c-1s....Updat| 00000030 65 73 13 00 00 00 32 30 32 30 2f 30 31 2f 30 35 |es....2020/01/05| 00000040 20 31 36 3a 34 35 3a 33 36 73 06 00 00 00 41 63 | 16:45:36s....Ac| 00000050 63 65 73 73 73 13 00 00 00 32 30 32 30 2f 30 31 |cesss....2020/01| 00000060 2f 30 35 20 31 36 3a 34 35 3a 33 36 73 04 00 00 |/05 16:45:36s...| 00000070 00 52 6f 6f 74 73 3e 00 00 00 2f 68 6f 6d 65 2f |.Roots>.../home/| 00000080 64 69 72 65 63 74 6f 72 79 2f 64 65 76 2f 66 72 |directory/dev/fr| 00000090 65 65 2f 67 69 74 2d 70 34 2f 70 34 2d 73 61 6d |ee/git-p4/p4-sam| 000000a0 70 6c 65 2d 72 65 70 6f 2f 64 69 72 65 63 74 2d |ple-repo/direct-| 000000b0 63 6d 64 2d 74 65 73 74 73 07 00 00 00 4f 70 74 |cmd-tests....Opt| 000000c0 69 6f 6e 73 73 3a 00 00 00 6e 6f 61 6c 6c 77 72 |ionss:...noallwr| 000000d0 69 74 65 20 6e 6f 63 6c 6f 62 62 65 72 20 6e 6f |ite noclobber no| 000000e0 63 6f 6d 70 72 65 73 73 20 75 6e 6c 6f 63 6b 65 |compress unlocke| 000000f0 64 20 6e 6f 6d 6f 64 74 69 6d 65 20 6e 6f 72 6d |d nomodtime norm| 00000100 64 69 72 73 0d 00 00 00 53 75 62 6d 69 74 4f 70 |dirs....SubmitOp| 00000110 74 69 6f 6e 73 73 0f 00 00 00 73 75 62 6d 69 74 |tionss....submit| 00000120 75 6e 63 68 61 6e 67 65 64 73 07 00 00 00 4c 69 |unchangeds....Li| 00000130 6e 65 45 6e 64 73 05 00 00 00 6c 6f 63 61 6c 73 |neEnds....locals| 00000140 05 00 00 00 56 69 65 77 30 73 15 00 00 00 2f 2f |....View0s....//| 00000150 64 65 70 6f 74 2f 2e 2e 2e 20 2f 2f 63 2d 31 2f |depot/... //c-1/| 00000160 2e 2e 2e 73 04 00 00 00 54 79 70 65 73 09 00 00 |...s....Types...| 00000170 00 77 72 69 74 65 61 62 6c 65 73 06 00 00 00 42 |.writeables....B| 00000180 61 63 6b 75 70 73 06 00 00 00 65 6e 61 62 6c 65 |ackups....enable| 00000190 30 |0| 00000191 $ p4 -G client -o c-1 | python -c 'import marshal, pprint, sys; pprint.pprint(marshal.load(sys.stdin))' {'Access': '2020/01/05 16:45:36', 'Backup': 'enable', 'Client': 'c-1', 'LineEnd': 'local', 'Options': 'noallwrite noclobber nocompress unlocked nomodtime normdir', 'Root': '/home/directory/dev/free/git-p4/p4-sample-repo/direct-cmd-test', 'SubmitOptions': 'submitunchanged', 'Type': 'writeable', 'Update': '2020/01/05 16:45:36', 'View0': '//depot/... //c-1/...', 'code': 'stat'} $ p4 -G client -o git-p4-sync-2 | hexdump -C 00000000 7b 73 04 00 00 00 63 6f 64 65 73 04 00 00 00 73 |{s....codes....s| 00000010 74 61 74 73 06 00 00 00 43 6c 69 65 6e 74 73 0d |tats....Clients.| 00000020 00 00 00 67 69 74 2d 70 34 2d 73 79 6e 63 2d 32 |...git-p4-sync-2| 00000030 73 06 00 00 00 55 70 64 61 74 65 73 13 00 00 00 |s....Updates....| 00000040 32 30 31 39 2f 31 32 2f 31 35 20 31 33 3a 34 39 |2019/12/15 13:49| 00000050 3a 35 31 73 06 00 00 00 41 63 63 65 73 73 73 13 |:51s....Accesss.| 00000060 00 00 00 32 30 31 39 2f 31 32 2f 31 35 20 31 33 |...2019/12/15 13| 00000070 3a 34 39 3a 35 31 73 05 00 00 00 4f 77 6e 65 72 |:49:51s....Owner| 00000080 73 02 00 00 00 73 61 73 04 00 00 00 52 6f 6f 74 |s....sas....Root| 00000090 73 52 00 00 00 2f 76 61 72 2f 61 74 6c 61 73 73 |sR.../var/atlass| 000000a0 69 61 6e 2f 61 70 70 6c 69 63 61 74 69 6f 6e 2d |ian/application-| 000000b0 64 61 74 61 2f 62 69 74 62 75 63 6b 65 74 2f 73 |data/bitbucket/s| 000000c0 68 61 72 65 64 2f 69 73 2d 67 69 74 2d 70 34 2f |hared/is-git-p4/| 000000d0 72 65 70 6f 73 69 74 6f 72 79 2f 72 65 70 6f 5f |repository/repo_| 000000e0 6c 6f 63 61 6c 5f 32 73 07 00 00 00 4f 70 74 69 |local_2s....Opti| 000000f0 6f 6e 73 73 3a 00 00 00 6e 6f 61 6c 6c 77 72 69 |onss:...noallwri| 00000100 74 65 20 6e 6f 63 6c 6f 62 62 65 72 20 6e 6f 63 |te noclobber noc| 00000110 6f 6d 70 72 65 73 73 20 75 6e 6c 6f 63 6b 65 64 |ompress unlocked| 00000120 20 6e 6f 6d 6f 64 74 69 6d 65 20 6e 6f 72 6d 64 | nomodtime normd| 00000130 69 72 73 0d 00 00 00 53 75 62 6d 69 74 4f 70 74 |irs....SubmitOpt| 00000140 69 6f 6e 73 73 0f 00 00 00 73 75 62 6d 69 74 75 |ionss....submitu| 00000150 6e 63 68 61 6e 67 65 64 73 07 00 00 00 4c 69 6e |nchangeds....Lin| 00000160 65 45 6e 64 73 05 00 00 00 6c 6f 63 61 6c 73 05 |eEnds....locals.| 00000170 00 00 00 56 69 65 77 30 73 1e 00 00 00 2f 2f 72 |...View0s....//r| 00000180 65 70 6f 2f 2e 2e 2e 20 2f 2f 67 69 74 2d 70 34 |epo/... //git-p4| 00000190 2d 73 79 6e 63 2d 32 2f 2e 2e 2e 73 04 00 00 00 |-sync-2/...s....| 000001a0 54 79 70 65 73 09 00 00 00 77 72 69 74 65 61 62 |Types....writeab| 000001b0 6c 65 73 06 00 00 00 42 61 63 6b 75 70 73 06 00 |les....Backups..| 000001c0 00 00 65 6e 61 62 6c 65 73 09 00 00 00 65 78 74 |..enables....ext| 000001d0 72 61 54 61 67 30 73 0d 00 00 00 56 69 65 77 44 |raTag0s....ViewD| 000001e0 65 70 6f 74 54 79 70 65 73 0d 00 00 00 65 78 74 |epotTypes....ext| 000001f0 72 61 54 61 67 54 79 70 65 30 73 04 00 00 00 77 |raTagType0s....w| 00000200 6f 72 64 73 0d 00 00 00 56 69 65 77 44 65 70 6f |ords....ViewDepo| 00000210 74 54 79 70 65 73 05 00 00 00 67 72 61 70 68 30 |tTypes....graph0| 00000220 $ p4 -G client -o git-p4-sync-2 | python -c 'import marshal, pprint, sys; pprint.pprint(marshal.load(sys.stdin))' {'Access': '2019/12/15 13:49:51', 'Backup': 'enable', 'Client': 'git-p4-sync-2', 'LineEnd': 'local', 'Options': 'noallwrite noclobber nocompress unlocked nomodtime normdir', 'Owner': 'sa', 'Root': '/var/atlassian/application-data/bitbucket/shared/is-git-p4/repository/repo_local_2', 'SubmitOptions': 'submitunchanged', 'Type': 'writeable', 'Update': '2019/12/15 13:49:51', 'View0': '//repo/... //git-p4-sync-2/...', 'ViewDepotType': 'graph', 'code': 'stat', 'extraTag0': 'ViewDepotType', 'extraTagType0': 'word'} 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)