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

Merge with stable

Changeset 1408d349ac7e

Parents 0865a2485b59

Parents 53ca55f9aa39

by Adrian Buehlmann

Changes to 3 files · Browse files at 1408d349ac7e Showing diff from parent 0865a2485b59 53ca55f9aa39 Diff from another changeset...

 
121
122
123
 
124
125
126
 
152
153
154
155
156
157
158
159
 
 
160
161
162
 
207
208
209
 
 
 
 
 
 
210
211
212
 
287
288
289
290
 
 
291
292
 
293
294
295
 
298
299
300
 
 
 
 
 
 
 
 
 
 
301
302
303
 
328
329
330
 
 
 
 
 
 
 
 
331
332
333
 
334
335
336
 
396
397
398
399
 
400
401
402
 
416
417
418
419
420
421
422
423
424
425
426
427
 
428
429
430
 
458
459
460
461
462
463
464
 
 
465
466
467
 
121
122
123
124
125
126
127
 
153
154
155
 
156
157
158
159
160
161
162
163
164
 
209
210
211
212
213
214
215
216
217
218
219
220
 
295
296
297
 
298
299
300
301
302
303
304
305
 
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
 
348
349
350
351
352
353
354
355
356
357
358
359
360
 
361
362
363
364
 
424
425
426
 
427
428
429
430
 
444
445
446
 
 
 
 
 
 
 
 
 
447
448
449
450
 
478
479
480
 
 
 
 
481
482
483
484
485
@@ -121,6 +121,7 @@
  self.filelistToolbar.addWidget(self.statusfilter)   self.filelistToolbar.addSeparator()   self.filelistToolbar.addWidget(self.refreshBtn) + self.actions = wctxactions.WctxActions(self.repo, self)   tv = WctxFileTree(self.repo)   vbox.addLayout(hbox)   vbox.addWidget(tv) @@ -152,11 +153,12 @@
  hcbox.addStretch(1)   hcbox.addWidget(self.countlbl)   - tv.menuAction.connect(self.refreshWctx)   tv.setItemsExpandable(False)   tv.setRootIsDecorated(False)   tv.sortByColumn(COL_STATUS, Qt.AscendingOrder)   tv.clicked.connect(self.onRowClicked) + tv.doubleClicked.connect(self.onRowDoubleClicked) + tv.menuRequest.connect(self.onMenuRequest)   le.textEdited.connect(self.setFilter)     def statusTypeTrigger(status): @@ -207,6 +209,12 @@
  self.fileview.saveSettings(qs, prefix+'/fileview')   qs.setValue(prefix+'/state', self.split.saveState())   + @pyqtSlot(QPoint, object) + def onMenuRequest(self, point, selected): + menu = self.actions.makeMenu(selected) + if menu.exec_(point): + self.refreshWctx() +   def refreshWctx(self):   if self.refthread:   return @@ -287,9 +295,11 @@
  curidx = tm.index(i, 0)   else:   selmodel.select(curidx, flags) - selmodel.currentChanged.connect(self.currentChanged) + selmodel.currentChanged.connect(self.onCurrentChange) + selmodel.selectionChanged.connect(self.onSelectionChange)   if curidx and curidx.isValid():   selmodel.setCurrentIndex(curidx, QItemSelectionModel.Current) + self.onSelectionChange(None, None)     # Disabled decorator because of bug in older PyQt releases   #@pyqtSlot(QModelIndex) @@ -298,6 +308,16 @@
  if index.column() == COL_PATH:   self.tv.model().toggleRow(index)   + # Disabled decorator because of bug in older PyQt releases + #@pyqtSlot(QModelIndex) + def onRowDoubleClicked(self, index): + 'tree view emitted a doubleClicked signal, index guarunteed valid' + path, status, mst, u, ext, sz = self.tv.model().getRow(index) + if status in 'MAR!': + self.actions.allactions[0].trigger() + elif status == 'S': + self.linkActivated.emit(u'subrepo:'+hglib.tounicode(path)) +   @pyqtSlot(QString)   def setFilter(self, match):   self.tv.model().setFilter(match) @@ -328,9 +348,17 @@
  else:   return []   + @pyqtSlot(QItemSelection, QItemSelection) + def onSelectionChange(self, selected, deselected): + selrows = [] + for index in self.tv.selectedRows(): + path, status, mst, u, ext, sz = self.tv.model().getRow(index) + selrows.append((set(status+mst.lower()), path)) + self.actions.updateActionSensitivity(selrows) +   # Disabled decorator because of bug in older PyQt releases   #@pyqtSlot(QModelIndex, QModelIndex) - def currentChanged(self, index, old): + def onCurrentChange(self, index, old):   'Connected to treeview "currentChanged" signal'   row = index.model().getRow(index)   if row is None: @@ -396,7 +424,7 @@
     class WctxFileTree(QTreeView): - menuAction = pyqtSignal() + menuRequest = pyqtSignal(QPoint, object)     def __init__(self, repo, parent=None):   QTreeView.__init__(self, parent) @@ -416,15 +444,7 @@
  if event.key() == 32:   for index in self.selectedRows():   self.model().toggleRow(index) - if event.key() == Qt.Key_D and event.modifiers() == Qt.ControlModifier: - selfiles = [] - for index in self.selectedRows(): - selfiles.append(self.model().getRow(index)[COL_PATH]) - dlg = visdiff.visualdiff(self.repo.ui, self.repo, selfiles, {}) - if dlg: - dlg.exec_() - else: - return super(WctxFileTree, self).keyPressEvent(event) + return super(WctxFileTree, self).keyPressEvent(event)     def dragObject(self):   urls = [] @@ -458,10 +478,8 @@
  for index in self.selectedRows():   path, status, mst, u, ext, sz = self.model().getRow(index)   selrows.append((set(status+mst.lower()), path)) - point = self.mapToGlobal(point) - action = wctxactions.wctxactions(self, point, self.repo, selrows) - if action: - self.menuAction.emit() + if selrows: + self.menuRequest.emit(self.mapToGlobal(point), selrows)     def selectedRows(self):   return self.selectionModel().selectedRows()
 
14
15
16
17
 
18
19
20
21
22
23
24
25
 
 
26
27
28
29
30
31
32
33
34
35
36
37
 
 
38
39
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
67
 
68
69
70
 
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
123
124
125
126
127
128
129
130
131
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
134
135
 
190
191
192
193
 
194
195
196
197
198
 
 
199
200
201
 
204
205
206
207
 
208
209
210
211
 
 
212
213
214
 
239
240
241
242
243
244
245
 
 
 
 
246
247
248
 
14
15
16
 
17
18
19
 
 
 
 
 
 
20
21
22
 
 
 
 
 
 
 
 
 
 
 
23
24
25
 
 
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
113
114
115
116
 
119
120
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
 
 
 
 
 
 
 
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
 
 
 
 
 
 
 
 
 
 
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
234
235
236
 
237
238
239
240
 
 
241
242
243
244
245
 
248
249
250
 
251
252
253
 
 
254
255
256
257
258
 
283
284
285
 
 
 
 
286
287
288
289
290
291
292
@@ -14,57 +14,103 @@
 from tortoisehg.util import hglib, shlib  from tortoisehg.hgqt.i18n import _   -from PyQt4.QtCore import Qt +from PyQt4.QtCore import Qt, QObject  from PyQt4.QtGui import *   -def wctxactions(parent, point, repo, selrows): - if not selrows: - return - alltypes = set() - for t, path in selrows: - alltypes |= t +class WctxActions(QObject): + 'container class for working context actions'   - def make(text, func, types, icon=None): - files = [f for t, f in selrows if t & types] - if not files: - return None - action = menu.addAction(text) - if icon: - action.setIcon(qtlib.getmenuicon(icon)) - action.args = (func, parent, files, repo) - action.run = lambda: run(*action.args) - action.triggered.connect(action.run) - return action + def __init__(self, repo, parent): + super(WctxActions, self).__init__(parent)   - if hasattr(parent, 'contextmenu'): - menu = parent.contextmenu + self.menu = QMenu(parent) + self.repo = repo + allactions = [] + + def make(text, func, types, icon=None, keys=None): + action = QAction(text, parent) + action._filetypes = types + action._runfunc = func + if icon: + action.setIcon(qtlib.getmenuicon(icon)) + if keys: + action.setShortcut(QKeySequence(keys)) + action.triggered.connect(self.runAction) + parent.addAction(action) + allactions.append(action) + + make(_('&Visual Diff'), vdiff, frozenset('MAR!'), 'visualdiff', 'CTRL+D') + make(_('Copy patch'), copyPatch, frozenset('MAR!'), 'copy-patch') + make(_('Edit'), edit, frozenset('MACI?'), 'edit-file', 'SHIFT+CTRL+E') + make(_('View missing'), viewmissing, frozenset('R!')) + allactions.append(None) + make(_('&Revert'), revert, frozenset('MAR!'), 'hg-revert') + make(_('&Add'), add, frozenset('R'), 'fileadd') + allactions.append(None) + make(_('File History'), log, frozenset('MARC!'), 'hg-log') + make(_('&Annotate'), annotate, frozenset('MARC!'), 'hg-annotate') + allactions.append(None) + make(_('&Forget'), forget, frozenset('MAC!'), 'filedelete') + make(_('&Add'), add, frozenset('I?'), 'fileadd') + make(_('&Detect Renames...'), guessRename, frozenset('A?!'), + 'detect_rename') + make(_('&Ignore'), ignore, frozenset('?'), 'ignore') + make(_('Remove versioned'), remove, frozenset('C'), 'remove') + make(_('&Delete unversioned'), delete, frozenset('?I'), 'hg-purge') + allactions.append(None) + make(_('Mark unresolved'), unmark, frozenset('r')) + make(_('Mark resolved'), mark, frozenset('u')) + self.allactions = allactions + + def updateActionSensitivity(self, selrows): + 'Enable/Disable permanent actions based on current selection' + self.selrows = selrows + alltypes = set() + for types, wfile in selrows: + alltypes |= types + for action in self.allactions: + if action is not None: + action.setEnabled(bool(action._filetypes & alltypes)) + + def makeMenu(self, selrows): + self.selrows = selrows + repo, menu = self.repo, self.menu + + alltypes = set() + for types, wfile in selrows: + alltypes |= types +   menu.clear() - else: - menu = QMenu(parent) - parent.contextmenu = menu - make(_('&Visual Diff'), vdiff, frozenset('MAR!'), 'visualdiff') - make(_('Copy patch'), copyPatch, frozenset('MAR!'), 'copy-patch') - make(_('Edit'), edit, frozenset('MACI?'), 'edit-file') - make(_('View missing'), viewmissing, frozenset('R!')) - if len(repo.parents()) > 1: - make(_('View other'), viewother, frozenset('MA')) - menu.addSeparator() - make(_('&Revert'), revert, frozenset('MAR!'), 'hg-revert') - make(_('&Add'), add, frozenset('R'), 'fileadd') - menu.addSeparator() - make(_('File History'), log, frozenset('MARC!'), 'hg-log') - make(_('&Annotate'), annotate, frozenset('MARC!'), 'hg-annotate') - menu.addSeparator() - make(_('&Forget'), forget, frozenset('MAC!'), 'filedelete') - make(_('&Add'), add, frozenset('I?'), 'fileadd') - make(_('&Detect Renames...'), guessRename, frozenset('A?!'), 'detect_rename') - make(_('&Ignore'), ignore, frozenset('?'), 'ignore') - make(_('Remove versioned'), remove, frozenset('C'), 'remove') - make(_('&Delete unversioned'), delete, frozenset('?I'), 'hg-purge') - if len(selrows) == 1: - menu.addSeparator() + addedActions = False + for action in self.allactions: + if action is None and addedActions: + menu.addSeparator() + addedActions = False + elif action._filetypes & alltypes: + menu.addAction(action) + addedActions = True + + def make(text, func, types, icon=None): + if not types & alltypes: + return + action = menu.addAction(text) + action._filetypes = types + action._runfunc = func + if icon: + action.setIcon(qtlib.getmenuicon(icon)) + action.triggered.connect(self.runAction) + + if len(repo.parents()) > 1: + make(_('View other'), viewother, frozenset('MA')) + + if len(selrows) == 1: + menu.addSeparator() + make(_('&Copy...'), copy, frozenset('MC'), 'edit-copy') + make(_('Rename...'), rename, frozenset('MC'), 'hg-rename') + + # Add 'was renamed from' actions for unknown files   t, path = selrows[0] - wctx = repo[None] + wctx = self.repo[None]   if t & frozenset('?') and wctx.deleted():   rmenu = QMenu(_('Was renamed from'))   for d in wctx.deleted()[:15]: @@ -73,63 +119,61 @@
  a.triggered.connect(lambda: renamefromto(repo, deleted, path))   mkaction(d)   menu.addMenu(rmenu) - else: - make(_('&Copy...'), copy, frozenset('MC'), 'edit-copy') - make(_('Rename...'), rename, frozenset('MC'), 'hg-rename') - menu.addSeparator() - make(_('Mark unresolved'), unmark, frozenset('r')) - make(_('Mark resolved'), mark, frozenset('u')) - f = make(_('Restart Merge...'), resolve, frozenset('u')) - if f: - files = [f for t, f in selrows if 'u' in t] - rmenu = QMenu(_('Restart merge with')) - for tool in hglib.mergetools(repo.ui): - def mkaction(rtool): - a = rmenu.addAction(hglib.tounicode(rtool)) - a.triggered.connect(lambda: resolve_with(rtool, repo, files)) - mkaction(tool) - menu.addMenu(rmenu) - return menu.exec_(point)   -def run(func, parent, files, repo): - 'run wrapper for all action methods' - hu = htmlui.htmlui() - name = func.__name__.title() - notify = False - cwd = os.getcwd() - try: - os.chdir(repo.root) + # Add restart merge actions for resolved files + if alltypes & frozenset('u'): + f = make(_('Restart Merge...'), resolve, frozenset('u')) + files = [f for t, f in selrows if 'u' in t] + rmenu = QMenu(_('Restart merge with')) + for tool in hglib.mergetools(repo.ui): + def mkaction(rtool): + a = rmenu.addAction(hglib.tounicode(rtool)) + a.triggered.connect(lambda: resolve_with(rtool, repo, files)) + mkaction(tool) + menu.addMenu(rmenu) + return menu + + def runAction(self): + 'run wrapper for all action methods' + + repo, action, parent = self.repo, self.sender(), self.parent() + func = action._runfunc + files = [wfile for t, wfile in self.selrows if t & action._filetypes] + + hu = htmlui.htmlui() + name = func.__name__.title() + notify = False + cwd = os.getcwd()   try: - # All operations should quietly succeed. Any error should - # result in a message box - notify = func(parent, hu, repo, files) - o, e = hu.getdata() - if e: - QMessageBox.warning(parent, name + _(' errors'), str(e)) - elif o: - QMessageBox.information(parent, name + _(' output'), str(o)) - elif notify: - wfiles = [repo.wjoin(x) for x in files] - shlib.shell_notify(wfiles) - except (IOError, OSError), e: - err = hglib.tounicode(str(e)) - QMessageBox.critical(parent, name + _(' Aborted'), err) - except util.Abort, e: - if e.hint: - err = _('%s (hint: %s)') % (hglib.tounicode(str(e)), - hglib.tounicode(e.hint)) - else: + os.chdir(repo.root) + try: + # All operations should quietly succeed. Any error should + # result in a message box + notify = func(parent, hu, repo, files) + o, e = hu.getdata() + if e: + QMessageBox.warning(parent, name + _(' errors'), str(e)) + elif o: + QMessageBox.information(parent, name + _(' output'), str(o)) + elif notify: + wfiles = [repo.wjoin(x) for x in files] + shlib.shell_notify(wfiles) + except (IOError, OSError), e:   err = hglib.tounicode(str(e)) - QMessageBox.critical(parent, name + _(' Aborted'), err) - except (error.LookupError), e: - err = hglib.tounicode(str(e)) - QMessageBox.critical(parent, name + _(' Aborted'), err) - except NotImplementedError: - QMessageBox.critical(parent, name + _(' not implemented'), - 'Please add it :)') - finally: - os.chdir(cwd) - return notify + QMessageBox.critical(parent, name + _(' Aborted'), err) + except util.Abort, e: + if e.hint: + err = _('%s (hint: %s)') % (hglib.tounicode(str(e)), + hglib.tounicode(e.hint)) + else: + err = hglib.tounicode(str(e)) + QMessageBox.critical(parent, name + _(' Aborted'), err) + except (error.LookupError), e: + err = hglib.tounicode(str(e)) + QMessageBox.critical(parent, name + _(' Aborted'), err) + finally: + os.chdir(cwd) + return notify    def renamefromto(repo, deleted, unknown):   repo[None].copy(deleted, unknown) @@ -190,12 +234,12 @@
  cmdline = ' '.join([editor] + files)   else:   editor = os.environ.get('HGEDITOR') or ui.config('ui', 'editor') or \ - os.environ.get('EDITOR', 'vi') + os.environ.get('EDITOR', 'vi')   cmdline = ' '.join([editor] + files)   if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'):   res = QMessageBox.critical(parent, - _('No visual editor configured'), - _('Please configure a visual editor.')) + _('No visual editor configured'), + _('Please configure a visual editor.'))   from tortoisehg.hgqt.settings import SettingsDialog   dlg = SettingsDialog(False, focus='tortoisehg.editor')   dlg.exec_() @@ -204,11 +248,11 @@
  cmdline = util.quotecommand(cmdline)   try:   subprocess.Popen(cmdline, shell=True, creationflags=visdiff.openflags, - stderr=None, stdout=None, stdin=None) + stderr=None, stdout=None, stdin=None)   except (OSError, EnvironmentError), e:   QMessageBox.warning(parent, - _('Editor launch failure'), - _('%s : %s') % (cmd, str(e))) + _('Editor launch failure'), + _('%s : %s') % (cmd, str(e)))   return False     @@ -239,10 +283,10 @@
  commands.revert(ui, repo, *files, **revertopts)   else:   res = qtlib.CustomPrompt( - _('Confirm Revert'), - _('Revert local file changes?'), parent, - (_('&Revert with backup'), _('&Discard changes'), - _('Cancel')), 2, 2, files).run() + _('Confirm Revert'), + _('Revert local file changes?'), parent, + (_('&Revert with backup'), _('&Discard changes'), + _('Cancel')), 2, 2, files).run()   if res == 2:   return False   if res == 1:
 
348
349
350
351
 
 
 
 
 
 
 
 
352
353
354
 
483
484
485
486
 
487
488
489
 
348
349
350
 
351
352
353
354
355
356
357
358
359
360
361
 
490
491
492
 
493
494
495
496
@@ -348,7 +348,14 @@
  repopath = hglib.fromunicode(repopath)   self._openRepo(path=repopath, reuse=reuse)   - @pyqtSlot(unicode) + @pyqtSlot(QString) + def openLinkedRepo(self, path): + self.showRepo(path) + rw = self.repoTabsWidget.currentWidget() + if rw: + rw.taskTabsWidget.setCurrentIndex(rw.commitTabIndex) + + @pyqtSlot(QString)   def showRepo(self, path):   """Activate the repo tab or open it if not available [unicode]"""   for i in xrange(self.repoTabsWidget.count()): @@ -483,7 +490,7 @@
  rw.output.connect(self.log.output)   rw.makeLogVisible.connect(self.log.setShown)   rw.revisionSelected.connect(self.updateHistoryActions) - rw.repoLinkClicked.connect(self.showRepo) + rw.repoLinkClicked.connect(self.openLinkedRepo)   rw.taskTabsWidget.currentChanged.connect(self.updateTaskViewMenu)   rw.toolbarVisibilityChanged.connect(self.updateToolBarActions)