summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: edae1e2)
raw | patch | inline | side by side (parent: edae1e2)
author | Simon Hausmann <simon@lst.de> | |
Tue, 19 Feb 2008 08:33:08 +0000 (09:33 +0100) | ||
committer | Simon Hausmann <simon@lst.de> | |
Wed, 27 Feb 2008 15:27:07 +0000 (16:27 +0100) |
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>
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>
contrib/fast-import/git-p4 | patch | blob | history |
index e55a41b10ed3fd7f93a9c5b60870dc5dc837177c..087f4229a030d3b2f7a1645d9906d44215b0ee4e 100755 (executable)
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."
self.interactive = True
self.firstTime = True
self.origin = ""
- self.directSubmit = False
self.detectRename = False
self.verbose = False
self.isWindows = (platform.system() == "Windows")
"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
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()
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 -"
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()
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"
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 ...")
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