git-p4: do not terminate creating tag for unknown commit
authorLuke Diamand <luke@diamand.org>
Thu, 27 Aug 2015 07:18:57 +0000 (08:18 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Aug 2015 19:02:56 +0000 (12:02 -0700)
If p4 reports a tag for a commit that git-p4 does not know
about (e.g. because it references a P4 changelist that was
imported prior to the point at which the repo was cloned into
git), make sure that the error is correctly caught and handled.
rather than just crashing.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py
index 073f87bbfdc1dc7ebc3fe610e78709667f597d82..a62611a9191cf6575953a53b0bc227b241f49471 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -2494,9 +2494,9 @@ def importP4Labels(self, stream, p4Labels):
                 # 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])
+                     "--reverse", ":/\[git-p4:.*change = %d\]" % changelist], ignore_error=True)
                 if len(gitCommit) == 0:
-                    print "could not find git commit for changelist %d" % changelist
+                    print "importing label %s: could not find git commit for changelist %d" % (name, changelist)
                 else:
                     gitCommit = gitCommit.strip()
                     commitFound = True