Merge branch 'ls/p4-retry-thrice'
authorJunio C Hamano <gitster@pobox.com>
Fri, 16 Dec 2016 23:27:50 +0000 (15:27 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Dec 2016 23:27:50 +0000 (15:27 -0800)
* ls/p4-retry-thrice:
git-p4: add config to retry p4 commands; retry 3 times by default

Documentation/git-p4.txt
git-p4.py
index ce40b9a5475307e0d3aad90b4ce6fee26485fab2..bae862ddcb9fe85765ea5bb126ced4fad8e98268 100644 (file)
@@ -476,6 +476,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 1d4bfe64e298849f37e3a13b138a2f6f2c2b27e7..13bf44768b352c2cd5b34e718bdc7aaef7d6014d 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