Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable sync: provide a safe mechanism for clearing username/pw from URL (refs #117)

Never show the user's password, but don't actually provide a method for
changing or setting the URL password. Only allow it to be deleted along with
the username, and default the checkbox to favor deletion.

Changeset 606c40397743

Parent 922a727f1b80

by Steve Borho

Changes to one file · Browse files at 606c40397743 Showing diff from parent 922a727f1b80 Diff from another changeset...

 
476
477
478
479
 
 
480
481
482
 
889
890
891
892
 
893
 
 
 
 
 
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
909
910
911
912
913
914
915
916
917
918
919
 
 
920
921
922
 
929
930
931
932
 
 
 
 
933
934
935
 
476
477
478
 
479
480
481
482
483
 
890
891
892
 
893
894
895
896
897
898
899
900
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
 
 
 
 
 
938
939
940
941
942
 
949
950
951
 
952
953
954
955
956
957
958
@@ -476,7 +476,8 @@
  else:   alias = 'new'   url = self.currentUrl(False) - dlg = SaveDialog(self.repo, alias, url, self) + safeurl = self.currentUrl(True) + dlg = SaveDialog(self.repo, alias, url, safeurl, self)   dlg.setWindowFlags(Qt.Sheet)   dlg.setWindowModality(Qt.WindowModal)   if dlg.exec_() == QDialog.Accepted: @@ -889,34 +890,53 @@
  super(PostPullDialog, self).reject()    class SaveDialog(QDialog): - def __init__(self, repo, alias, url, parent): + def __init__(self, repo, alias, url, safeurl, parent):   super(SaveDialog, self).__init__(parent) + + self.setWindowTitle(_('Save Peer Path')) + self.setWindowFlags(self.windowFlags() & + ~Qt.WindowContextHelpButtonHint) +   self.repo = repo - layout = QVBoxLayout() - self.setLayout(layout) - hbox = QHBoxLayout() - hbox.addWidget(QLabel(_('Alias'))) - self.aliasentry = QLineEdit(alias) - hbox.addWidget(self.aliasentry, 1) - layout.addLayout(hbox) - hbox = QHBoxLayout() - hbox.addWidget(QLabel(_('URL'))) - self.urlentry = QLineEdit(url) - fontm = QFontMetrics(self.font()) - self.urlentry.setFixedWidth(fontm.width(url)+5) - hbox.addWidget(self.urlentry, 1) - layout.addLayout(hbox) + self.origurl = url + self.setLayout(QFormLayout(fieldGrowthPolicy=QFormLayout.ExpandingFieldsGrow)) + + self.aliasentry = QLineEdit(hglib.tounicode(alias)) + self.aliasentry.selectAll() + self.layout().addRow(_('Alias'), self.aliasentry) + + self.urllabel = QLabel(hglib.tounicode(safeurl)) + self.layout().addRow(_('URL'), self.urllabel) + + user, host, port, folder, passwd, scheme = parseurl(url) + if user or passwd: + cleanurl = '://'.join([scheme, host]) + if port: + cleanurl = ':'.join([cleanurl, port]) + if folder: + cleanurl = '/'.join([cleanurl, folder]) + def showurl(showclean): + newurl = showclean and cleanurl or safeurl + self.urllabel.setText(hglib.tounicode(newurl)) + self.cleanurl = cleanurl + self.clearcb = QCheckBox(_('Remove authentication data from URL')) + self.clearcb.setToolTip( + _('User authentication data should be associated with the ' + 'hostname using the security dialog.')) + self.clearcb.toggled.connect(showurl) + self.clearcb.setChecked(True) + self.layout().addRow(self.clearcb) + else: + self.clearcb = None +   BB = QDialogButtonBox   bb = QDialogButtonBox(BB.Save|BB.Cancel)   bb.accepted.connect(self.accept)   bb.rejected.connect(self.reject)   bb.button(BB.Save).setAutoDefault(True)   self.bb = bb - layout.addWidget(bb) - self.aliasentry.selectAll() - self.setWindowTitle(_('Save Peer Path')) - self.setWindowFlags(self.windowFlags() & - ~Qt.WindowContextHelpButtonHint) + self.layout().addRow(None, bb) +   QTimer.singleShot(0, lambda:self.aliasentry.setFocus())     def accept(self): @@ -929,7 +949,10 @@
  if fn is None:   return   alias = hglib.fromunicode(self.aliasentry.text()) - path = hglib.fromunicode(self.urlentry.text()) + if self.clearcb and self.clearcb.isChecked(): + path = self.cleanurl + else: + path = self.origurl   if alias in cfg['paths']:   if not qtlib.QuestionMsgBox(_('Confirm URL replace'),   _('%s already exists, replace URL?') % alias):