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

status: use wctx.status() method and standard localrepo.status options

This uses an API that I very recently added to Mercurial, so new it's still
sitting in Matt's queue. Since this widget isn't used anywhere outside of
my testing, it's safe to commit.

Changeset b614968eba96

Parent faa2db22b83d

by Steve Borho

Changes to one file · Browse files at b614968eba96 Showing diff from parent faa2db22b83d Diff from another changeset...

 
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
 
94
95
96
97
98
 
 
 
99
100
101
 
104
105
106
107
 
108
109
110
 
195
196
197
198
 
199
200
201
 
206
207
208
209
210
211
212
213
214
215
 
 
 
 
 
 
 
 
 
216
217
218
 
282
283
284
285
 
 
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
 
87
88
89
 
 
90
91
92
93
94
95
 
98
99
100
 
101
102
103
104
 
189
190
191
 
192
193
194
195
 
200
201
202
 
 
 
 
 
 
 
203
204
205
206
207
208
209
210
211
212
213
214
 
278
279
280
 
281
@@ -20,37 +20,30 @@
 # This widget can be used as the basis of the commit tool or any other  # working copy browser.   -# A QuickOp style dialog will need to create the workingctx instance by -# hand, not using repo[None], in order to pass in the results from its -# own call to localrepo.status(), else it will not be able to see clean -# or ignored files. -  # Technical Debt  # filter using pats -# show example of wctx manual creation -# wctx.ignored() does not exist, need a back-door  # Handle large files, binary files, subrepos better  # Thread refreshWctx, connect to an external progress bar  # Thread rowSelected, connect to an external progress bar -# Need a mechanism to clear pats -# Save splitter position, use parent's QSetting +# Need mechanisms to clear pats and toggle visibility options +# Save splitter position to parent's QSetting  # Show merge status column, when appropriate  # Context menu, toolbar  # Sorting, filtering of working files  # Chunk selection  # tri-state checkboxes for commit -# File type (unknown/deleted) toggles  # Investigate Qt.DecorationRole and possible use of overlay icons  # Investigate folding/nesting of files    class StatusWidget(QWidget): - def __init__(self, pats, parent=None): + def __init__(self, pats, parent=None, **opts):   QWidget.__init__(self, parent)     root = paths.find_root()   assert(root)   self.repo = hg.repository(ui.ui(), path=root)   self.wctx = self.repo[None] + self.opts = opts     # determine the user configured status colors   # (in the future, we could support full rich-text tags) @@ -94,8 +87,9 @@
  hglib.invalidaterepo(self.repo)   wctx = self.repo[None]   try: - # Force wctx to load _status property - wctx.unknown() + wctx.status(unknown=self.opts.get('unknown', True), + clean=self.opts.get('clean', False), + ignored=self.opts.get('ignored', False))   except (OSError, IOError, util.Abort), e:   self.status_error = str(e)   self.wctx = wctx @@ -104,7 +98,7 @@
  return bool(self.wctx.p2())     def updateModel(self): - tm = WctxModel(self.wctx) + tm = WctxModel(self.wctx, self.opts)   self.tv.setModel(tm)   self.tv.setItemsExpandable(False)   self.tv.setRootIsDecorated(False) @@ -195,7 +189,7 @@
 colors = {}    class WctxModel(QAbstractTableModel): - def __init__(self, wctx, parent=None): + def __init__(self, wctx, opts, parent=None):   QAbstractTableModel.__init__(self, parent)   rows = []   for m in wctx.modified(): @@ -206,13 +200,15 @@
  rows.append([True, 'R', hglib.tounicode(r), r])   for d in wctx.deleted():   rows.append([False, '!', hglib.tounicode(d), d]) - for u in wctx.unknown(): - rows.append([False, '?', hglib.tounicode(u), u]) - # TODO: wctx.ignored() does not exist - #for i in wctx.ignored(): - # rows.append([False, 'I', hglib.tounicode(i), i]) - for c in wctx.clean(): - rows.append([False, 'C', hglib.tounicode(c), c]) + if opts.get('unknown', True): + for u in wctx.unknown(): + rows.append([False, '?', hglib.tounicode(u), u]) + if opts.get('ignored', False): + for i in wctx.ignored(): + rows.append([False, 'I', hglib.tounicode(i), i]) + if opts.get('clean', False): + for c in wctx.clean(): + rows.append([False, 'C', hglib.tounicode(c), c])   try:   for s in wctx.substate:   if wctx.sub(s).dirty(): @@ -282,4 +278,4 @@
     def run(ui, *pats, **opts): - return StatusWidget(pats, None) + return StatusWidget(pats, None, **opts)