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.
# repotreemodel.py - model for the reporegistry## Copyright 2010 Adrian Buehlmann <adrian@cadifra.com>## This software may be used and distributed according to the terms of the# GNU General Public License version 2 or any later version.fromtortoisehg.utilimporthglib,pathsfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportqtlibfromrepotreeitemimportundumpObject,AllRepoGroupItem,RepoGroupItemfromrepotreeitemimportRepoItem,RepoTreeItemfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*extractXmlElementName='reporegextract'reporegistryXmlElementName='reporegistry'repoRegMimeType='application/thg-reporegistry'repoRegGroupMimeType='application/thg-reporegistrygroup'repoExternalMimeType='text/uri-list'defwriteXml(target,item,rootElementName):xw=QXmlStreamWriter(target)xw.setAutoFormatting(True)xw.setAutoFormattingIndent(2)xw.writeStartDocument()xw.writeStartElement(rootElementName)item.dumpObject(xw)xw.writeEndElement()xw.writeEndDocument()defreadXml(source,rootElementName):itemread=Nonexr=QXmlStreamReader(source)ifxr.readNextStartElement():ele=str(xr.name().toString())ifele!=rootElementName:print"unexpected xml element '%s' "\
"(was looking for %s)"%(ele,rootElementName)returnifxr.hasError():printstr(xr.errorString())ifxr.readNextStartElement():itemread=undumpObject(xr)xr.skipCurrentElement()ifxr.hasError():printstr(xr.errorString())returnitemreaddefiterRepoItemFromXml(source):xr=QXmlStreamReader(source)whilenotxr.atEnd():t=xr.readNext()ift==QXmlStreamReader.StartElementandxr.name()=='repo':yieldundumpObject(xr)defgetRepoItemList(root):ifisinstance(root,RepoItem):return[root]ifnotisinstance(root,RepoTreeItem):return[]returnreduce(lambdaa,b:a+b,(getRepoItemList(c)forcinroot.childs),[])classRepoTreeModel(QAbstractItemModel):def__init__(self,filename,parent,showSubrepos=False,showNetworkSubrepos=False):QAbstractItemModel.__init__(self,parent)self.showSubrepos=showSubreposself.showNetworkSubrepos=showNetworkSubreposroot=Noneall=Noneiffilename:f=QFile(filename)iff.open(QIODevice.ReadOnly):root=readXml(f,reporegistryXmlElementName)f.close()ifroot:forcinroot.childs:ifisinstance(c,AllRepoGroupItem):all=cbreakifself.showSubrepos:self.loadSubrepos(root)ifnotroot:root=RepoTreeItem(self)all=AllRepoGroupItem(self)root.appendChild(all)self.rootItem=rootself.allrepos=all# see http://doc.qt.nokia.com/4.6/model-view-model-subclassing.html# overrides from QAbstractItemModeldefindex(self,row,column,parent):ifnotself.hasIndex(row,column,parent):returnQModelIndex()if(notparent.isValid()):parentItem=self.rootItemelse:parentItem=parent.internalPointer()childItem=parentItem.child(row)ifchildItem:returnself.createIndex(row,column,childItem)else:returnQModelIndex()defparent(self,index):ifnotindex.isValid():returnQModelIndex()childItem=index.internalPointer()parentItem=childItem.parent()ifparentItemisself.rootItem:returnQModelIndex()returnself.createIndex(parentItem.row(),0,parentItem)defrowCount(self,parent):ifparent.column()>0:return0ifnotparent.isValid():parentItem=self.rootItem;else:parentItem=parent.internalPointer()returnparentItem.childCount()defcolumnCount(self,parent):ifparent.isValid():returnparent.internalPointer().columnCount()else:returnself.rootItem.columnCount()defdata(self,index,role):ifnotindex.isValid():returnQVariant()ifrolenotin(Qt.DisplayRole,Qt.EditRole,Qt.DecorationRole):returnQVariant()item=index.internalPointer()returnitem.data(index.column(),role)defheaderData(self,section,orientation,role):ifrole==Qt.DisplayRole:iforientation==Qt.Horizontal:ifsection==1:returnQString(_('Path'))returnQVariant()defflags(self,index):ifnotindex.isValid():returnQt.NoItemFlagsitem=index.internalPointer()returnitem.flags()defsupportedDropActions(self):returnQt.CopyAction|Qt.MoveAction|Qt.LinkActiondefremoveRows(self,row,count,parent):item=parent.internalPointer()ifitemisNone:item=self.rootItemself.beginRemoveRows(parent,row,row+count-1)res=item.removeRows(row,count)self.endRemoveRows()returnresdefmimeTypes(self):returnQStringList([repoRegMimeType,repoRegGroupMimeType,repoExternalMimeType])defmimeData(self,indexes):i=indexes[0]item=i.internalPointer()buf=QByteArray()writeXml(buf,item,extractXmlElementName)d=QMimeData()ifisinstance(item,RepoItem):d.setData(repoRegMimeType,buf)d.setUrls([QUrl.fromLocalFile(hglib.tounicode(item.rootpath()))])else:d.setData(repoRegGroupMimeType,buf)d.setText(QString(item.name))returnddefdropMimeData(self,data,action,row,column,parent):group=parent.internalPointer()ifdata.hasUrls():d=str(data.data(repoRegMimeType))else:row=parent.row()group=self.rootItemparent=QModelIndex()d=str(data.data(repoRegGroupMimeType))itemread=readXml(d,extractXmlElementName)ifitemreadisNone:returnFalseifgroupisNone:returnFalseifrow<0:row=0ifself.showSubrepos:self.loadSubrepos(itemread) self.beginInsertRows(parent, row, row)
group.insertChild(row, itemread)
self.endInsertRows()
+ if isinstance(itemread, AllRepoGroupItem):+ self.allrepos = itemread return True
def setData(self, index, value, role):
ifnotindex.isValid()orrole!=Qt.EditRole:returnFalses=value.toString()ifs.isEmpty():returnFalseitem=index.internalPointer()ifitem.setData(index.column(),value):self.dataChanged.emit(index,index)returnTruereturnFalse # functions not defined in QAbstractItemModel
def allreposIndex(self):
- return self.createIndex(0, 0, self.allrepos)
+ return self.createIndex(self.allrepos.row(), 0, self.allrepos)
def addRepo(self, group, root, row=-1):
grp = group
ifgrp==None:grp=self.allreposIndex()rgi=grp.internalPointer()ifrow<0:row=rgi.childCount()self.beginInsertRows(grp,row,row)ri=RepoItem(root)rgi.insertChild(row,ri)ifnotself.showSubrepos \
or(notself.showNetworkSubreposandpaths.netdrive_status(root)):self.endInsertRows()returninvalidRepoList=ri.appendSubrepos()self.endInsertRows()ifinvalidRepoList:ifinvalidRepoList[0]==root:qtlib.WarningMsgBox(_('Could not get subrepository list'),_('It was not possible to get the subrepository list for ''the repository in:<br><br><i>%s</i>')%root)else:qtlib.WarningMsgBox(_('Could not open some subrepositories'),_('It was not possible to fully load the subrepository ''list for the repository in:<br><br><i>%s</i><br><br>''The following subrepositories may be missing, broken or ''on an inconsistent state and cannot be accessed:''<br><br><i>%s</i>')%(root,"<br>".join(invalidRepoList)))defgetRepoItem(self,reporoot):returnself.rootItem.getRepoItem(reporoot)defaddGroup(self,name):ri=self.rootItemcc=ri.childCount()self.beginInsertRows(QModelIndex(),cc,cc+1)ri.appendChild(RepoGroupItem(name,ri))self.endInsertRows()defwrite(self,fn):f=QFile(fn)f.open(QIODevice.WriteOnly)writeXml(f,self.rootItem,reporegistryXmlElementName)f.close()defdepth(self,index):count=1whileTrue:index=index.parent()ifindex.row()<0:returncountcount+=1defloadSubrepos(self,root):warningmsg=''forcingetRepoItemList(root):ifself.showNetworkSubrepos \
ornotpaths.netdrive_status(c.rootpath()):invalidRepoList=c.appendSubrepos()
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.