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

sync: add post-pull behaviors

* rename refresh to reload, since we reload config file(s)
* not loading extensions on demand; uncertain how we want to deal with them

Changeset a25aa7bf68e9

Parent 338cc33e00ba

by Steve Borho

Changes to one file · Browse files at a25aa7bf68e9 Showing diff from parent 338cc33e00ba Diff from another changeset...

 
41
42
43
 
44
45
46
 
90
91
92
 
 
93
94
95
 
110
111
112
 
113
114
115
 
123
124
125
126
 
127
128
129
 
145
146
147
148
 
149
150
151
 
155
156
157
 
 
 
158
159
160
 
231
232
233
234
 
235
236
237
 
251
252
253
254
 
 
255
256
257
 
279
280
281
282
 
 
 
 
 
 
 
 
283
284
285
 
297
298
299
 
 
 
 
 
 
300
301
302
 
314
315
316
317
 
 
318
319
320
321
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
324
325
 
41
42
43
44
45
46
47
 
91
92
93
94
95
96
97
98
 
113
114
115
116
117
118
119
 
127
128
129
 
130
131
132
133
 
149
150
151
 
152
153
154
155
 
159
160
161
162
163
164
165
166
167
 
238
239
240
 
241
242
243
244
 
258
259
260
 
261
262
263
264
265
 
287
288
289
 
290
291
292
293
294
295
296
297
298
299
300
 
312
313
314
315
316
317
318
319
320
321
322
323
 
