diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-06-06 11:38:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-06 11:38:57 -0700 |
commit | eb5398a89122e4345b1fd3cab4f5630290bb3d0e (patch) | |
tree | cb9932fff1eb1f41494568d8579e5bc146aa4379 | |
parent | 3784ba310fbb14ca96d7faeeefad1d8985c5de86 (diff) | |
parent | b4073bb387ef303c9ac3c044f46d6a8ae6e190f0 (diff) | |
download | git-eb5398a89122e4345b1fd3cab4f5630290bb3d0e.tar.gz |
Merge branch 'mc/git-p4-prepare-p4-only'
* mc/git-p4-prepare-p4-only:
git-p4: Do not include diff in spec file when just preparing p4
-rwxr-xr-x | git-p4.py | 49 | ||||
-rwxr-xr-x | t/t9807-git-p4-submit.sh | 3 |
2 files changed, 28 insertions, 24 deletions
@@ -1238,6 +1238,28 @@ class P4Submit(Command, P4UserMap): if response == 'n': return False + def get_diff_description(self, editedFiles): + # diff + if os.environ.has_key("P4DIFF"): + del(os.environ["P4DIFF"]) + diff = "" + for editedFile in editedFiles: + diff += p4_read_pipe(['diff', '-du', + wildcard_encode(editedFile)]) + + # new file diff + newdiff = "" + for newFile in filesToAdd: + newdiff += "==== new file ====\n" + newdiff += "--- /dev/null\n" + newdiff += "+++ %s\n" % newFile + f = open(newFile, "r") + for line in f.readlines(): + newdiff += "+" + line + f.close() + + return diff + newdiff + def applyCommit(self, id): """Apply one commit, return True if it succeeded.""" @@ -1398,34 +1420,15 @@ class P4Submit(Command, P4UserMap): submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n" separatorLine = "######## everything below this line is just the diff #######\n" + if not self.prepare_p4_only: + submitTemplate += separatorLine + submitTemplate += self.get_diff_description(editedFiles) - # diff - if os.environ.has_key("P4DIFF"): - del(os.environ["P4DIFF"]) - diff = "" - for editedFile in editedFiles: - diff += p4_read_pipe(['diff', '-du', - wildcard_encode(editedFile)]) - - # new file diff - newdiff = "" - for newFile in filesToAdd: - newdiff += "==== new file ====\n" - newdiff += "--- /dev/null\n" - newdiff += "+++ %s\n" % newFile - f = open(newFile, "r") - for line in f.readlines(): - newdiff += "+" + line - f.close() - - # change description file: submitTemplate, separatorLine, diff, newdiff (handle, fileName) = tempfile.mkstemp() tmpFile = os.fdopen(handle, "w+") if self.isWindows: submitTemplate = submitTemplate.replace("\n", "\r\n") - separatorLine = separatorLine.replace("\n", "\r\n") - newdiff = newdiff.replace("\n", "\r\n") - tmpFile.write(submitTemplate + separatorLine + diff + newdiff) + tmpFile.write(submitTemplate) tmpFile.close() if self.prepare_p4_only: diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh index 4caf36e006..7fab2ed977 100755 --- a/t/t9807-git-p4-submit.sh +++ b/t/t9807-git-p4-submit.sh @@ -403,7 +403,8 @@ test_expect_success 'submit --prepare-p4-only' ' git commit -m "prep only add" && git p4 submit --prepare-p4-only >out && test_i18ngrep "prepared for submission" out && - test_i18ngrep "must be deleted" out + test_i18ngrep "must be deleted" out && + ! test_i18ngrep "everything below this line is just the diff" out ) && ( cd "$cli" && |