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

stable revdetails: add a 'second parent' toggle action for files that were merged

This change also has the side effect of making merged files displayed with a
bold font even if we are not displaying all the files in the merge. I thought
this was appropriate.

Changeset 242b524cd771

Parent ee45228c8376

by Steve Borho

Changes to 3 files · Browse files at 242b524cd771 Showing diff from parent ee45228c8376 Diff from another changeset...

 
42
43
44
 
45
46
47
 
49
50
51
 
 
 
 
 
52
53
54
 
68
69
70
71
72
73
74
75
76
77
78
79
 
81
82
83
84
85
86
87
88
89
90
91
92
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
95
96
 
102
103
104
105
 
 
106
107
108
109
110
111
112
113
114
115
 
 
 
116
117
118
 
124
125
126
127
128
129
130
131
132
 
142
143
144
145
146
 
 
147
148
149
150
151
152
153
 
154
155
 
156
 
 
157
158
 
159
160
161
 
42
43
44
45
46
47
48
 
50
51
52
53
54
55
56
57
58
59
60
 
74
75
76
 
 
 
 
 
 
77
78
79
 
81
82
83
 
 
 
 
 
 
 
 
 
 
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
108
109
110
 
111
112
113
114
115
116
117
 
 
 
 
 
118
119
120
121
122
123
 
129
130
131
 
 
 
132
133
134
 
144
145
146
 
 
147
148
149
150
151
152
153
154
 
155
156
 
157
158
159
160
161
 
162
163
164
165
@@ -42,6 +42,7 @@
  self._files = []   self._filesdict = {}   self._fulllist = False + self._secondParent = False     @pyqtSlot(bool)   def toggleFullFileList(self, value): @@ -49,6 +50,11 @@
  self.loadFiles()   self.layoutChanged.emit()   + @pyqtSlot(bool) + def toggleSecondParent(self, value): + self._secondParent = value + self.layoutChanged.emit() +   def __len__(self):   return len(self._files)   @@ -68,12 +74,6 @@
  self.loadFiles()   self.layoutChanged.emit()   - def flagFromIndex(self, index): - if not index.isValid() or index.row()>=len(self) or not self._ctx: - return None - row = index.row() - return self._files[row]['flag'] -   def fileFromIndex(self, index):   if not index.isValid() or index.row()>=len(self) or not self._ctx:   return None @@ -81,16 +81,22 @@
  return self._files[row]['path']     def revFromIndex(self, index): - if self.showingFullList(): - if not index.isValid() or index.row()>=len(self) or not self._ctx: - return None - row = index.row() - current_file_desc = self._files[row] - if current_file_desc['parent'] == 1: - return self._ctx.parents()[1].rev() - else: - return self._ctx.parents()[0].rev() - return None + 'return revision for index. index is guarunteed to be valid' + if not bool(self._ctx.p2()): + return self._ctx.p1().rev() + row = index.row() + data = self._files[row] + if (data['wasmerged'] and self._secondParent) or \ + (data['parent'] == 1 and self._fulllist): + return self._ctx.p2().rev() + else: + return self._ctx.p1().rev() + + def dataFromIndex(self, index): + if not index.isValid() or index.row()>=len(self) or not self._ctx: + return None + row = index.row() + return self._files[row]     def indexFromFile(self, filename):   if filename in self._filesdict: @@ -102,17 +108,16 @@
  files = []   ctxfiles = self._ctx.files()   modified, added, removed = self._ctx.changesToParent(parent) - if self.showingFullList(): + ismerge = bool(self._ctx.p2()) + if self._fulllist and ismerge:   func = lambda x: True   else:   func = lambda x: x in ctxfiles   for lst, flag in ((added, 'A'), (modified, 'M'), (removed, 'R')):   for f in filter(func, lst): - files.append({'path': f, 'flag': flag, - 'parent': parent, - 'infiles': f in ctxfiles}) - # renamed/copied files are handled by background - # filling process since it can be a bit long + wasmerged = ismerge and f in ctxfiles + files.append({'path': f, 'status': flag, 'parent': parent, + 'wasmerged': wasmerged})   return files     def loadFiles(self): @@ -124,9 +129,6 @@
  self._files += [x for x in _files if x['path'] not in _paths]   self._filesdict = dict([(f['path'], f) for f in self._files])   - def showingFullList(self): - return self._fulllist and bool(self._ctx.p2()) -   def data(self, index, role):   if not index.isValid() or index.row()>len(self) or not self._ctx:   return nullvariant @@ -142,20 +144,22 @@
  if role in (Qt.DisplayRole, Qt.ToolTipRole):   return QVariant(hglib.tounicode(current_file))   elif role == Qt.DecorationRole: - if self.showingFullList(): - if current_file_desc['infiles']: + if self._fulllist and bool(self._ctx.p2()): + if current_file_desc['wasmerged']:   icn = geticon('leftright')   elif current_file_desc['parent'] == 0:   icn = geticon('left')   elif current_file_desc['parent'] == 1:   icn = geticon('right')   return QVariant(icn.pixmap(20,20)) - elif current_file_desc['flag'] == 'A': + elif current_file_desc['status'] == 'A':   return QVariant(geticon('fileadd')) - elif current_file_desc['flag'] == 'R': + elif current_file_desc['status'] == 'R':   return QVariant(geticon('filedelete')) + #else: + # return QVariant(geticon('view-diff'))   elif role == Qt.FontRole: - if current_file_desc['infiles'] and self.showingFullList(): + if current_file_desc['wasmerged']:   return QVariant(self._boldfont)   else:   return nullvariant
 
