Skip to content

Commit

Permalink
git-p4: Removed git-p4 submit --direct.
Browse files Browse the repository at this point in the history
This feature was originally meant to allow for quicker direct submits into perforce, but
it turns out that it is not actually quicker than doing a git commit and then running
git-p4 submit.

Signed-off-by: Simon Hausmann <simon@lst.de>
  • Loading branch information
Simon Hausmann committed Feb 27, 2008
1 parent edae1e2 commit 0e36f2d
Showing 1 changed file with 11 additions and 45 deletions.
56 changes: 11 additions & 45 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ class P4Submit(Command):
optparse.make_option("--verbose", dest="verbose", action="store_true"),
optparse.make_option("--origin", dest="origin"),
optparse.make_option("--reset", action="store_true", dest="reset"),
optparse.make_option("--direct", dest="directSubmit", action="store_true"),
optparse.make_option("-M", dest="detectRename", action="store_true"),
]
self.description = "Submit changes from git to the perforce depot."
Expand All @@ -478,7 +477,6 @@ class P4Submit(Command):
self.interactive = True
self.firstTime = True
self.origin = ""
self.directSubmit = False
self.detectRename = False
self.verbose = False
self.isWindows = (platform.system() == "Windows")
Expand All @@ -494,12 +492,9 @@ class P4Submit(Command):
"maybe you want to call git-p4 submit --reset" % self.configFile)

commits = []
if self.directSubmit:
commits.append("0")
else:
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
commits.append(line.strip())
commits.reverse()
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
commits.append(line.strip())
commits.reverse()

self.config["commits"] = commits

Expand Down Expand Up @@ -556,13 +551,9 @@ class P4Submit(Command):
return template

def applyCommit(self, id):
if self.directSubmit:
print "Applying local change in working directory/index"
diff = self.diffStatus
else:
print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
diffOpts = ("", "-M")[self.detectRename]
diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
diffOpts = ("", "-M")[self.detectRename]
diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
filesToAdd = set()
filesToDelete = set()
editedFiles = set()
Expand Down Expand Up @@ -597,10 +588,7 @@ class P4Submit(Command):
else:
die("unknown modifier %s for %s" % (modifier, path))

if self.directSubmit:
diffcmd = "cat \"%s\"" % self.diffFile
else:
diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
patchcmd = diffcmd + " | git apply "
tryPatchCmd = patchcmd + "--check -"
applyPatchCmd = patchcmd + "--check --apply -"
Expand Down Expand Up @@ -648,12 +636,10 @@ class P4Submit(Command):
mode = filesToChangeExecBit[f]
setP4ExecBit(f, mode)

logMessage = ""
if not self.directSubmit:
logMessage = extractLogMessageFromGitCommit(id)
if self.isWindows:
logMessage = logMessage.replace("\n", "\r\n")
logMessage = logMessage.strip()
logMessage = extractLogMessageFromGitCommit(id)
if self.isWindows:
logMessage = logMessage.replace("\n", "\r\n")
logMessage = logMessage.strip()

template = self.prepareSubmitTemplate()

Expand Down Expand Up @@ -692,12 +678,6 @@ class P4Submit(Command):
if self.isWindows:
submitTemplate = submitTemplate.replace("\r\n", "\n")

if self.directSubmit:
print "Submitting to git first"
os.chdir(self.oldWorkingDirectory)
write_pipe("git commit -a -F -", submitTemplate)
os.chdir(self.clientPath)

write_pipe("p4 submit -i", submitTemplate)
else:
fileName = "submit.txt"
Expand Down Expand Up @@ -739,17 +719,6 @@ class P4Submit(Command):
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
self.oldWorkingDirectory = os.getcwd()

if self.directSubmit:
self.diffStatus = read_pipe_lines("git diff -r --name-status HEAD")
if len(self.diffStatus) == 0:
print "No changes in working directory to submit."
return True
patch = read_pipe("git diff -p --binary --diff-filter=ACMRTUXB HEAD")
self.diffFile = self.gitdir + "/p4-git-diff"
f = open(self.diffFile, "wb")
f.write(patch)
f.close();

os.chdir(self.clientPath)
print "Syncronizing p4 checkout..."
system("p4 sync ...")
Expand Down Expand Up @@ -777,9 +746,6 @@ class P4Submit(Command):

self.config.close()

if self.directSubmit:
os.remove(self.diffFile)

if len(commits) == 0:
if self.firstTime:
print "No changes found to apply between %s and current HEAD" % self.origin
Expand Down

0 comments on commit 0e36f2d

Please sign in to comment.