]> granicus.if.org Git - git/commitdiff
git-p4: add config to retry p4 commands; retry 3 times by default
authorLars Schneider <larsxschneider@gmail.com>
Sun, 4 Dec 2016 14:03:11 +0000 (15:03 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Dec 2016 22:55:32 +0000 (14:55 -0800)
P4 commands can fail due to random network issues. P4 users can counter
these issues by using a retry flag supported by all p4 commands [1].

Add an integer Git config value `git-p4.retries` to define the number of
retries for all p4 invocations. If the config is not defined then set
the default retry count to 3.

[1] https://www.perforce.com/perforce/doc.current/manuals/cmdref/global.options.html

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-p4.txt
git-p4.py

index c83aaf39c33505ead72d523f278620fcc6f8f757..656587248cc466143589742b093ae8cb43030263 100644 (file)
@@ -467,6 +467,10 @@ git-p4.client::
        Client specified as an option to all p4 commands, with
        '-c <client>', including the client spec.
 
+git-p4.retries::
+       Specifies the number of times to retry a p4 command (notably,
+       'p4 sync') if the network times out. The default value is 3.
+
 Clone and sync variables
 ~~~~~~~~~~~~~~~~~~~~~~~~
 git-p4.syncFromOrigin::
index fd5ca524626c40823371422e52a3457fd1d45579..2422178210f344131a783edd3c1d5acbd0229512 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -78,6 +78,11 @@ def p4_build_cmd(cmd):
     if len(client) > 0:
         real_cmd += ["-c", client]
 
+    retries = gitConfigInt("git-p4.retries")
+    if retries is None:
+        # Perform 3 retries by default
+        retries = 3
+    real_cmd += ["-r", str(retries)]
 
     if isinstance(cmd,basestring):
         real_cmd = ' '.join(real_cmd) + ' ' + cmd