(self, args)
| 4330 | return os.path.split(depotDir)[1] |
| 4331 | |
| 4332 | def run(self, args): |
| 4333 | if len(args) < 1: |
| 4334 | return False |
| 4335 | |
| 4336 | if self.keepRepoPath and not self.cloneDestination: |
| 4337 | sys.stderr.write("Must specify destination for --keep-path\n") |
| 4338 | sys.exit(1) |
| 4339 | |
| 4340 | depotPaths = args |
| 4341 | |
| 4342 | if not self.cloneDestination and len(depotPaths) > 1: |
| 4343 | self.cloneDestination = depotPaths[-1] |
| 4344 | depotPaths = depotPaths[:-1] |
| 4345 | |
| 4346 | for p in depotPaths: |
| 4347 | if not p.startswith("//"): |
| 4348 | sys.stderr.write('Depot paths must start with "//": %s\n' % p) |
| 4349 | return False |
| 4350 | |
| 4351 | if not self.cloneDestination: |
| 4352 | self.cloneDestination = self.defaultDestination(args) |
| 4353 | |
| 4354 | print("Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)) |
| 4355 | |
| 4356 | if not os.path.exists(self.cloneDestination): |
| 4357 | os.makedirs(self.cloneDestination) |
| 4358 | chdir(self.cloneDestination) |
| 4359 | |
| 4360 | init_cmd = ["git", "init"] |
| 4361 | if self.cloneBare: |
| 4362 | init_cmd.append("--bare") |
| 4363 | retcode = subprocess.call(init_cmd) |
| 4364 | if retcode: |
| 4365 | raise subprocess.CalledProcessError(retcode, init_cmd) |
| 4366 | |
| 4367 | if not P4Sync.run(self, depotPaths): |
| 4368 | return False |
| 4369 | |
| 4370 | # create a master branch and check out a work tree |
| 4371 | if gitBranchExists(self.branch): |
| 4372 | system(["git", "branch", currentGitBranch(), self.branch]) |
| 4373 | if not self.cloneBare: |
| 4374 | system(["git", "checkout", "-f"]) |
| 4375 | else: |
| 4376 | print('Not checking out any branch, use ' |
| 4377 | '"git checkout -q -b master <branch>"') |
| 4378 | |
| 4379 | # auto-set this variable if invoked with --use-client-spec |
| 4380 | if self.useClientSpec_from_options: |
| 4381 | system(["git", "config", "--bool", "git-p4.useclientspec", "true"]) |
| 4382 | |
| 4383 | # persist any git-p4 encoding-handling config options passed in for clone: |
| 4384 | if gitConfig('git-p4.metadataDecodingStrategy'): |
| 4385 | system(["git", "config", "git-p4.metadataDecodingStrategy", gitConfig('git-p4.metadataDecodingStrategy')]) |
| 4386 | if gitConfig('git-p4.metadataFallbackEncoding'): |
| 4387 | system(["git", "config", "git-p4.metadataFallbackEncoding", gitConfig('git-p4.metadataFallbackEncoding')]) |
| 4388 | if gitConfig('git-p4.pathEncoding'): |
| 4389 | system(["git", "config", "git-p4.pathEncoding", gitConfig('git-p4.pathEncoding')]) |
nothing calls this directly
no test coverage detected