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

sync: saving of [auth] sections is now functional

Changeset a03484f199ac

Parent cfb74e87f48a

by Steve Borho

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

 
319
320
321
 
322
323
324
 
 
 
 
 
325
326
327
 
355
356
357
 
 
 
 
 
 
 
358
359
360
361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
 
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
 
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
 
 
 
 
 
 
 
 
407
408
409
@@ -319,9 +319,15 @@
  def __init__(self, root, host, user, pw, parent):   super(AuthDialog, self).__init__(parent)   self.root = root + self.host = host   layout = QVBoxLayout()   self.setLayout(layout)   hbox = QHBoxLayout() + hbox.addWidget(QLabel(_('Site Alias'))) + self.aliasentry = QLineEdit(host.split('.', 1)[0]) + hbox.addWidget(self.aliasentry, 1) + layout.addLayout(hbox) + hbox = QHBoxLayout()   hbox.addWidget(QLabel(_('Username')))   self.userentry = QLineEdit(user)   hbox.addWidget(self.userentry, 1) @@ -355,22 +361,49 @@
  pass     def saveInRepo(self): + fn = os.path.join(self.root, '.hg', 'hgrc') + self.saveToPath([fn]) + + def saveGlobal(self): + self.saveToPath(util.user_rcpath()) + + def saveToPath(self, path):   if iniparse is None:   qtlib.WarningMsgBox(_('Unable to save authentication'),   _('Iniparse must be installed.'), parent=self)   return + fn, cfg = loadIniFile(path, self) + if fn is None: + return + if 'auth' not in cfg: + cfg._new_namespace('auth') + username = hglib.fromunicode(self.userentry.text()) + password = hglib.fromunicode(self.pwentry.text()) + alias = hglib.fromunicode(self.aliasentry.text()) + if self.host+'.prefix' in cfg['auth']: + if not qtlib.QuestionMsgBox(_('Confirm authentication replace'), + _('Authentication info for %s already' + 'exists, replace?') % host): + return + cfg['auth'][alias+'.schemes'] = 'https http' + cfg['auth'][alias+'.username'] = username + cfg['auth'][alias+'.prefix'] = self.host + key = alias+'.password' + if password: + cfg['auth'][key] = password + elif not password and key in cfg['auth']: + del cfg['auth'][key] + try: + f = util.atomictempfile(fn, 'w', createmode=None) + f.write(str(cfg)) + f.rename() + except IOError, e: + qtlib.WarningMsgBox(_('Unable to write configuration file'), + hglib.tounicode(e), parent=self)   fn = os.path.join(self.root, '.hg', 'hgrc')   fn, cfg = loadIniFile([fn], self)   super(AuthDialog, self).accept()   - def saveGlobal(self): - if iniparse is None: - qtlib.WarningMsgBox(_('Unable to save authentication'), - _('Iniparse must be installed.'), parent=self) - return - fn, cfg = loadIniFile(util.user_rcpath(), self) - super(AuthDialog, self).accept() -   def reject(self):   super(AuthDialog, self).reject()