From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Luke Diamand <luke@diamand.org>,
Johannes Sixt <j.sixt@viscovery.net>
Subject: [PATCHv2 07/12] git p4: rearrange submit template construction
Date: Sun, 9 Sep 2012 16:16:08 -0400 [thread overview]
Message-ID: <1347221773-12773-8-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1347221773-12773-1-git-send-email-pw@padd.com>
Put all items in order as they appear, and add comments.
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
git-p4.py | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 0481f43..ea14c1f 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1202,6 +1202,9 @@ class P4Submit(Command, P4UserMap):
p4_revert(f)
return False
+ #
+ # Apply the patch for real, and do add/delete/+x handling.
+ #
system(applyPatchCmd)
for f in filesToAdd:
@@ -1215,6 +1218,10 @@ class P4Submit(Command, P4UserMap):
mode = filesToChangeExecBit[f]
setP4ExecBit(f, mode)
+ #
+ # Build p4 change description, starting with the contents
+ # of the git commit message.
+ #
logMessage = extractLogMessageFromGitCommit(id)
logMessage = logMessage.strip()
(logMessage, jobs) = self.separate_jobs_from_description(logMessage)
@@ -1223,8 +1230,16 @@ class P4Submit(Command, P4UserMap):
submitTemplate = self.prepareLogMessage(template, logMessage, jobs)
if self.preserveUser:
- submitTemplate = submitTemplate + ("\n######## Actual user %s, modified after commit\n" % p4User)
+ submitTemplate += "\n######## Actual user %s, modified after commit\n" % p4User
+
+ if self.checkAuthorship and not self.p4UserIsMe(p4User):
+ submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail
+ submitTemplate += "######## Use option --preserve-user to modify authorship.\n"
+ submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n"
+
+ separatorLine = "######## everything below this line is just the diff #######\n"
+ # diff
if os.environ.has_key("P4DIFF"):
del(os.environ["P4DIFF"])
diff = ""
@@ -1232,6 +1247,7 @@ class P4Submit(Command, P4UserMap):
diff += p4_read_pipe(['diff', '-du',
wildcard_encode(editedFile)])
+ # new file diff
newdiff = ""
for newFile in filesToAdd:
newdiff += "==== new file ====\n"
@@ -1242,13 +1258,7 @@ class P4Submit(Command, P4UserMap):
newdiff += "+" + line
f.close()
- if self.checkAuthorship and not self.p4UserIsMe(p4User):
- submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail
- submitTemplate += "######## Use option --preserve-user to modify authorship.\n"
- submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n"
-
- separatorLine = "######## everything below this line is just the diff #######\n"
-
+ # change description file: submitTemplate, separatorLine, diff, newdiff
(handle, fileName) = tempfile.mkstemp()
tmpFile = os.fdopen(handle, "w+")
if self.isWindows:
@@ -1258,6 +1268,9 @@ class P4Submit(Command, P4UserMap):
tmpFile.write(submitTemplate + separatorLine + diff + newdiff)
tmpFile.close()
+ #
+ # Let the user edit the change description, then submit it.
+ #
if self.edit_template(fileName):
# read the edited message and submit
ret = True
--
1.7.12.rc2.111.g96f7c73
next prev parent reply other threads:[~2012-09-09 20:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 20:16 [PATCHv2 00/12] git p4: submit conflict handling Pete Wyckoff
2012-09-09 20:16 ` [PATCHv2 01/12] git p4 test: remove bash-ism of combined export/assignment Pete Wyckoff
2012-09-15 21:25 ` Luke Diamand
2012-09-16 6:05 ` Junio C Hamano
2012-09-16 9:38 ` Luke Diamand
2012-09-17 4:50 ` Junio C Hamano
2012-09-17 8:13 ` Luke Diamand
2012-09-09 20:16 ` [PATCHv2 02/12] git p4: gracefully fail if some commits could not be applied Pete Wyckoff
2012-09-15 21:48 ` Luke Diamand
2012-09-09 20:16 ` [PATCHv2 03/12] git p4: remove submit failure options [a]pply and [w]rite Pete Wyckoff
2012-09-15 21:52 ` Luke Diamand
2012-09-09 20:16 ` [PATCHv2 04/12] git p4: move conflict prompt into run, add [q]uit input Pete Wyckoff
2012-09-15 21:56 ` Luke Diamand
2012-09-09 20:16 ` [PATCHv2 05/12] git p4: standardize submit cancel due to unchanged template Pete Wyckoff
2012-09-15 21:58 ` Luke Diamand
2012-09-09 20:16 ` [PATCHv2 06/12] git p4: test clean-up after failed submit, fix added files Pete Wyckoff
2012-09-09 20:16 ` Pete Wyckoff [this message]
2012-09-09 20:16 ` [PATCHv2 08/12] git p4: revert deleted files after submit cancel Pete Wyckoff
2012-09-09 20:16 ` [PATCHv2 09/12] git p4: accept -v for --verbose Pete Wyckoff
2012-09-09 20:16 ` [PATCHv2 10/12] git p4: add submit --dry-run option Pete Wyckoff
2012-09-09 20:16 ` [PATCHv2 11/12] git p4: add submit --prepare-p4-only option Pete Wyckoff
2012-09-09 20:16 ` [PATCHv2 12/12] git-p4: add submit --conflict option and config varaiable Pete Wyckoff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347221773-12773-8-git-send-email-pw@padd.com \
--to=pw@padd.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=luke@diamand.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).