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)

