Skip to content

Commit 55702c5

Browse files
alrashedfgitster
authored andcommitted
git-p4: show Perforce error to the user
During "git p4 clone" if p4 process returns an error from the server, it will store the message in the 'err' variable. Then it will send a text command "die-now" to git-fast-import. However, git-fast-import raises an exception: "fatal: Unsupported command: die-now" and err is never displayed. This patch ensures that err is shown to the end user. Signed-off-by: Fahad Alrashed <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 786a3e4 commit 55702c5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

git-p4.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,17 +3253,19 @@ def streamP4FilesCb(self, marshalled):
32533253
if self.stream_have_file_info:
32543254
if "depotFile" in self.stream_file:
32553255
f = self.stream_file["depotFile"]
3256-
# force a failure in fast-import, else an empty
3257-
# commit will be made
3258-
self.gitStream.write("\n")
3259-
self.gitStream.write("die-now\n")
3260-
self.gitStream.close()
3261-
# ignore errors, but make sure it exits first
3262-
self.importProcess.wait()
3263-
if f:
3264-
die("Error from p4 print for %s: %s" % (f, err))
3265-
else:
3266-
die("Error from p4 print: %s" % err)
3256+
try:
3257+
# force a failure in fast-import, else an empty
3258+
# commit will be made
3259+
self.gitStream.write("\n")
3260+
self.gitStream.write("die-now\n")
3261+
self.gitStream.close()
3262+
# ignore errors, but make sure it exits first
3263+
self.importProcess.wait()
3264+
finally:
3265+
if f:
3266+
die("Error from p4 print for %s: %s" % (f, err))
3267+
else:
3268+
die("Error from p4 print: %s" % err)
32673269

32683270
if 'depotFile' in marshalled and self.stream_have_file_info:
32693271
# start of a new file - output the old one first

0 commit comments

Comments
 (0)