Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

sync: allow 'Delete' in paths tree to remove URLs from .hg/hgrc

Changeset c3db94897c0d

Parent a7d753445985

by Steve Borho

Changes to one file · Browse files at c3db94897c0d Showing diff from parent a7d753445985 Diff from another changeset...

 
22
23
24
25
26
27
28
 
316
317
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
320
321
 
493
494
495
 
496
497
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
500
501
 
22
23
24
 
25
26
27
 
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
 
514
515
516
517
518
519
 
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
@@ -22,7 +22,6 @@
 # TODO  # Write keyring help, connect to help button  # Ini file locking for sync.py and settings.py -# Delete paths from ini file via 'Delete/Backspace'    try:   import iniparse @@ -316,6 +315,28 @@
  dialog = hgemail.EmailDialog(_ui, repo, None, self)   dialog.exec_()   + def removeAlias(self, alias): + if iniparse is None: + qtlib.WarningMsgBox(_('Unable to remove URL'), + _('Iniparse must be installed.'), parent=self) + return + fn = os.path.join(self.root, '.hg', 'hgrc') + fn, cfg = loadIniFile([fn], self) + if fn is None: + return + if 'paths' in cfg: + if alias in cfg['paths']: + del cfg['paths'][alias] + try: + f = util.atomictempfile(fn, 'w', createmode=None) + f.write(str(cfg)) + f.rename() + self.refresh() + except IOError, e: + qtlib.WarningMsgBox(_('Unable to write configuration file'), + hglib.tounicode(e), parent=self) + +  class SaveDialog(QDialog):   def __init__(self, root, alias, url, parent):   super(SaveDialog, self).__init__(parent) @@ -493,9 +514,23 @@
  self.setSelectionMode(QTreeView.SingleSelection)   self.setContextMenuPolicy(Qt.CustomContextMenu)   self.customContextMenuRequested.connect(self.menuRequest) + self.parent = parent     def keyPressEvent(self, event): - return super(PathsTree, self).keyPressEvent(event) + if event.matches(QKeySequence.Delete): + self.deleteSelected() + else: + return super(PathsTree, self).keyPressEvent(event) + + def deleteSelected(self): + for index in self.selectedRows(): + alias = index.data(Qt.DisplayRole).toString() + r = qtlib.QuestionMsgBox(_('Confirm path delete'), + _('Delete %s from your repo configuration file?') % alias, + parent=self) + if r: + alias = hglib.fromunicode(alias) + self.parent.removeAlias(alias)     def dragObject(self):   urls = []