summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorPete Wyckoff <pw@padd.com>2012-11-23 17:35:35 -0500
committerJunio C Hamano <gitster@pobox.com>2012-11-26 10:59:57 -0800
commit249da4c0dcd0534f416e2d5da0a9923c6068e492 (patch)
treea77889108234d68a49ab7b55df201a7dd8e981ce /git-p4.py
parent18fa13d0b34b6243d3679ea78325ee33ee4d0989 (diff)
downloadgit-249da4c0dcd0534f416e2d5da0a9923c6068e492.tar.gz
git p4: handle servers without move support
Support for the "p4 move" command was added in 8e9497c (git p4: add support for 'p4 move' in P4Submit, 2012-07-12), which checks to make sure that the client and server support the command. But older versions of p4d may not handle the "-k" argument, and newer p4d allow disabling "p4 move" with a configuration setting. Check for both these cases by testing a p4 move command on bogus filenames and looking for strings in the error messages. Reported-by: Vitor Antunes <vitor.hda@gmail.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/git-p4.py b/git-p4.py
index cd68e04a45..9644c9f879 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -129,6 +129,25 @@ def p4_has_command(cmd):
p.communicate()
return p.returncode == 0
+def p4_has_move_command():
+ """See if the move command exists, that it supports -k, and that
+ it has not been administratively disabled. The arguments
+ must be correct, but the filenames do not have to exist. Use
+ ones with wildcards so even if they exist, it will fail."""
+
+ if not p4_has_command("move"):
+ return False
+ cmd = p4_build_cmd(["move", "-k", "@from", "@to"])
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (out, err) = p.communicate()
+ # return code will be 1 in either case
+ if err.find("Invalid option") >= 0:
+ return False
+ if err.find("disabled") >= 0:
+ return False
+ # assume it failed because @... was invalid changelist
+ return True
+
def system(cmd):
expand = isinstance(cmd,basestring)
if verbose:
@@ -894,7 +913,7 @@ class P4Submit(Command, P4UserMap):
self.conflict_behavior = None
self.isWindows = (platform.system() == "Windows")
self.exportLabels = False
- self.p4HasMoveCommand = p4_has_command("move")
+ self.p4HasMoveCommand = p4_has_move_command()
def check(self):
if len(p4CmdList("opened ...")) > 0: