>From aef963f0c45dea81f3e6f30d3b4185a0983ca4de Mon Sep 17 00:00:00 2001 From: David Foster Date: Mon, 6 May 2013 10:50:01 -0700 Subject: [PATCH] Compensate for Windows-style output from the p4 command on non-Windows systems. --- git-p4.py | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/git-p4.py b/git-p4.py index 647f110..949d66d 100755 --- a/git-p4.py +++ b/git-p4.py @@ -1454,6 +1454,24 @@ class P4Submit(Command, P4UserMap): tmpFile = open(fileName, "rb") message = tmpFile.read() tmpFile.close() + + # HACK: If Perforce spontaneously generates Windows-style output, + # compensate by assuming the entire p4 command went into + # Windows mode. + if separatorLine not in message: + print "WARNING: Perforce has spontaneously decided to generate Windows-style output. Compensating." + + # Assume that Perforce is now inexplicably operating in Windows mode + self.isWindows = True + + # Retroactively rewrite expected output + submitTemplate = submitTemplate.replace("\n", "\r\n") + separatorLine = separatorLine.replace("\n", "\r\n") + newdiff = newdiff.replace("\n", "\r\n") + + if separatorLine not in message: + raise ValueError('Confused. Thought Perforce went into Windows mode but apparently something else is wrong.') + submitTemplate = message[:message.index(separatorLine)] if self.isWindows: submitTemplate = submitTemplate.replace("\r\n", "\n") -- 1.7.7.5 (Apple Git-26)