335
336
337
 
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
@@ -41,6 +41,7 @@
  self.resize(850, 550)     self.root = root + self.repo = thgrepo.repository(ui.ui(), root)   self.finishfunc = None   self.curuser = None   self.curpw = None @@ -90,6 +91,8 @@
  hbox.addWidget(self.pathentry, 1)   self.authbutton = QPushButton(_('Authentication'))   hbox.addWidget(self.authbutton) + self.postpullbutton = QPushButton() + hbox.addWidget(self.postpullbutton)   layout.addLayout(hbox)     self.tv.clicked.connect(self.pathSelected) @@ -110,6 +113,7 @@
  self.outbutton.clicked.connect(self.outclicked)   self.pushbutton.clicked.connect(self.pushclicked)   self.emailbutton.clicked.connect(self.emailclicked) + self.postpullbutton.clicked.connect(self.postpullclicked)     self.opbuttons = (self.inbutton, self.pullbutton,   self.outbutton, self.pushbutton, @@ -123,7 +127,7 @@
  cmd.setHidden(True)   self.cmd = cmd   - self.refresh() + self.reload()   if 'default' in self.paths:   self.setUrl(self.paths['default'])   self.curalias = 'default' @@ -145,7 +149,7 @@
  for b in self.opbuttons:   b.setEnabled(True)   - def refresh(self): + def reload(self):   fn = os.path.join(self.root, '.hg', 'hgrc')   fn, cfg = loadIniFile([fn], self)   self.paths = {} @@ -155,6 +159,9 @@
  self.paths[ alias ] = cfg['paths'][ alias ]   tm = PathsModel(self.paths, self)   self.tv.setModel(tm) + self.cachedpp = self.repo.postpull + name = _('Post Pull: ') + self.repo.postpull.title() + self.postpullbutton.setText(name)     def refreshUrl(self):   'User has changed schema/host/port/path' @@ -231,7 +238,7 @@
    def keyPressEvent(self, event):   if event.matches(QKeySequence.Refresh): - self.refresh() + self.reload()   elif event.key() == Qt.Key_Escape:   if self.cmd.core.is_running():   self.cmd.core.cancel() @@ -251,7 +258,8 @@
  dialog = SaveDialog(self.root, alias, url, self)   if dialog.exec_() == QDialog.Accepted:   self.curalias = hglib.fromunicode(dialog.aliasentry.text()) - self.refresh() + self.repo.invalidateui() + self.reload()     def authclicked(self):   host = hglib.fromunicode(self.hostentry.text()) @@ -279,7 +287,14 @@
  self.finishfunc = lambda: self.invalidate.emit(self.root)   else:   self.finishfunc = None - self.run(['--repository', self.root, 'pull']) + cmdline = ['--repository', self.root, 'pull'] + if self.cachedpp == 'rebase': + cmdline.append('--rebase') + elif self.cachedpp == 'update': + cmdline.append('--update') + elif self.cachedpp == 'fetch': + cmdline[2] = 'fetch' + self.run(cmdline)     def outclicked(self):   if self.log: @@ -297,6 +312,12 @@
  self.finishfunc = None   self.run(['--repository', self.root, 'push'])   + def postpullclicked(self): + dlg = PostPullDialog(self.repo, self) + if dlg.exec_() == QDialog.Accepted: + self.repo.invalidateui() + self.reload() +   def emailclicked(self):   from tortoisehg.hgqt import run as _run   _run.email(ui.ui(), root=self.root) @@ -314,12 +335,95 @@
  del cfg['paths'][alias]   try:   wconfig.writefile(cfg, fn) - self.refresh() + self.repo.invalidateui() + self.reload()   except IOError, e:   qtlib.WarningMsgBox(_('Unable to write configuration file'),   hglib.tounicode(e), parent=self)     +class PostPullDialog(QDialog): + def __init__(self, repo, parent): + super(PostPullDialog, self).__init__(parent) + self.repo = repo + layout = QVBoxLayout() + self.setLayout(layout) + self.setWindowTitle(_('Post Pull Behavior')) + + self.none = QRadioButton(_('None - simply pull changesets')) + self.update = QRadioButton(_('Update - pull, then try to update')) + layout.addWidget(self.none) + layout.addWidget(self.update) + + if 'fetch' in repo.extensions() or repo.postpull == 'fetch': + self.fetch = QRadioButton(_('Fetch - use fetch extension')) + layout.addWidget(self.fetch) + if 'rebase' in repo.extensions() or repo.postpull == 'rebase': + self.rebase = QRadioButton(_('Rebase - use rebase extension')) + layout.addWidget(self.rebase) + + self.none.setChecked(True) + if repo.postpull == 'update': + self.update.setChecked(True) + elif repo.postpull == 'fetch': + self.fetch.setChecked(True) + elif repo.postpull == 'rebase': + self.rebase.setChecked(True) + + BB = QDialogButtonBox + bb = QDialogButtonBox(BB.Cancel) + bb.rejected.connect(self.reject) + + sr = QPushButton(_('Save In Repo')) + sr.clicked.connect(self.saveInRepo) + bb.addButton(sr, BB.ActionRole) + + sg = QPushButton(_('Save Global')) + sg.clicked.connect(self.saveGlobal) + sg.setAutoDefault(True) + bb.addButton(sg, BB.ActionRole) + + self.bb = bb + layout.addWidget(bb) + + def saveInRepo(self): + fn = os.path.join(self.root, '.hg', 'hgrc') + self.saveToPath([fn]) + + def saveGlobal(self): + self.saveToPath(util.user_rcpath()) + + def getValue(self): + if self.none.isChecked(): + return 'none' + elif self.update.isChecked(): + return 'update' + elif self.fetch.isChecked(): + return 'fetch' + else: + return 'rebase' + + def saveToPath(self, path): + fn, cfg = loadIniFile(path, self) + if not hasattr(cfg, 'write'): + qtlib.WarningMsgBox(_('Unable to save authentication'), + _('Iniparse must be installed.'), parent=self) + return + if fn is None: + return + try: + cfg.set('tortoisehg', 'postpull', self.getValue()) + wconfig.writefile(cfg, fn) + 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(PostPullDialog, self).accept() + + def reject(self): + super(PostPullDialog, self).reject() +  class SaveDialog(QDialog):   def __init__(self, root, alias, url, parent):   super(SaveDialog, self).__init__(parent)