* [git-p4] import with labels fails when commit is not transferred
@ 2015-06-30 8:45 Holl, Marcus
2015-07-04 3:27 ` Luke Diamand
0 siblings, 1 reply; 3+ messages in thread
From: Holl, Marcus @ 2015-06-30 8:45 UTC (permalink / raw)
To: git@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 3831 bytes --]
Hi,
I have an issue with the git p4 tooling regarding import of labels.
My git version is 2.4.5
I try to transform a perforce repository. My command line is:
git p4 clone --verbose --detect-branches --import-local --import-labels --destination <DESTINATION> //depot@all
The relevant parts in the gitconfig is:
[git-p4]
branchUser = <USERNAME>
For that user there is a branch mapping defined with a lot of entries like:
//depot/trunk/... //depot/branches/ipro-status-8-2--branch/...
//depot/trunk/... //depot/branches/9-0-preview/...
//depot/trunk/... //depot/branches/release-8-0-0-branch/...
//depot/trunk/... //depot/branches/release-8-1-0-branch/...
//depot/trunk/... //depot/branches/release-8-2-0-branch/...
//depot/trunk/... //depot/branches/release-8-3-0-branch/...
//depot/trunk/... //depot/branches/release-8-4-branch/...
//depot/trunk/... //depot/branches/release-8-5-branch/...
...
The import fails with the log output that can be found at the bottom of this mail.
git log -all -grep "\[git-p4:.*change\ =\ 69035\]" reports nothing. The commit is not contained in the git repository.
p4 describe for changelist 69035 returns a reasonable result. This change contains one file located at a path in the perforce folder structure that comes without corresponding entry in the perforce branch mapping.
According to the given branch mapping it looks reasonable to me that the change is omitted in the git repository. But in my opinion the import should not fail in such a case.
A reasonable behavior would be to blacklist the label (add it to git-p4.ignoredP4Labels) and to continue with the next label.
Attached is a proposal for a fix that needs to be carefully reviews since I'm not that experienced with python.
Other proposals for resolving this issue are highly appreciated.
Thanks a lot and best regards,
Marcus Holl
Log output:
Reading pipe: ['git', 'rev-list', '--max-count=1', '--reverse', ':/\\[git-p4:.*change = 69035\\]']
fatal: ambiguous argument ':/\[git-p4:.*change = 69035\]': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
ied with change: 69078, original Date: 2010-04-22T09:07:24.000000Z\n', 'Update': '2013/11/02 07:40:31', 'Label': 'release-8-1-0-976', 'Access': '2015/06/26 14:50:15', 'Owner': 'svn_p4_converter', 'Options': 'unlocked noautoreload'}
p4 label release-8-1-0-976 mapped to git commit 82a11809928b86a7bde03cf486428de52ab3380f
writing tag release-9-0-0-179 for commit fb8370cd04806686c567ad720d065436f2334b4a
labelDetails= {'code': 'stat', 'Description': 'Created or modified with change: 96984, original Date: 2011-12-22T16:01:25.681427Z\n', 'Update': '2013/11/02 15:15:50', 'Label': 'release-9-0-0-179', 'Access': '2015/06/26 14:50:16', 'Owner': 'build', 'Options': 'unlocked noautoreload'}
p4 label release-9-0-0-179 mapped to git commit fb8370cd04806686c567ad720d065436f2334b4a
Traceback (most recent call last):
File "/usr/lib/git/git-p4", line 3297, in <module>
main()
File "/usr/lib/git/git-p4", line 3291, in main
if not cmd.run(args):
File "/usr/lib/git/git-p4", line 3165, in run
if not P4Sync.run(self, depotPaths):
File "/usr/lib/git/git-p4", line 3045, in run
self.importP4Labels(self.gitStream, missingP4Labels)
File "/usr/lib/git/git-p4", line 2421, in importP4Labels
"--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
File "/usr/lib/git/git-p4", line 138, in read_pipe
die('Command failed: %s' % str(c))
File "/usr/lib/git/git-p4", line 106, in die
raise Exception(msg)
Exception: Command failed: ['git', 'rev-list', '--max-count=1', '--reverse', ':/\\[git-p4:.*change = 69035\\]']
[-- Attachment #2: 0001-git-p4-Do-not-fail-on-not-found-commit-when-importin.patch --]
[-- Type: application/octet-stream, Size: 1552 bytes --]
From 4714fb23885278963db09aa3b7a426db1ebd5be4 Mon Sep 17 00:00:00 2001
From: Marcus Holl <marcus.holl@sap.com>
Date: Tue, 30 Jun 2015 10:10:12 +0200
Subject: [PATCH] [git-p4] Do not fail on not found commit when importing
labels
When a commit is not transferred from perforce to git since it is located
in the perforce folder layout in a place that does not match the branches
according to a given branch mapping the import fails.
With this change the corresponding label is added to git-p4.ignoredP4Labels
and it is continued with the next label.
---
git-p4.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 549022e..f3c8c6f 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2417,8 +2417,12 @@ class P4Sync(Command, P4UserMap):
if change.has_key('change'):
# find the corresponding git commit; take the oldest commit
changelist = int(change['change'])
- gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
- "--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
+ gitCommit = ""
+ try:
+ gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
+ "--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
+ except:
+ pass
if len(gitCommit) == 0:
print "could not find git commit for changelist %d" % changelist
else:
--
1.9.3 (Apple Git-50)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [git-p4] import with labels fails when commit is not transferred
2015-06-30 8:45 [git-p4] import with labels fails when commit is not transferred Holl, Marcus
@ 2015-07-04 3:27 ` Luke Diamand
2015-08-04 7:19 ` Luke Diamand
0 siblings, 1 reply; 3+ messages in thread
From: Luke Diamand @ 2015-07-04 3:27 UTC (permalink / raw)
To: Holl, Marcus, git@vger.kernel.org
Sorry for not replying earlier, and thanks for taking the time to
investigate this!
It's a pretty subtle corner case: I think a test case would be useful.
I'm going to try to put something together, unless you beat me to it!
(I think t9811-git-p4-label-import.sh is the one that needs extending).
Thanks!
Luke
On 30/06/15 09:45, Holl, Marcus wrote:
> Hi,
>
> I have an issue with the git p4 tooling regarding import of labels.
>
> My git version is 2.4.5
>
> I try to transform a perforce repository. My command line is:
> git p4 clone --verbose --detect-branches --import-local --import-labels --destination <DESTINATION> //depot@all
>
>
> The relevant parts in the gitconfig is:
> [git-p4]
> branchUser = <USERNAME>
>
>
> For that user there is a branch mapping defined with a lot of entries like:
> //depot/trunk/... //depot/branches/ipro-status-8-2--branch/...
> //depot/trunk/... //depot/branches/9-0-preview/...
> //depot/trunk/... //depot/branches/release-8-0-0-branch/...
> //depot/trunk/... //depot/branches/release-8-1-0-branch/...
> //depot/trunk/... //depot/branches/release-8-2-0-branch/...
> //depot/trunk/... //depot/branches/release-8-3-0-branch/...
> //depot/trunk/... //depot/branches/release-8-4-branch/...
> //depot/trunk/... //depot/branches/release-8-5-branch/...
> ...
>
>
> The import fails with the log output that can be found at the bottom of this mail.
>
> git log -all -grep "\[git-p4:.*change\ =\ 69035\]" reports nothing. The commit is not contained in the git repository.
>
> p4 describe for changelist 69035 returns a reasonable result. This change contains one file located at a path in the perforce folder structure that comes without corresponding entry in the perforce branch mapping.
>
> According to the given branch mapping it looks reasonable to me that the change is omitted in the git repository. But in my opinion the import should not fail in such a case.
>
> A reasonable behavior would be to blacklist the label (add it to git-p4.ignoredP4Labels) and to continue with the next label.
>
> Attached is a proposal for a fix that needs to be carefully reviews since I'm not that experienced with python.
>
> Other proposals for resolving this issue are highly appreciated.
>
> Thanks a lot and best regards,
> Marcus Holl
>
>
> Log output:
>
> Reading pipe: ['git', 'rev-list', '--max-count=1', '--reverse', ':/\\[git-p4:.*change = 69035\\]']
> fatal: ambiguous argument ':/\[git-p4:.*change = 69035\]': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'
> ied with change: 69078, original Date: 2010-04-22T09:07:24.000000Z\n', 'Update': '2013/11/02 07:40:31', 'Label': 'release-8-1-0-976', 'Access': '2015/06/26 14:50:15', 'Owner': 'svn_p4_converter', 'Options': 'unlocked noautoreload'}
> p4 label release-8-1-0-976 mapped to git commit 82a11809928b86a7bde03cf486428de52ab3380f
> writing tag release-9-0-0-179 for commit fb8370cd04806686c567ad720d065436f2334b4a
> labelDetails= {'code': 'stat', 'Description': 'Created or modified with change: 96984, original Date: 2011-12-22T16:01:25.681427Z\n', 'Update': '2013/11/02 15:15:50', 'Label': 'release-9-0-0-179', 'Access': '2015/06/26 14:50:16', 'Owner': 'build', 'Options': 'unlocked noautoreload'}
> p4 label release-9-0-0-179 mapped to git commit fb8370cd04806686c567ad720d065436f2334b4a
> Traceback (most recent call last):
> File "/usr/lib/git/git-p4", line 3297, in <module>
> main()
> File "/usr/lib/git/git-p4", line 3291, in main
> if not cmd.run(args):
> File "/usr/lib/git/git-p4", line 3165, in run
> if not P4Sync.run(self, depotPaths):
> File "/usr/lib/git/git-p4", line 3045, in run
> self.importP4Labels(self.gitStream, missingP4Labels)
> File "/usr/lib/git/git-p4", line 2421, in importP4Labels
> "--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
> File "/usr/lib/git/git-p4", line 138, in read_pipe
> die('Command failed: %s' % str(c))
> File "/usr/lib/git/git-p4", line 106, in die
> raise Exception(msg)
> Exception: Command failed: ['git', 'rev-list', '--max-count=1', '--reverse', ':/\\[git-p4:.*change = 69035\\]']
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [git-p4] import with labels fails when commit is not transferred
2015-07-04 3:27 ` Luke Diamand
@ 2015-08-04 7:19 ` Luke Diamand
0 siblings, 0 replies; 3+ messages in thread
From: Luke Diamand @ 2015-08-04 7:19 UTC (permalink / raw)
To: Holl, Marcus, git@vger.kernel.org
On 04/07/15 04:27, Luke Diamand wrote:
> Sorry for not replying earlier, and thanks for taking the time to
> investigate this!
>
> It's a pretty subtle corner case: I think a test case would be useful.
> I'm going to try to put something together, unless you beat me to it!
>
> (I think t9811-git-p4-label-import.sh is the one that needs extending).
I've been looking into this a bit more, and I think that you don't need
a try/except - it's enough just to add "ignore_error=True" to the call
to read_lines.
It also looks like this is a general problem of importing a label where
the revision doesn't exist in git. For example, if you create a p4
label, then clone at the revision after that, you will get the problem.
I've got a test case and a modified git-p4.py, but I haven't yet got to
the point where I'm convinced it works. I think the fix is pretty much
what you've shown (replacing try-except with ignore_error) but I'd like
my test case to be a bit more convincing.
Thanks!
Luke
>
> On 30/06/15 09:45, Holl, Marcus wrote:
>> Hi,
>>
>> I have an issue with the git p4 tooling regarding import of labels.
>>
>> My git version is 2.4.5
>>
>> I try to transform a perforce repository. My command line is:
>> git p4 clone --verbose --detect-branches --import-local
>> --import-labels --destination <DESTINATION> //depot@all
>>
>>
>> The relevant parts in the gitconfig is:
>> [git-p4]
>> branchUser = <USERNAME>
>>
>>
>> For that user there is a branch mapping defined with a lot of entries
>> like:
>> //depot/trunk/... //depot/branches/ipro-status-8-2--branch/...
>> //depot/trunk/... //depot/branches/9-0-preview/...
>> //depot/trunk/... //depot/branches/release-8-0-0-branch/...
>> //depot/trunk/... //depot/branches/release-8-1-0-branch/...
>> //depot/trunk/... //depot/branches/release-8-2-0-branch/...
>> //depot/trunk/... //depot/branches/release-8-3-0-branch/...
>> //depot/trunk/... //depot/branches/release-8-4-branch/...
>> //depot/trunk/... //depot/branches/release-8-5-branch/...
>> ...
>>
>>
>> The import fails with the log output that can be found at the bottom
>> of this mail.
>>
>> git log -all -grep "\[git-p4:.*change\ =\ 69035\]" reports nothing.
>> The commit is not contained in the git repository.
>>
>> p4 describe for changelist 69035 returns a reasonable result. This
>> change contains one file located at a path in the perforce folder
>> structure that comes without corresponding entry in the perforce
>> branch mapping.
>>
>> According to the given branch mapping it looks reasonable to me that
>> the change is omitted in the git repository. But in my opinion the
>> import should not fail in such a case.
>>
>> A reasonable behavior would be to blacklist the label (add it to
>> git-p4.ignoredP4Labels) and to continue with the next label.
>>
>> Attached is a proposal for a fix that needs to be carefully reviews
>> since I'm not that experienced with python.
>>
>> Other proposals for resolving this issue are highly appreciated.
>>
>> Thanks a lot and best regards,
>> Marcus Holl
>>
>>
>> Log output:
>>
>> Reading pipe: ['git', 'rev-list', '--max-count=1', '--reverse',
>> ':/\\[git-p4:.*change = 69035\\]']
>> fatal: ambiguous argument ':/\[git-p4:.*change = 69035\]': unknown
>> revision or path not in the working tree.
>> Use '--' to separate paths from revisions, like this:
>> 'git <command> [<revision>...] -- [<file>...]'
>> ied with change: 69078, original Date: 2010-04-22T09:07:24.000000Z\n',
>> 'Update': '2013/11/02 07:40:31', 'Label': 'release-8-1-0-976',
>> 'Access': '2015/06/26 14:50:15', 'Owner': 'svn_p4_converter',
>> 'Options': 'unlocked noautoreload'}
>> p4 label release-8-1-0-976 mapped to git commit
>> 82a11809928b86a7bde03cf486428de52ab3380f
>> writing tag release-9-0-0-179 for commit
>> fb8370cd04806686c567ad720d065436f2334b4a
>> labelDetails= {'code': 'stat', 'Description': 'Created or modified
>> with change: 96984, original Date: 2011-12-22T16:01:25.681427Z\n',
>> 'Update': '2013/11/02 15:15:50', 'Label': 'release-9-0-0-179',
>> 'Access': '2015/06/26 14:50:16', 'Owner': 'build', 'Options':
>> 'unlocked noautoreload'}
>> p4 label release-9-0-0-179 mapped to git commit
>> fb8370cd04806686c567ad720d065436f2334b4a
>> Traceback (most recent call last):
>> File "/usr/lib/git/git-p4", line 3297, in <module>
>> main()
>> File "/usr/lib/git/git-p4", line 3291, in main
>> if not cmd.run(args):
>> File "/usr/lib/git/git-p4", line 3165, in run
>> if not P4Sync.run(self, depotPaths):
>> File "/usr/lib/git/git-p4", line 3045, in run
>> self.importP4Labels(self.gitStream, missingP4Labels)
>> File "/usr/lib/git/git-p4", line 2421, in importP4Labels
>> "--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
>> File "/usr/lib/git/git-p4", line 138, in read_pipe
>> die('Command failed: %s' % str(c))
>> File "/usr/lib/git/git-p4", line 106, in die
>> raise Exception(msg)
>> Exception: Command failed: ['git', 'rev-list', '--max-count=1',
>> '--reverse', ':/\\[git-p4:.*change = 69035\\]']
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-04 7:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-30 8:45 [git-p4] import with labels fails when commit is not transferred Holl, Marcus
2015-07-04 3:27 ` Luke Diamand
2015-08-04 7:19 ` Luke Diamand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).