Skip to content

Commit 55ac2ed

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4: rearrange submit template construction
Put all items in order as they appear, and add comments. Signed-off-by: Pete Wyckoff <[email protected]> Acked-by: Luke Diamand <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7fbc98 commit 55ac2ed

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

git-p4.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,9 @@ def applyCommit(self, id):
12021202
p4_revert(f)
12031203
return False
12041204

1205+
#
1206+
# Apply the patch for real, and do add/delete/+x handling.
1207+
#
12051208
system(applyPatchCmd)
12061209

12071210
for f in filesToAdd:
@@ -1215,6 +1218,10 @@ def applyCommit(self, id):
12151218
mode = filesToChangeExecBit[f]
12161219
setP4ExecBit(f, mode)
12171220

1221+
#
1222+
# Build p4 change description, starting with the contents
1223+
# of the git commit message.
1224+
#
12181225
logMessage = extractLogMessageFromGitCommit(id)
12191226
logMessage = logMessage.strip()
12201227
(logMessage, jobs) = self.separate_jobs_from_description(logMessage)
@@ -1223,15 +1230,24 @@ def applyCommit(self, id):
12231230
submitTemplate = self.prepareLogMessage(template, logMessage, jobs)
12241231

12251232
if self.preserveUser:
1226-
submitTemplate = submitTemplate + ("\n######## Actual user %s, modified after commit\n" % p4User)
1233+
submitTemplate += "\n######## Actual user %s, modified after commit\n" % p4User
1234+
1235+
if self.checkAuthorship and not self.p4UserIsMe(p4User):
1236+
submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail
1237+
submitTemplate += "######## Use option --preserve-user to modify authorship.\n"
1238+
submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n"
1239+
1240+
separatorLine = "######## everything below this line is just the diff #######\n"
12271241

1242+
# diff
12281243
if os.environ.has_key("P4DIFF"):
12291244
del(os.environ["P4DIFF"])
12301245
diff = ""
12311246
for editedFile in editedFiles:
12321247
diff += p4_read_pipe(['diff', '-du',
12331248
wildcard_encode(editedFile)])
12341249

1250+
# new file diff
12351251
newdiff = ""
12361252
for newFile in filesToAdd:
12371253
newdiff += "==== new file ====\n"
@@ -1242,13 +1258,7 @@ def applyCommit(self, id):
12421258
newdiff += "+" + line
12431259
f.close()
12441260

1245-
if self.checkAuthorship and not self.p4UserIsMe(p4User):
1246-
submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail
1247-
submitTemplate += "######## Use option --preserve-user to modify authorship.\n"
1248-
submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n"
1249-
1250-
separatorLine = "######## everything below this line is just the diff #######\n"
1251-
1261+
# change description file: submitTemplate, separatorLine, diff, newdiff
12521262
(handle, fileName) = tempfile.mkstemp()
12531263
tmpFile = os.fdopen(handle, "w+")
12541264
if self.isWindows:
@@ -1258,6 +1268,9 @@ def applyCommit(self, id):
12581268
tmpFile.write(submitTemplate + separatorLine + diff + newdiff)
12591269
tmpFile.close()
12601270

1271+
#
1272+
# Let the user edit the change description, then submit it.
1273+
#
12611274
if self.edit_template(fileName):
12621275
# read the edited message and submit
12631276
ret = True

0 commit comments

Comments
 (0)