From: Junio C Hamano Date: Sun, 17 Aug 2008 17:53:57 +0000 (-0700) Subject: Merge branch 'ak/p4' X-Git-Tag: v1.6.0~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a1975c4feaa5e9a45beb7aad22b4a0cca44dcbb8;p=git.git Merge branch 'ak/p4' * ak/p4: Utilise our new p4_read_pipe and p4_write_pipe wrappers Add p4 read_pipe and write_pipe wrappers Put in the two other configuration elements found in the source Put some documentation in about the parameters that have been added Move git-p4.syncFromOrigin into a configuration parameters section Consistently use 'git-p4' for the configuration entries If the user has configured various parameters, use them. Switch to using 'p4_build_cmd' If we are in verbose mode, output what we are about to run (or return) Add a single command that will be used to construct the 'p4' command Utilise the new 'p4_system' function. Have a command that specifically invokes 'p4' (via system) Utilise the new 'p4_read_pipe_lines' command Create a specific version of the read_pipe_lines command for p4 invocations Conflicts: contrib/fast-import/git-p4 --- a1975c4feaa5e9a45beb7aad22b4a0cca44dcbb8 diff --cc contrib/fast-import/git-p4 index 3f2303dcf,12fa9d3fd..f9865b444 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@@ -16,11 -16,41 +16,46 @@@ from sets import Set verbose = False + + def p4_build_cmd(cmd): + """Build a suitable p4 command line. + + This consolidates building and returning a p4 command line into one + location. It means that hooking into the environment, or other configuration + can be done more easily. + """ + real_cmd = "%s " % "p4" + + user = gitConfig("git-p4.user") + if len(user) > 0: + real_cmd += "-u %s " % user + + password = gitConfig("git-p4.password") + if len(password) > 0: + real_cmd += "-P %s " % password + + port = gitConfig("git-p4.port") + if len(port) > 0: + real_cmd += "-p %s " % port + + host = gitConfig("git-p4.host") + if len(host) > 0: + real_cmd += "-h %s " % host + + client = gitConfig("git-p4.client") + if len(client) > 0: + real_cmd += "-c %s " % client + + real_cmd += "%s" % (cmd) + if verbose: + print real_cmd + return real_cmd + +def chdir(dir): + if os.name == 'nt': + os.environ['PWD']=dir + os.chdir(dir) + def die(msg): if verbose: raise Exception(msg) @@@ -717,9 -764,9 +769,9 @@@ class P4Submit(Command) print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath) self.oldWorkingDirectory = os.getcwd() - os.chdir(self.clientPath) + chdir(self.clientPath) print "Syncronizing p4 checkout..." - system("p4 sync ...") + p4_system("sync ...") self.check()