Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.5, 2.1, and 2.1.1

stable export: warn if a patch file already exists (closes #502)

The current behavior of export os to "append" the selected changes into any
existing patch file if the name of the file matches the name of the patch file
that would normally be created.

This patch adds a warning message that lets the user choose between the old
behaviour (which may have its uses) or a (IMHO) more sensible behavior in which
the existing patch is overwritten, or simply abort the operation.

Changeset 8d237f16ab5d

Parent 4df9d3b22a66

by Angel Ezquerra

Changes to one file · Browse files at 8d237f16ab5d Showing diff from parent 4df9d3b22a66 Diff from another changeset...

 
1206
1207
1208
 
1209
1210
 
 
1211
 
 
 
 
 
 
 
 
 
 
 
1212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1213
1214
1215
 
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
@@ -1206,10 +1206,53 @@
  return   epath = os.path.join(hglib.fromunicode(dir),   hglib.fromunicode(self.repo.shortname)+'_%r.patch') +   cmdline = ['export', '--repository', self.repo.root, '--verbose',   '--output', epath] + + existingRevisions = []   for rev in revisions: + if os.path.exists(epath % rev): + if os.path.isfile(epath % rev): + existingRevisions.append(rev) + else: + QMessageBox.warning(self, + _('Cannot export revision'), + (_('Cannot export revision %s into the file named:' + '\n\n%s\n') % (rev, epath % rev)) + \ + _('There is already an existing folder ' + 'with that same name.')) + return   cmdline.extend(['--rev', str(rev)]) + + if existingRevisions: + buttonNames = [_("Replace"), _("Append"), _("Abort")] + + warningMessage = \ + _('There are existing patch files for %d revisions (%s) ' + 'in the selected location (%s).\n\n') \ + % (len(existingRevisions), + " ,".join([str(rev) for rev in existingRevisions]), + dir) + + warningMessage += \ + _('What do you want to do?\n') + u'\n' + \ + u'- ' + _('Replace the existing patch files.\n') + \ + u'- ' + _('Append the changes to the existing patch files.\n') + \ + u'- ' + _('Abort the export operation.\n') + + res = qtlib.CustomPrompt(_('Patch files already exist'), + warningMessage, + self, + buttonNames, 0, 2).run() + + if buttonNames[res] == _("Replace"): + # Remove the existing patch files + for rev in existingRevisions: + os.remove(epath % rev) + elif buttonNames[res] == _("Abort"): + return +   self.runCommand(cmdline)     def visualDiffRevision(self):