Use git format-patch and git apply --apply when extracting patches from git and
applying them to a Perforce checkout. This should make it possible to apply git commits with binary files that cannot be handled by path. Signed-off-by: Simon Hausmann <simon@lst.de>
This commit is contained in:
parent
64ffb06a9c
commit
47a130b7bf
@ -213,10 +213,13 @@ class P4Submit(Command):
|
|||||||
else:
|
else:
|
||||||
die("unknown modifier %s for %s" % (modifier, path))
|
die("unknown modifier %s for %s" % (modifier, path))
|
||||||
|
|
||||||
diffcmd = "git diff-tree -p --diff-filter=ACMRTUXB \"%s^\" \"%s\"" % (id, id)
|
diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
|
||||||
patchcmd = diffcmd + " | patch -p1"
|
patchcmd = diffcmd + " | git apply "
|
||||||
|
tryPatchCmd = diffcmd + "--check -"
|
||||||
|
applyPatchCmd = diffcmd + "--check --apply -"
|
||||||
|
print mypopen(diffcmd).read()
|
||||||
|
|
||||||
if os.system(patchcmd + " --dry-run --silent") != 0:
|
if os.system(tryPatchCmd) != 0:
|
||||||
print "Unfortunately applying the change failed!"
|
print "Unfortunately applying the change failed!"
|
||||||
print "What do you want to do?"
|
print "What do you want to do?"
|
||||||
response = "x"
|
response = "x"
|
||||||
@ -226,7 +229,7 @@ class P4Submit(Command):
|
|||||||
print "Skipping! Good luck with the next patches..."
|
print "Skipping! Good luck with the next patches..."
|
||||||
return
|
return
|
||||||
elif response == "a":
|
elif response == "a":
|
||||||
os.system(patchcmd)
|
os.system(applyPatchCmd)
|
||||||
if len(filesToAdd) > 0:
|
if len(filesToAdd) > 0:
|
||||||
print "You may also want to call p4 add on the following files:"
|
print "You may also want to call p4 add on the following files:"
|
||||||
print " ".join(filesToAdd)
|
print " ".join(filesToAdd)
|
||||||
@ -239,7 +242,7 @@ class P4Submit(Command):
|
|||||||
print "Patch saved to patch.txt in %s !" % self.clientPath
|
print "Patch saved to patch.txt in %s !" % self.clientPath
|
||||||
die("Please resolve and submit the conflict manually and continue afterwards with git-p4 submit --continue")
|
die("Please resolve and submit the conflict manually and continue afterwards with git-p4 submit --continue")
|
||||||
|
|
||||||
system(patchcmd)
|
system(applyPatchCmd)
|
||||||
|
|
||||||
for f in filesToAdd:
|
for f in filesToAdd:
|
||||||
system("p4 add %s" % f)
|
system("p4 add %s" % f)
|
||||||
|
Loading…
Reference in New Issue
Block a user