Skip to content

Commit 4570aeb

Browse files
committed
Merge branch 'pw/p4-docs-and-tests'
* pw/p4-docs-and-tests: git-p4: document and test submit options git-p4: test and document --use-client-spec git-p4: test --keep-path git-p4: test --max-changes git-p4: document and test --import-local git-p4: honor --changesfile option and test git-p4: document and test clone --branch git-p4: test cloning with two dirs, clarify doc git-p4: clone does not use --git-dir git-p4: introduce asciidoc documentation rename git-p4 tests
2 parents 228c341 + 28755db commit 4570aeb

10 files changed

+830
-343
lines changed

Documentation/git-p4.txt

Lines changed: 479 additions & 0 deletions
Large diffs are not rendered by default.

contrib/fast-import/git-p4

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ def isValidGitDir(path):
362362
def parseRevision(ref):
363363
return read_pipe("git rev-parse %s" % ref).strip()
364364

365+
def branchExists(ref):
366+
rev = read_pipe(["git", "rev-parse", "-q", "--verify", ref],
367+
ignore_error=True)
368+
return len(rev) > 0
369+
365370
def extractLogMessageFromGitCommit(commit):
366371
logMessage = ""
367372

@@ -1089,6 +1094,8 @@ class P4Submit(Command, P4UserMap):
10891094
die("Detecting current git branch failed!")
10901095
elif len(args) == 1:
10911096
self.master = args[0]
1097+
if not branchExists(self.master):
1098+
die("Branch %s does not exist" % self.master)
10921099
else:
10931100
return False
10941101

@@ -1951,7 +1958,10 @@ class P4Sync(Command, P4UserMap):
19511958
if not gitBranchExists(self.refPrefix + "HEAD") and self.importIntoRemotes and gitBranchExists(self.branch):
19521959
system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
19531960

1954-
if self.useClientSpec or gitConfig("git-p4.useclientspec") == "true":
1961+
if not self.useClientSpec:
1962+
if gitConfig("git-p4.useclientspec", "--bool") == "true":
1963+
self.useClientSpec = True
1964+
if self.useClientSpec:
19551965
self.getClientSpec()
19561966

19571967
# TODO: should always look at previous commits,
@@ -2024,6 +2034,17 @@ class P4Sync(Command, P4UserMap):
20242034
revision = ""
20252035
self.users = {}
20262036

2037+
# Make sure no revision specifiers are used when --changesfile
2038+
# is specified.
2039+
bad_changesfile = False
2040+
if len(self.changesFile) > 0:
2041+
for p in self.depotPaths:
2042+
if p.find("@") >= 0 or p.find("#") >= 0:
2043+
bad_changesfile = True
2044+
break
2045+
if bad_changesfile:
2046+
die("Option --changesfile is incompatible with revision specifiers")
2047+
20272048
newPaths = []
20282049
for p in self.depotPaths:
20292050
if p.find("@") != -1:
@@ -2040,7 +2061,10 @@ class P4Sync(Command, P4UserMap):
20402061
revision = p[hashIdx:]
20412062
p = p[:hashIdx]
20422063
elif self.previousDepotPaths == []:
2043-
revision = "#head"
2064+
# pay attention to changesfile, if given, else import
2065+
# the entire p4 tree at the head revision
2066+
if len(self.changesFile) == 0:
2067+
revision = "#head"
20442068

20452069
p = re.sub ("\.\.\.$", "", p)
20462070
if not p.endswith("/"):
@@ -2335,7 +2359,8 @@ def main():
23352359
args = sys.argv[2:]
23362360

23372361
if len(options) > 0:
2338-
options.append(optparse.make_option("--git-dir", dest="gitdir"))
2362+
if cmd.needsGit:
2363+
options.append(optparse.make_option("--git-dir", dest="gitdir"))
23392364

23402365
parser = optparse.OptionParser(cmd.usage.replace("%prog", "%prog " + cmdName),
23412366
options,
@@ -2365,6 +2390,7 @@ def main():
23652390

23662391
if not cmd.run(args):
23672392
parser.print_help()
2393+
sys.exit(2)
23682394

23692395

23702396
if __name__ == '__main__':

contrib/fast-import/git-p4.txt

Lines changed: 0 additions & 302 deletions
This file was deleted.

0 commit comments

Comments
 (0)