58
59
60
 
 
61
62
63
 
70
71
72
 
73
74
 
75
76
77
 
89
90
91
92
93
94
95
96
 
 
 
 
 
97
98
 
99
100
101
 
103
104
105
106
 
107
108
 
109
110
 
111
112
113
 
194
195
196
197
 
198
199
200
 
 
 
 
 
201
202
203
 
58
59
60
61
62
63
64
65
 
72
73
74
75
76
77
78
79
80
81
 
93
94
95
 
 
 
 
 
96
97
98
99
100
101
102
103
104
105
106
 
108
109
110
 
111
112
 
113
114
 
115
116
117
118
 
199
200
201
 
202
203
204
205
206
207
208
209
210
211
212
213
@@ -58,6 +58,8 @@
  self.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)   self.actionShowAllMerge.setChecked(False)   self.actionShowAllMerge.toggled.connect(model.toggleFullFileList) + self.actionSecondParent.setChecked(False) + self.actionSecondParent.toggled.connect(model.toggleSecondParent)   if model._ctx is not None:   self.contextChanged(model._ctx)   @@ -70,8 +72,10 @@
  self._actions[act].setEnabled(real or wd)   if len(ctx.parents()) == 2:   self.actionShowAllMerge.setVisible(True) + self.actionSecondParent.setVisible(True)   else:   self.actionShowAllMerge.setVisible(False) + self.actionSecondParent.setVisible(False)     def currentFile(self):   index = self.currentIndex() @@ -89,13 +93,14 @@
  def fileSelected(self, index=None, *args):   if index is None:   index = self.currentIndex() - sel_file = self.model().fileFromIndex(index) - from_rev = self.model().revFromIndex(index) - status = self.model().flagFromIndex(index) - if sel_file: - self.fileRevSelected.emit(sel_file, from_rev, status) + data = self.model().dataFromIndex(index) + if data: + fromRev = self.model().revFromIndex(index) + self.fileRevSelected.emit(data['path'], fromRev, data['status']) + self.actionSecondParent.setEnabled(data['wasmerged'])   else:   self.clearDisplay.emit() + self.actionSecondParent.setEnabled(False)     def selectFile(self, filename):   index = self.model().indexFromFile(filename) @@ -103,11 +108,11 @@
  self.fileSelected(index)     def fileActivated(self, index, alternate=False): - sel_file = self.model().fileFromIndex(index) + selFile = self.model().fileFromIndex(index)   if alternate: - self.navigate(sel_file) + self.navigate(selFile)   else: - self.diffNavigate(sel_file) + self.diffNavigate(selFile)     def navigate(self, filename=None):   self._navigate(filename, FileLogDialog, self._nav_dialogs) @@ -194,10 +199,15 @@
  dlg.activateWindow()     def createActions(self): - self.actionShowAllMerge = QAction('Show All', self) + self.actionShowAllMerge = QAction(_('Show All'), self)   self.actionShowAllMerge.setCheckable(True)   self.actionShowAllMerge.setChecked(False)   self.actionShowAllMerge.setVisible(False) + self.actionSecondParent = QAction(_('Other'), self) + self.actionSecondParent.setCheckable(True) + self.actionSecondParent.setChecked(False) + self.actionSecondParent.setVisible(False) + self.actionSecondParent.setEnabled(False)     self._actions = {}   for name, desc, icon, key, tip, cb in [
 
176
177
178
 
179
180
181
 
176
177
178
179
180
181
182
@@ -176,6 +176,7 @@
  Qt.ALT+Qt.Key_Enter])   self.actionActivateFileAlt.triggered.connect(fileActivated)   self.mergeToolBar.addAction(self.filelist.actionShowAllMerge) + self.mergeToolBar.addAction(self.filelist.actionSecondParent)     self.actionNextLine = QAction('Next line', self)   self.actionNextLine.setShortcut(Qt.SHIFT + Qt.Key_Down)