Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# status.py - working copy browser## Copyright 2010 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.frommercurialimportui,hg,util,patch,cmdutil,error,mdifffromtortoisehg.hgqtimportqtlib,htmluifromtortoisehg.utilimportpaths,hglibfromtortoisehg.util.i18nimport_fromPyQt4.QtCoreimportQt,QVariant,SIGNAL,QAbstractTableModelfromPyQt4.QtGuiimportQWidget,QVBoxLayout,QSplitter,QTreeViewfromPyQt4.QtGuiimportQTextEdit,QFont# 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# Show merge status column, when appropriate# Context menu, toolbar# Sorting, filtering of working files# Chunk selection# tri-state checkboxes for commit# Select entire table row when clicked# File type (unknown/deleted) togglesclassStatusWidget(QWidget):def__init__(self,pats,parent=None):QWidget.__init__(self,parent)root=paths.find_root()assert(root)self.repo=hg.repository(ui.ui(),path=root)self.wctx=self.repo[None]split=QSplitter(Qt.Horizontal)layout=QVBoxLayout()layout.addWidget(split)self.setLayout(layout)self.tv=QTreeView(split)self.connect(self.tv,SIGNAL('clicked(QModelIndex)'),self.rowSelected)self.te=QTextEdit(split)self.te.document().setDefaultStyleSheet(qtlib.thgstylesheet)self.te.setReadOnly(True)self.te.setLineWrapMode(QTextEdit.NoWrap)# it is not clear why I had to set this QFont to get monospacef=QFont("Monospace")f.setStyleHint(QFont.TypeWriter)f.setPointSize(9)self.te.setFont(f)ifnotparent:self.setWindowTitle(_('TortoiseHg Status'))self.resize(650,400)# 60% for diff panesplit.setStretchFactor(0,2)split.setStretchFactor(1,5)self.refreshWctx()self.updateModel()defrefreshWctx(self):hglib.invalidaterepo(self.repo)wctx=self.repo[None]try:# Force wctx to load _status propertywctx.unknown()except(OSError,IOError,util.Abort),e:self.status_error=str(e)self.wctx=wctxdefisMerge(self):returnbool(self.wctx.p2())defupdateModel(self):tm=WctxModel(self.wctx)self.tv.setItemsExpandable(False)self.tv.setRootIsDecorated(False)self.tv.setSortingEnabled(True)self.tv.sortByColumn(1) self.tv.setModel(tm)
self.tv.resizeColumnToContents(0)
self.tv.resizeColumnToContents(1)
+ self.connect(self.tv, SIGNAL('activated(QModelIndex)'), tm.toggleRow) def rowSelected(self, index):
pfile = index.model().getPath(index)
wfile=util.pconvert(pfile)hu=htmlui.htmlui()try:m=cmdutil.matchfiles(self.repo,[wfile])opts=mdiff.diffopts(git=True,nodates=True)n2,n1=None,self.wctx.p1().node()fors,linpatch.difflabel(patch.diff,self.repo,n1,n2,match=m,opts=opts):hu.write(s,label=l)except(IOError,error.RepoError,error.LookupError,util.Abort),e:self.status_error=str(e)o,e=hu.getdata()self.te.setHtml(o)COL_STATUS=0COL_PATH_DISPLAY=1COL_PATH=2classWctxModel(QAbstractTableModel):def__init__(self,wctx,parent=None):QAbstractTableModel.__init__(self,parent)rows=[]forminwctx.modified():rows.append(('M',hglib.tounicode(m),m))forainwctx.added():rows.append(('A',hglib.tounicode(a),a))forrinwctx.removed():rows.append(('R',hglib.tounicode(r),r))fordinwctx.deleted():rows.append(('!',hglib.tounicode(d),d))foruinwctx.unknown():rows.append(('?',hglib.tounicode(u),u))# TODO: wctx.ignored() does not exist#for i in wctx.ignored():# rows.append(('I', hglib.tounicode(i), i))forcinwctx.clean():rows.append(('C',hglib.tounicode(c),c))try:forsinwctx.substate:ifwctx.sub(s).dirty():rows.append(('S',hglib.tounicode(s),s))except(OSError,IOError,error.ConfigError),e: self.status_error = str(e)
self.rows = rows
self.headers = (_('Stat'), _('Filename'))
+ self.checked = [False,] * len(rows) def rowCount(self, parent):
return len(self.rows)
defcolumnCount(self,parent): return len(self.headers)
def data(self, index, role):
- if not index.isValid() or role != Qt.DisplayRole:
+ if not index.isValid():
return QVariant()
- return QVariant(self.rows[index.row()][index.column()])
-- def getPath(self, index):- assert index.isValid()- return self.rows[index.row()][COL_PATH]+ if role == Qt.DisplayRole:+ return QVariant(self.rows[index.row()][index.column()])
+ if role == Qt.CheckStateRole and index.column() == COL_STATUS:+ # also Qt.PartiallyChecked+ if self.checked[index.row()]:+ return Qt.Checked+ else:+ return Qt.Unchecked+ return QVariant() def headerData(self, col, orientation, role):
if role != Qt.DisplayRole or orientation != Qt.Horizontal:
returnQVariant()else: return QVariant(self.headers[col])
def flags(self, index):
- return Qt.ItemIsSelectable | Qt.ItemIsEnabled+ flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled+ if index.column() == COL_STATUS:+ flags |= Qt.ItemIsUserCheckable+ return flags++ # Custom methods++ def getPath(self, index):+ assert index.isValid()+ return self.rows[index.row()][COL_PATH]++ def toggleRow(self, index):+ assert index.isValid()+ self.checked[index.row()] = not self.checked[index.row()]+ self.emit(SIGNAL("layoutChanged()"))def run(ui, *pats, **opts):
returnStatusWidget(pats,None)
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.