git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv1 2/6] git-p4: add P4CommandException to report errors talking to Perforce

From
Luke Diamand <luke@diamand.org>
Date
Jan 29, 2020, 11:12 UTC
Message-ID
<20200129111246.12196-3-luke@diamand.org>
In-Reply-To
<20200129111246.12196-2-luke@diamand.org>
Currently when there is a P4 error, git-p4 calls die() which just exits.

This then leaves the git-fast-import process still running, and can even leave p4 itself still running.

As a result, git-p4 fails to exit cleanly. This is a particular problem for people running the unit tests in regression.

Use this exception to report errors upwards, cleaning up as the error propagates.

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 git-p4.py | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/git-p4.py b/git-p4.py
index 23724defe8..df2a956622 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -618,6 +618,14 @@ def __init__(self, exit_code, p4_result, limit):
         super(P4RequestSizeException, self).__init__(exit_code, p4_result)
         self.limit = limit
 
+class P4CommandException(P4Exception):
+    """ Something went wrong calling p4 which means we have to give up """
+    def __init__(self, msg):
+        self.msg = msg
+
+    def __str__(self):
+        return self.msg
+
 def isModeExecChanged(src_mode, dst_mode):
     return isModeExec(src_mode) != isModeExec(dst_mode)
 
-- 
2.20.1.390.gb5101f9297
Previous: Luke DiamandNext: Luke Diamand
Message 3 of 13 in “[PATCHv1 0/6] git-p4: wait() for child processes better”
  1. Luke DiamandJan 29, 2020
  2. 1/6 git-p4: make closeStreams() idempotentLuke Diamand, Jan 29, 2020
  3. 2/6 git-p4: add P4CommandException to report errors talking to PerforceLuke Diamand, Jan 29, 2020
  4. 3/6 git-p4: disable some pylint warnings, to get pylint output to something manageableLuke Diamand, Jan 29, 2020
  5. 4/6 git-p4: create helper function importRevisions()Luke Diamand, Jan 29, 2020
  6. 5/6 git-p4: cleanup better on error exitLuke Diamand, Jan 29, 2020
  7. 6/6 git-p4: check for access to remote host earlierLuke Diamand, Jan 29, 2020
  8. Eric SunshineJan 29, 2020
  9. Luke DiamandJan 29, 2020
  10. Junio C HamanoJan 30, 2020
  11. Luke DiamandJan 31, 2020
  12. Johannes SchindelinJan 30, 2020
  13. Luke DiamandJan 30, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.