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

status: Show merge status column, when appropriate

Changeset 0c3cd84a2168

Parent 2733efd91294

by Steve Borho

Changes to one file · Browse files at 0c3cd84a2168 Showing diff from parent 2733efd91294 Diff from another changeset...

 
7
8
9
10
 
11
12
13
 
21
22
23
24
25
26
27
 
46
47
48
 
49
50
51
 
95
96
97
 
98
99
100
 
117
118
119
120
 
121
122
123
124
125
126
127
128
 
 
 
129
130
131
 
222
223
224
225
226
 
 
 
227
228
229
 
250
251
252
253
 
254
255
256
257
 
 
258
259
 
 
260
261
 
 
262
263
 
 
264
265
266
 
267
268
269
 
270
271
272
 
273
274
275
276
 
277
278
 
279
280
281
282
283
 
298
299
300
301
 
302
303
304
305
306
 
 
 
 
 
 
307
308
309
 
320
321
322
 
 
 
 
 
 
323
324
325
 
7
8
9
 
10
11
12
13
 
21
22
23
 
24
25
26
 
45
46
47
48
49
50
51
 
95
96
97
98
99
100
101
 
118
119
120
 
121
122
123
124
125
126
 
 
 
127
128
129
130
131
132
 
223
224
225
 
 
226
227
228
229
230
231
 
252
253
254
 
255
256
257
258
 
259
260
261
 
262
263
264
 
265
266
267
 
268
269
270
271
 
272
273
274
 
275
276
277
 
278
279
280
281
 
282
283
284
285
286
 
287
288
289
 
304
305
306
 
307
308
309
310
311
 
312
313
314
315
316
317
318
319
320
 
331
332
333
334
335
336
337
338
339
340
341
342
@@ -7,7 +7,7 @@
   import os   -from mercurial import ui, hg, util, patch, cmdutil, error, mdiff, context +from mercurial import ui, hg, util, patch, cmdutil, error, mdiff, context, merge  from tortoisehg.hgqt import qtlib, htmlui, chunkselect  from tortoisehg.util import paths, hglib  from tortoisehg.util.i18n import _ @@ -21,7 +21,6 @@
 # working copy browser.    # Technical Debt -# Show merge status column, when appropriate  # Thread refreshWctx, connect to an external progress bar  # Thread rowSelected, connect to an external progress bar  # Need mechanisms to clear pats and toggle visibility options @@ -46,6 +45,7 @@
  self.opts = dict(unknown=True, clean=False, ignored=False)   self.opts.update(opts)   self.pats = pats + self.ms = {}     # determine the user configured status colors   # (in the future, we could support full rich-text tags) @@ -95,6 +95,7 @@
    def refreshWctx(self):   hglib.invalidaterepo(self.repo) + self.ms = merge.mergestate(self.repo)   extract = lambda x, y: dict(zip(x, map(y.get, x)))   stopts = extract(('unknown', 'ignored', 'clean'), self.opts)   if self.pats: @@ -117,15 +118,15 @@
  return bool(self.wctx.p2())     def updateModel(self): - tm = WctxModel(self.wctx, self.opts) + tm = WctxModel(self.wctx, self.ms, self.opts)   self.tv.setModel(tm)   self.tv.setItemsExpandable(False)   self.tv.setRootIsDecorated(False)   self.tv.setSortingEnabled(True)   self.tv.sortByColumn(COL_PATH_DISPLAY) - self.tv.resizeColumnToContents(COL_CHECK) - self.tv.resizeColumnToContents(COL_STATUS) - self.tv.resizeColumnToContents(COL_PATH_DISPLAY) + for col in xrange(COL_PATH): + self.tv.resizeColumnToContents(col) + self.tv.setColumnHidden(COL_MERGE_STATE, not tm.anyMerge())   self.connect(self.tv, SIGNAL('activated(QModelIndex)'), tm.toggleRow)   self.connect(self.tv, SIGNAL('pressed(QModelIndex)'), tm.pressedRow)   @@ -222,8 +223,9 @@
   COL_CHECK = 0  COL_STATUS = 1 -COL_PATH_DISPLAY = 2 -COL_PATH = 3 +COL_MERGE_STATE = 2 +COL_PATH_DISPLAY = 3 +COL_PATH = 4    tips = {   'M': _('%s is modified'), @@ -250,34 +252,38 @@
 colors = {}    class WctxModel(QAbstractTableModel): - def __init__(self, wctx, opts, parent=None): + def __init__(self, wctx, ms, opts, parent=None):   QAbstractTableModel.__init__(self, parent)   rows = []   for m in wctx.modified(): - rows.append([True, 'M', hglib.tounicode(m), m]) + mst = m in ms and ms[m].upper() or "" + rows.append([True, 'M', mst, hglib.tounicode(m), m])   for a in wctx.added(): - rows.append([True, 'A', hglib.tounicode(a), a]) + mst = a in ms and ms[a].upper() or "" + rows.append([True, 'A', mst, hglib.tounicode(a), a])   for r in wctx.removed(): - rows.append([True, 'R', hglib.tounicode(r), r]) + mst = r in ms and ms[r].upper() or "" + rows.append([True, 'R', mst, hglib.tounicode(r), r])   for d in wctx.deleted(): - rows.append([False, '!', hglib.tounicode(d), d]) + mst = d in ms and ms[d].upper() or "" + rows.append([False, '!', mst, hglib.tounicode(d), d])   if opts['unknown']:   for u in wctx.unknown(): - rows.append([False, '?', hglib.tounicode(u), u]) + rows.append([False, '?', '', hglib.tounicode(u), u])   if opts['ignored']:   for i in wctx.ignored(): - rows.append([False, 'I', hglib.tounicode(i), i]) + rows.append([False, 'I', '', hglib.tounicode(i), i])   if opts['clean']:   for c in wctx.clean(): - rows.append([False, 'C', hglib.tounicode(c), c]) + rows.append([False, 'C', '', hglib.tounicode(c), c])   try:   for s in wctx.substate:   if wctx.sub(s).dirty(): - rows.append([False, 'S', hglib.tounicode(s), s]) + rows.append([False, 'S', '', hglib.tounicode(s), s])   except (OSError, IOError, error.ConfigError), e:   self.status_error = str(e) + self.headers = ('*', _('Stat'), _('M'), _('Filename'))   self.rows = rows - self.headers = ('*', _('Stat'), _('Filename'))     def rowCount(self, parent):   return len(self.rows) @@ -298,12 +304,17 @@
  elif role == Qt.DisplayRole:   return QVariant(self.rows[index.row()][index.column()])   - checked, status, upath, path = self.rows[index.row()] + checked, status, mst, upath, path = self.rows[index.row()]   if role == Qt.TextColorRole:   return colors.get(status, QColor('black'))   elif role == Qt.ToolTipRole:   if status in tips: - return QVariant(tips[status] % upath) + tip = tips[status] % upath + if mst == 'R': + tip += _(', resolved merge') + elif mst == 'U': + tip += _(', unresolved merge') + return QVariant(tip)   return QVariant()     def headerData(self, col, orientation, role): @@ -320,6 +331,12 @@
    # Custom methods   + def anyMerge(self): + for r in self.rows: + if r[COL_MERGE_STATE]: + return True + return False +   def getPath(self, index):   assert index.isValid()   return self.rows[index.row()][COL_PATH]