git-p4: add config to retry p4 commands; retry 3 times by default
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>
Lars Schneider committed
Dec 4, 2016 at 15:03 UTC
89a6ecc55b55ae87c39c5d9edb115731550fba95
2 files changed
+9
Documentation/git-p4.txt
+4
@@ -467,6 +467,10 @@ git-p4.client::
467
Client specified as an option to all p4 commands, with
468
'-c <client>', including the client spec.
469
470
+git-p4.retries::
471
+ Specifies the number of times to retry a p4 command (notably,
472
+ 'p4 sync') if the network times out. The default value is 3.
473
+
474
Clone and sync variables
475
~~~~~~~~~~~~~~~~~~~~~~~~
476
git-p4.syncFromOrigin::
git-p4.py
+5
@@ -78,6 +78,11 @@ def p4_build_cmd(cmd):
78
if len(client) > 0:
79
real_cmd += ["-c", client]
80
81
+ retries = gitConfigInt("git-p4.retries")
82
+ if retries is None:
83
+ # Perform 3 retries by default
84
+ retries = 3
85
+ real_cmd += ["-r", str(retries)]
86
87
if isinstance(cmd,basestring):
88
real_cmd = ' '.join(real_cmd) + ' ' + cmd