@matheusbsbs / matheus-bagliano / commits / 25df95cce4
Fork 0

Make submitting work on Windows.

Signed-off-by: Simon Hausmann <hausmann@kde.org>

Simon Hausmann committed May 15, 2007 at 15:15 UTC 25df95cce470d74cdc5e8905a298bbc36c7ec6d0
1 file changed +11 -5
contrib/fast-import/git-p4
+11 -5
@@ -9,7 +9,7 @@
9 #
10
11 import optparse, sys, os, marshal, popen2, subprocess, shelve
12 -import tempfile, getopt, sha, os.path, time
12 +import tempfile, getopt, sha, os.path, time, platform
13 from sets import Set;
14
15 gitdir = os.environ.get("GIT_DIR", "")
@@ -299,7 +299,10 @@ class P4Submit(Command):
299 diff += "+" + line
300 f.close()
301
302 - separatorLine = "######## everything below this line is just the diff #######\n"
302 + separatorLine = "######## everything below this line is just the diff #######"
303 + if platform.system() == "Windows":
304 + separatorLine += "\r"
305 + separatorLine += "\n"
306
307 response = "e"
308 firstIteration = True
@@ -312,9 +315,12 @@ class P4Submit(Command):
315 tmpFile = os.fdopen(handle, "w+")
316 tmpFile.write(submitTemplate + separatorLine + diff)
317 tmpFile.close()
315 - editor = os.environ.get("EDITOR", "vi")
318 + defaultEditor = "vi"
319 + if platform.system() == "Windows":
320 + defaultEditor = "notepad"
321 + editor = os.environ.get("EDITOR", defaultEditor);
322 system(editor + " " + fileName)
317 - tmpFile = open(fileName, "r")
323 + tmpFile = open(fileName, "rb")
324 message = tmpFile.read()
325 tmpFile.close()
326 os.remove(fileName)
@@ -325,7 +331,7 @@ class P4Submit(Command):
331 print submitTemplate
332 raw_input("Press return to continue...")
333 else:
328 - pipe = mypopen("p4 submit -i", "w")
334 + pipe = os.popen("p4 submit -i", "wb")
335 pipe.write(submitTemplate)
336 pipe.close()
337 else: