2102
tmpFile.write(submitTemplate)
2103
tmpFile.close()
2104
2105
- if self.prepare_p4_only:
2106
- #
2107
- # Leave the p4 tree prepared, and the submit template around
2108
- # and let the user decide what to do next
2109
- #
2110
- print()
2111
- print("P4 workspace prepared for submission.")
2112
- print("To submit or revert, go to client workspace")
2113
- print(" " + self.clientPath)
2114
- print()
2115
- print("To submit, use \"p4 submit\" to write a new description,")
2116
- print("or \"p4 submit -i <%s\" to use the one prepared by" \
2117
- " \"git p4\"." % fileName)
2118
- print("You can delete the file \"%s\" when finished." % fileName)
2119
-
2120
- if self.preserveUser and p4User and not self.p4UserIsMe(p4User):
2121
- print("To preserve change ownership by user %s, you must\n" \
2122
- "do \"p4 change -f <change>\" after submitting and\n" \
2123
- "edit the User field.")
2124
- if pureRenameCopy:
2125
- print("After submitting, renamed files must be re-synced.")
2126
- print("Invoke \"p4 sync -f\" on each of these files:")
2127
- for f in pureRenameCopy:
2128
- print(" " + f)
2129
-
2130
- print()
2131
- print("To revert the changes, use \"p4 revert ...\", and delete")
2132
- print("the submit template file \"%s\"" % fileName)
2133
- if filesToAdd:
2134
- print("Since the commit adds new files, they must be deleted:")
2135
- for f in filesToAdd:
2136
- print(" " + f)
2137
- print()
2138
- return True
2139
-
2140
- #
2141
- # Let the user edit the change description, then submit it.
2142
- #
2105
submitted = False
2106
2107
try:
2108
+
2109
+ if self.prepare_p4_only:
2110
+ #
2111
+ # Leave the p4 tree prepared, and the submit template around
2112
+ # and let the user decide what to do next
2113
+ #
2114
+ submitted = True
2115
+ print("")
2116
+ print("P4 workspace prepared for submission.")
2117
+ print("To submit or revert, go to client workspace")
2118
+ print(" " + self.clientPath)
2119
+ print("")
2120
+ print("To submit, use \"p4 submit\" to write a new description,")
2121
+ print("or \"p4 submit -i <%s\" to use the one prepared by" \
2122
+ " \"git p4\"." % fileName)
2123
+ print("You can delete the file \"%s\" when finished." % fileName)
2124
+
2125
+ if self.preserveUser and p4User and not self.p4UserIsMe(p4User):
2126
+ print("To preserve change ownership by user %s, you must\n" \
2127
+ "do \"p4 change -f <change>\" after submitting and\n" \
2128
+ "edit the User field.")
2129
+ if pureRenameCopy:
2130
+ print("After submitting, renamed files must be re-synced.")
2131
+ print("Invoke \"p4 sync -f\" on each of these files:")
2132
+ for f in pureRenameCopy:
2133
+ print(" " + f)
2134
+
2135
+ print("")
2136
+ print("To revert the changes, use \"p4 revert ...\", and delete")
2137
+ print("the submit template file \"%s\"" % fileName)
2138
+ if filesToAdd:
2139
+ print("Since the commit adds new files, they must be deleted:")
2140
+ for f in filesToAdd:
2141
+ print(" " + f)
2142
+ print("")
2143
+ sys.stdout.flush()
2144
+ return True
2145
+
2146
if self.edit_template(fileName):
2147
# read the edited message and submit
2148
tmpFile = open(fileName, "rb")
2150
tmpFile.close()
2151
if self.isWindows:
2152
message = message.replace("\r\n", "\n")
2153
- submitTemplate = message[:message.index(separatorLine)]
2153
+ if message.find(separatorLine) != -1:
2154
+ submitTemplate = message[:message.index(separatorLine)]
2155
+ else:
2156
+ submitTemplate = message
2157
+
2158
+ if len(submitTemplate.strip()) == 0:
2159
+ print("Changelist is empty, aborting this changelist.")
2160
+ sys.stdout.flush()
2161
+ return False
2162
2163
if update_shelve:
2164
p4_write_pipe(['shelve', '-r', '-i'], submitTemplate)
2182
submitted = True
2183
2184
finally:
2177
- # skip this patch
2185
+ # Revert changes if we skip this patch
2186
if not submitted or self.shelve:
2187
if self.shelve:
2188
print ("Reverting shelved files.")
2189
else:
2190
print ("Submission cancelled, undoing p4 changes.")
2191
+ sys.stdout.flush()
2192
for f in editedFiles | filesToDelete:
2193
p4_revert(f)
2194
for f in filesToAdd:
2195
p4_revert(f)
2196
os.remove(f)
2197
2189
- os.remove(fileName)
2198
+ if not self.prepare_p4_only:
2199
+ os.remove(fileName)
2200
return submitted
2201
2202
# Export git tags as p4 labels. Create a p4 label and then tag