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.
(cmd)
| 95 | |
| 96 | |
| 97 | def p4_build_cmd(cmd): |
| 98 | """Build a suitable p4 command line. |
| 99 | |
| 100 | This consolidates building and returning a p4 command line into one |
| 101 | location. It means that hooking into the environment, or other |
| 102 | configuration can be done more easily. |
| 103 | """ |
| 104 | real_cmd = ["p4"] |
| 105 | |
| 106 | user = gitConfig("git-p4.user") |
| 107 | if len(user) > 0: |
| 108 | real_cmd += ["-u", user] |
| 109 | |
| 110 | password = gitConfig("git-p4.password") |
| 111 | if len(password) > 0: |
| 112 | real_cmd += ["-P", password] |
| 113 | |
| 114 | port = gitConfig("git-p4.port") |
| 115 | if len(port) > 0: |
| 116 | real_cmd += ["-p", port] |
| 117 | |
| 118 | host = gitConfig("git-p4.host") |
| 119 | if len(host) > 0: |
| 120 | real_cmd += ["-H", host] |
| 121 | |
| 122 | client = gitConfig("git-p4.client") |
| 123 | if len(client) > 0: |
| 124 | real_cmd += ["-c", client] |
| 125 | |
| 126 | retries = gitConfigInt("git-p4.retries") |
| 127 | if retries is None: |
| 128 | # Perform 3 retries by default |
| 129 | retries = 3 |
| 130 | if retries > 0: |
| 131 | # Provide a way to not pass this option by setting git-p4.retries to 0 |
| 132 | real_cmd += ["-r", str(retries)] |
| 133 | |
| 134 | real_cmd += cmd |
| 135 | |
| 136 | # now check that we can actually talk to the server |
| 137 | global p4_access_checked |
| 138 | if not p4_access_checked: |
| 139 | p4_access_checked = True # suppress access checks in p4_check_access itself |
| 140 | p4_check_access() |
| 141 | |
| 142 | return real_cmd |
| 143 | |
| 144 | |
| 145 | def git_dir(path): |
no test coverage detected