Skip to content

Commit

Permalink
Merge branch 'pw/p4-docs-and-tests'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Jan 3, 2012
2 parents 228c341 + 28755db commit 4570aeb
Show file tree
Hide file tree
Showing 10 changed files with 830 additions and 343 deletions.
479 changes: 479 additions & 0 deletions Documentation/git-p4.txt

Large diffs are not rendered by default.

32 changes: 29 additions & 3 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ def isValidGitDir(path):
def parseRevision(ref):
return read_pipe("git rev-parse %s" % ref).strip()

def branchExists(ref):
rev = read_pipe(["git", "rev-parse", "-q", "--verify", ref],
ignore_error=True)
return len(rev) > 0

def extractLogMessageFromGitCommit(commit):
logMessage = ""

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

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

if self.useClientSpec or gitConfig("git-p4.useclientspec") == "true":
if not self.useClientSpec:
if gitConfig("git-p4.useclientspec", "--bool") == "true":
self.useClientSpec = True
if self.useClientSpec:
self.getClientSpec()

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

# Make sure no revision specifiers are used when --changesfile
# is specified.
bad_changesfile = False
if len(self.changesFile) > 0:
for p in self.depotPaths:
if p.find("@") >= 0 or p.find("#") >= 0:
bad_changesfile = True
break
if bad_changesfile:
die("Option --changesfile is incompatible with revision specifiers")

newPaths = []
for p in self.depotPaths:
if p.find("@") != -1:
Expand All @@ -2040,7 +2061,10 @@ class P4Sync(Command, P4UserMap):
revision = p[hashIdx:]
p = p[:hashIdx]
elif self.previousDepotPaths == []:
revision = "#head"
# pay attention to changesfile, if given, else import
# the entire p4 tree at the head revision
if len(self.changesFile) == 0:
revision = "#head"

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

if len(options) > 0:
options.append(optparse.make_option("--git-dir", dest="gitdir"))
if cmd.needsGit:
options.append(optparse.make_option("--git-dir", dest="gitdir"))

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

if not cmd.run(args):
parser.print_help()
sys.exit(2)


if __name__ == '__main__':
Expand Down
302 changes: 0 additions & 302 deletions contrib/fast-import/git-p4.txt

This file was deleted.

Loading

0 comments on commit 4570aeb

Please sign in to comment.