git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 07/12] git p4: rearrange submit template construction

From
PWPete Wyckoff <pw@padd.com>
Date
Sep 9, 2012, 20:16 UTC
Message-ID
<1347221773-12773-8-git-send-email-pw@padd.com>
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
Previous: Pete WyckoffNext: Pete Wyckoff
Message 17 of 22 in “[PATCHv2 00/12] git p4: submit conflict handling”
  1. Pete WyckoffSep 9, 2012
  2. 01/12 git p4 test: remove bash-ism of combined export/assignmentPete Wyckoff, Sep 9, 2012
  3. Luke DiamandSep 15, 2012
  4. Junio C HamanoSep 16, 2012
  5. Luke DiamandSep 16, 2012
  6. Junio C HamanoSep 17, 2012
  7. Luke DiamandSep 17, 2012
  8. 02/12 git p4: gracefully fail if some commits could not be appliedPete Wyckoff, Sep 9, 2012
  9. Luke DiamandSep 15, 2012
  10. 03/12 git p4: remove submit failure options [a]pply and [w]ritePete Wyckoff, Sep 9, 2012
  11. Luke DiamandSep 15, 2012
  12. 04/12 git p4: move conflict prompt into run, add [q]uit inputPete Wyckoff, Sep 9, 2012
  13. Luke DiamandSep 15, 2012
  14. 05/12 git p4: standardize submit cancel due to unchanged templatePete Wyckoff, Sep 9, 2012
  15. Luke DiamandSep 15, 2012
  16. 06/12 git p4: test clean-up after failed submit, fix added filesPete Wyckoff, Sep 9, 2012
  17. 07/12 git p4: rearrange submit template constructionPete Wyckoff, Sep 9, 2012
  18. 08/12 git p4: revert deleted files after submit cancelPete Wyckoff, Sep 9, 2012
  19. 09/12 git p4: accept -v for --verbosePete Wyckoff, Sep 9, 2012
  20. 10/12 git p4: add submit --dry-run optionPete Wyckoff, Sep 9, 2012
  21. 11/12 git p4: add submit --prepare-p4-only optionPete Wyckoff, Sep 9, 2012
  22. 12/12 git-p4: add submit --conflict option and config varaiablePete Wyckoff, Sep 9, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.