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 <fahad@keylock.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Fahad Alrashed 2024-05-08 22:11:05 +00:00 committed by Junio C Hamano
parent 786a3e4b8d
commit 55702c543e

View File

@ -3253,6 +3253,7 @@ class P4Sync(Command, P4UserMap):
if self.stream_have_file_info:
if "depotFile" in self.stream_file:
f = self.stream_file["depotFile"]
try:
# force a failure in fast-import, else an empty
# commit will be made
self.gitStream.write("\n")
@ -3260,6 +3261,7 @@ class P4Sync(Command, P4UserMap):
self.gitStream.close()
# ignore errors, but make sure it exits first
self.importProcess.wait()
finally:
if f:
die("Error from p4 print for %s: %s" % (f, err))
else: