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

logcolumns: allow different log columns in workbench, file history, file diff

Closes #454, #490

Changeset a9011b36e99e

Parent a8d27ba47d50

by Phil Currier

Changes to 7 files · Browse files at a9011b36e99e Showing diff from parent a8d27ba47d50 Diff from another changeset...

 
120
121
122
123
124
 
 
125
126
127
 
146
147
148
149
 
 
 
150
151
152
 
315
316
317
318
319
 
 
 
320
321
 
 
322
323
324
 
406
407
408
409
 
 
 
410
411
412
 
120
121
122
 
 
123
124
125
126
127
 
146
147
148
 
149
150
151
152
153
154
 
317
318
319
 
 
320
321
322
323
 
324
325
326
327
328
 
410
411
412
 
413
414
415
416
417
418
@@ -120,8 +120,8 @@
    self.splitter = QSplitter(Qt.Vertical)   self.setCentralWidget(self.splitter) - self.repoview = repoview.HgRepoView(self.repo, 'fileLogDialog', - self.splitter) + cs = ('fileLogDialog', _('File History Log Columns')) + self.repoview = repoview.HgRepoView(self.repo, cs[0], cs, self.splitter)   self.contentframe = QFrame(self.splitter)     vbox = QVBoxLayout() @@ -146,7 +146,9 @@
  self.editToolbar.addAction(self.actionForward)     def setupModels(self): - self.filerevmodel = filerevmodel.FileRevModel(self.repo, parent=self) + self.filerevmodel = filerevmodel.FileRevModel(self.repo, + self.repoview.colselect[0], + parent=self)   self.repoview.setModel(self.filerevmodel)   self.repoview.revisionSelected.connect(self.onRevisionSelected)   self.repoview.revisionActivated.connect(self.onRevisionActivated) @@ -315,10 +317,12 @@
  self.splitter = QSplitter(Qt.Vertical)   self.setCentralWidget(self.splitter)   self.horizontalLayout = QHBoxLayout() - self.tableView_revisions_left = repoview.HgRepoView(self.repo, - 'fileDiffDialogLeft', self) + cs = ('fileDiffDialogLeft', _('File Differences Log Columns')) + self.tableView_revisions_left = repoview.HgRepoView(self.repo, cs[0], + cs, self)   self.tableView_revisions_right = repoview.HgRepoView(self.repo, - 'fileDiffDialogRight', self) + 'fileDiffDialogRight', + cs, self)   self.horizontalLayout.addWidget(self.tableView_revisions_left)   self.horizontalLayout.addWidget(self.tableView_revisions_right)   self.frame = QFrame() @@ -406,7 +410,9 @@
  def setupModels(self):   self.filedata = {'left': None, 'right': None}   self._invbarchanged = False - self.filerevmodel = filerevmodel.FileRevModel(self.repo, self.filename, parent=self) + self.filerevmodel = filerevmodel.FileRevModel(self.repo, + self.tableView_revisions_left.colselect[0], + self.filename, parent=self)   self.filerevmodel.filled.connect(self.modelFilled)   self.tableView_revisions_left.setModel(self.filerevmodel)   self.tableView_revisions_right.setModel(self.filerevmodel)
 
14
15
16
17
 
18
19
20
21
22
 
 
 
 
 
 
23
24
25
 
27
28
29
30
31
 
 
 
32
33
34
35
36
 
37
38
39
40
41
 
42
43
44
 
14
15
16
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
33
34
35
 
 
36
37
38
39
40
41
42
 
43
44
45
46
 
 
47
48
49
50
@@ -14,12 +14,18 @@
 # this program; if not, write to the Free Software Foundation, Inc.,  # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   -from tortoisehg.hgqt.repomodel import HgRepoListModel, COLUMNNAMES +from tortoisehg.hgqt.repomodel import HgRepoListModel, COLUMNHEADERS  from tortoisehg.hgqt.graph import Graph, filelog_grapher  from tortoisehg.hgqt.i18n import _    from PyQt4.QtCore import *   +FILE_HEADERS = (('Filename', _('Filename', 'column header')),) +UNUSED_HEADERS = ('Graph', 'Changes') + +FILE_COLUMNHEADERS = tuple(c for c in COLUMNHEADERS + if c[0] not in UNUSED_HEADERS) + FILE_HEADERS +  class FileRevModel(HgRepoListModel):   """   Model used to manage the list of revisions of a file, in file @@ -27,18 +33,18 @@
  """   filled = pyqtSignal()   - _allcolumns = ('Rev', 'Branch', 'Description', 'Author', 'Age', - 'LocalTime', 'UTCTime', 'Tags', 'Filename') + _allcolumns = tuple(h[0] for h in FILE_COLUMNHEADERS) + _allcolnames = dict(FILE_COLUMNHEADERS) +   _columns = ('Rev', 'Branch', 'Description', 'Author', 'Age', 'Filename')   _stretchs = {'Description': 1, }   _getcolumns = "getFilelogColumns"   - def __init__(self, repo, filename=None, parent=None): + def __init__(self, repo, cfgname, filename=None, parent=None):   """   data is a HgHLRepo instance   """ - HgRepoListModel.__init__(self, repo, '', [], False, parent) - COLUMNNAMES['Filename'] = _('Filename', 'column header') + HgRepoListModel.__init__(self, repo, cfgname, '', [], False, parent)   self.setFilename(filename)     def setRepo(self, repo, branch='', fromhead=None, follow=False):
 
16
17
18
19
 
20
 
 
 
 
 
 
 
 
21
22
 
23
24
25
26
27
 
28
29
30
 
31
32
 
 
33
34
35
 
41
42
43
44
 
45
46
47
 
51
52
53
54
 
55
56
57
 
81
82
83
84
 
85
86
87
88
89
90
91
 
 
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
 
50
51
52
 
53
54
55
56
 
60
61
62
 
63
64
65
66
 
90
91
92
 
93
94
95
96
97
98
99
 
100
@@ -16,20 +16,29 @@
 from PyQt4.QtGui import *    class ColumnSelectDialog(QDialog): - def __init__(self, all, curcolumns=None, parent=None): + def __init__(self, cfgname, name, model, parent=None):   QDialog.__init__(self, parent) + if model: + all = model._allcolumns + colnames = model._allcolnames + self.curcolumns = model._columns + else: + all = repomodel.HgRepoListModel._allcolumns + colnames = repomodel.HgRepoListModel._allcolnames + self.curcolumns = None   - self.setWindowTitle(_('Workbench Log Columns')) + self.setWindowTitle(name)   self.setWindowFlags(self.windowFlags() & \   ~Qt.WindowContextHelpButtonHint)   self.setMinimumSize(250, 265)   - self.curcolumns = curcolumns + self.cfgname = cfgname   if not self.curcolumns:   s = QSettings() - cols = s.value('workbench/columns').toStringList() + cols = s.value(self.cfgname + '/columns').toStringList()   if cols: - self.curcolumns = [c for c in cols if c in all] + self.curcolumns = [hglib.fromunicode(c) + for c in cols if c in all]   else:   self.curcolumns = all   self.disabled = [c for c in all if c not in self.curcolumns] @@ -41,7 +50,7 @@
  list = QListWidget()   # enabled cols are listed in sorted order   for c in self.curcolumns: - item = QListWidgetItem(repomodel.COLUMNNAMES[c]) + item = QListWidgetItem(colnames[c])   item.columnid = c   item.setFlags(Qt.ItemIsSelectable |   Qt.ItemIsEnabled | @@ -51,7 +60,7 @@
  list.addItem(item)   # disabled cols are listed last   for c in self.disabled: - item = QListWidgetItem(repomodel.COLUMNNAMES[c]) + item = QListWidgetItem(colnames[c])   item.columnid = c   item.setFlags(Qt.ItemIsSelectable |   Qt.ItemIsEnabled | @@ -81,11 +90,11 @@
  item = self.list.item(i)   if item.checkState() == Qt.Checked:   cols.append(item.columnid) - s.setValue('workbench/columns', cols) + s.setValue(self.cfgname + '/columns', cols)   QDialog.accept(self)     def reject(self):   QDialog.reject(self)    def run(ui, *pats, **opts): - return ColumnSelectDialog(repomodel.ALLCOLUMNS) + return ColumnSelectDialog('workbench', _('Workbench'), None)
 
49
50
51
52
53
54
55
56
57
58
 
74
75
76
 
 
 
77
78
79
80
81
 
82
83
84
 
94
95
96
 
97
98
99
 
142
143
144
145
 
146
147
148
149
150
 
151
152
153
154
 
 
155
156
157
 
474
475
476
477
 
478
479
480
 
49
50
51
 
 
 
 
52
53
54
 
70
71
72
73
74
75
76
77
78
79
 
80
81
82
83
 
93
94
95
96
97
98
99
 
142
143
144
 
145
146
147
148
149
 
150
151
152
 
 
153
154
155
156
157
 
474
475
476
 
477
478
479
480
@@ -49,10 +49,6 @@
  ('Changes', _('Changes', 'column header')),   )   -COLUMNNAMES = dict(COLUMNHEADERS) - -ALLCOLUMNS = [h[0] for h in COLUMNHEADERS] -  UNAPPLIED_PATCH_COLOR = '#999999'    def get_color(n, ignore=()): @@ -74,11 +70,14 @@
  filled = pyqtSignal()   loaded = pyqtSignal()   + _allcolumns = tuple(h[0] for h in COLUMNHEADERS) + _allcolnames = dict(COLUMNHEADERS) +   _columns = ('Graph', 'Rev', 'Branch', 'Description', 'Author', 'Age', 'Tags',)   _stretchs = {'Description': 1, }   _mqtags = ('qbase', 'qtip', 'qparent')   - def __init__(self, repo, branch, revset, rfilter, parent): + def __init__(self, repo, cfgname, branch, revset, rfilter, parent):   """   repo is a hg repo instance   """ @@ -94,6 +93,7 @@
  self.filterbyrevset = rfilter   self.unicodestar = True   self.unicodexinabox = True + self.cfgname = cfgname     # To be deleted   self._user_colors = {} @@ -142,16 +142,16 @@
    def updateColumns(self):   s = QSettings() - cols = s.value('workbench/columns').toStringList() + cols = s.value(self.cfgname + '/columns').toStringList()   cols = [str(col) for col in cols]   # Fixup older names for columns   if 'Log' in cols:   cols[cols.index('Log')] = 'Description' - s.setValue('workbench/columns', cols) + s.setValue(self.cfgname + '/columns', cols)   if 'ID' in cols:   cols[cols.index('ID')] = 'Rev' - s.setValue('workbench/columns', cols) - validcols = [col for col in cols if col in ALLCOLUMNS] + s.setValue(self.cfgname + '/columns', cols) + validcols = [col for col in cols if col in self._allcolumns]   if validcols:   self._columns = tuple(validcols)   self.invalidateCache() @@ -474,7 +474,7 @@
  def headerData(self, section, orientation, role):   if orientation == Qt.Horizontal:   if role == Qt.DisplayRole: - return QVariant(COLUMNNAMES[self._columns[section]]) + return QVariant(self._allcolnames[self._columns[section]])   if role == Qt.TextAlignmentRole:   return QVariant(Qt.AlignLeft)   return nullvariant
 
19
20
21
 
22
23
24
25
 
 
 
 
 
26
27
28
 
32
33
34
35
 
36
37
38
39
40
 
41
42
43
44
45
46
47
 
 
 
 
 
 
48
49
50
 
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
74
75
 
129
130
131
 
 
 
 
 
 
132
133
134
 
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
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
 
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 
158
159
160
161
162
163
164
165
166
167
168
169
@@ -19,10 +19,16 @@
 from tortoisehg.util import hglib  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt import htmldelegate +from tortoisehg.hgqt.logcolumns import ColumnSelectDialog    from PyQt4.QtCore import *  from PyQt4.QtGui import *   +class HgRepoViewHeader(QHeaderView): + menuRequested = pyqtSignal(QPoint) + def contextMenuEvent(self, event): + self.menuRequested.emit(event.globalPos()) +  class HgRepoView(QTableView):     revisionClicked = pyqtSignal(object) @@ -32,19 +38,25 @@
  menuRequested = pyqtSignal(QPoint, object)   showMessage = pyqtSignal(unicode)   - def __init__(self, repo, cfgname, parent=None): + def __init__(self, repo, cfgname, colselect, parent=None):   QTableView.__init__(self, parent)   self.repo = repo   self.current_rev = -1   self.resized = False   self.cfgname = cfgname + self.colselect = colselect   self.setShowGrid(False)     vh = self.verticalHeader()   vh.hide()   vh.setDefaultSectionSize(20)   - self.horizontalHeader().setHighlightSections(False) + header = HgRepoViewHeader(Qt.Horizontal, self) + header.setHighlightSections(False) + header.menuRequested.connect(self.headerMenuRequest) + self.setHorizontalHeader(header) + + self.createActions()     self.standardDelegate = self.itemDelegate()   self.htmlDelegate = htmldelegate.HTMLDelegate(self) @@ -70,6 +82,23 @@
  def contextMenuEvent(self, event):   self.menuRequested.emit(event.globalPos(), self.selectedRevisions())   + def createActions(self): + menu = QMenu(self) + act = QAction(_('Choose log columns...'), self) + act.triggered.connect(self.setHistoryColumns) + menu.addAction(act) + self.headermenu = menu + + def headerMenuRequest(self, point): + self.headermenu.exec_(point) + + def setHistoryColumns(self): + dlg = ColumnSelectDialog(self.colselect[0], self.colselect[1], + self.model()) + if dlg.exec_() == QDialog.Accepted: + self.model().updateColumns() + self.resizeColumns() +   def setModel(self, model):   QTableView.setModel(self, model)   #Check if the font contains the glyph needed by the model @@ -129,6 +158,12 @@
  key = '%s/column_widths/%s' % (self.cfgname, str(self.repo[0]))   col_widths = [int(w) for w in QSettings().value(key).toStringList()]   + if len(model._columns) <> len(col_widths): + # If the columns and widths don't match, use the calculated + # widths as they will probably be a better fit (likely because + # columns were changed without updating the widths) + col_widths = [] +   for c in range(model.columnCount(QModelIndex())):   if c < len(col_widths) and col_widths[c] > 0:   w = col_widths[c]
 
132
133
134
135
 
 
136
137
138
 
606
607
608
609
 
 
610
611
612
 
779
780
781
782
 
 
 
783
784
785
 
132
133
134
 
135
136
137
138
139
 
607
608
609
 
610
611
612
613
614
 
781
782
783
 
784
785
786
787
788
789
@@ -132,7 +132,8 @@
    self.layout().addWidget(self.repotabs_splitter)   - self.repoview = view = HgRepoView(self.repo, 'repoWidget', self) + cs = ('workbench', _('Workbench Log Columns')) + self.repoview = view = HgRepoView(self.repo, 'repoWidget', cs, self)   view.revisionClicked.connect(self.onRevisionClicked)   view.revisionSelected.connect(self.onRevisionSelected)   view.revisionAltClicked.connect(self.onRevisionSelected) @@ -606,7 +607,8 @@
  # Filter revision set in case revisions were removed   self.revset = [r for r in self.revset if r < len(self.repo)]   branch = hglib.fromunicode(self.ubranch) - self.repomodel = HgRepoListModel(self.repo, branch, self.revset, + self.repomodel = HgRepoListModel(self.repo, self.repoview.colselect[0], + branch, self.revset,   self.revsetfilter, self)   self.repomodel.filled.connect(self.modelFilled)   self.repomodel.loaded.connect(self.modelLoaded) @@ -779,7 +781,9 @@
  self.rebuildGraph()   except (error.RevlogError, error.RepoError), e:   self.showMessage(hglib.tounicode(str(e))) - self.repomodel = HgRepoListModel(None, None, None, False, self) + self.repomodel = HgRepoListModel(None, + self.repoview.colselect[0], + None, None, False, self)   self.repoview.setModel(self.repomodel)   else:   self.dirty = True
 
14
15
16
17
 
18
19
20
 
639
640
641
642
643
 
 
644
645
646
 
14
15
16
 
17
18
19
20
 
639
640
641
 
 
642
643
644
645
646
@@ -14,7 +14,7 @@
 from mercurial.error import RepoError  from tortoisehg.util import paths, hglib   -from tortoisehg.hgqt import repomodel, thgrepo, cmdui, qtlib +from tortoisehg.hgqt import thgrepo, cmdui, qtlib  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt.repowidget import RepoWidget  from tortoisehg.hgqt.reporegistry import RepoRegistryView @@ -639,8 +639,8 @@
  def setHistoryColumns(self, *args):   """Display the column selection dialog"""   w = self.repoTabsWidget.currentWidget() - dlg = ColumnSelectDialog(repomodel.ALLCOLUMNS, - w and w.repoview.model()._columns) + dlg = ColumnSelectDialog('workbench', _('Workbench'), + w and w.repoview.model() or None)   if dlg.exec_() == QDialog.Accepted:   if w:   w.repoview.model().updateColumns()