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,RepoTreeItem,SubrepoItemfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*importosextractXmlElementName='reporegextract'reporegistryXmlElementName='reporegistry'repoRegMimeType='application/thg-reporegistry'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()) return itemread
def iterRepoItemFromXml(source):
+ 'Used by thgrepo.relatedRepositories to scan the XML file' xr = QXmlStreamReader(source)
while not xr.atEnd():
t = xr.readNext()
- if t == QXmlStreamReader.StartElement and xr.name() == 'repo':
+ if t == QXmlStreamReader.StartElement and xr.name() in('repo', 'subrepo'):
yield undumpObject(xr)
def getRepoItemList(root, includeSubRepos=False):
ifnotincludeSubReposandisinstance(root,RepoItem):return[root]ifnotisinstance(root,RepoTreeItem):return[]returnreduce(lambdaa,b:a+b,(getRepoItemList(c,includeSubRepos=includeSubRepos) \
forcinroot.childs),[])classRepoTreeModel(QAbstractItemModel):def__init__(self,filename,parent,showSubrepos=False,showNetworkSubrepos=False,showShortPaths=False):QAbstractItemModel.__init__(self,parent)self.showSubrepos=showSubreposself.showNetworkSubrepos=showNetworkSubreposself.showShortPaths=showShortPathsroot=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=allself.updateCommonPaths()# 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,Qt.FontRole):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,repoExternalMimeType])defmimeData(self,indexes):i=indexes[0]item=i.internalPointer()buf=QByteArray()writeXml(buf,item,extractXmlElementName)d=QMimeData()d.setData(repoRegMimeType,buf)ifisinstance(item,RepoItem):d.setUrls([QUrl.fromLocalFile(hglib.tounicode(item.rootpath()))])else:d.setText(QString(item.name))returnddefdropMimeData(self,data,action,row,column,parent):group=parent.internalPointer()d=str(data.data(repoRegMimeType))ifnotdata.hasUrls():# don't allow nesting of groupsrow=parent.row()group=self.rootItemparent=QModelIndex()itemread=readXml(d,extractXmlElementName)ifitemreadisNone:returnFalseifgroupisNone:returnFalse# Avoid copying subrepos multiple timesifQt.CopyAction==actionandself.getRepoItem(itemread.rootpath()):returnFalseifrow<0:row=0ifself.showSubrepos:self.loadSubrepos(itemread)self.beginInsertRows(parent,row,row)group.insertChild(row,itemread)self.endInsertRows()ifisinstance(itemread,AllRepoGroupItem):self.allrepos=itemreadreturnTruedefsetData(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 QAbstractItemModeldefallreposIndex(self):returnself.createIndex(self.allrepos.row(),0,self.allrepos)defaddRepo(self,group,root,row=-1):grp=groupifgrp==None:grp=self.allreposIndex()rgi=grp.internalPointer()ifrow<0:row=rgi.childCount()# Is the root of the repo that we want to add a subrepo contained# within a repo or subrepo? If so, assume it is an hg subrepoitemIsSubrepo=notpaths.find_root(os.path.dirname(root))isNoneself.beginInsertRows(grp,row,row)ifitemIsSubrepo:ri=SubrepoItem(root)else: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,lookForSubrepos=False):returnself.rootItem.getRepoItem(os.path.normcase(reporoot),lookForSubrepos=lookForSubrepos)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,filterFunc=(lambdar:True)):forcingetRepoItemList(root):iffilterFunc(c.rootpath()):ifself.showNetworkSubrepos \
ornotpaths.netdrive_status(c.rootpath()):self.removeRows(0,c.childCount(),self.createIndex(c.row(),0,c))c.appendSubrepos()defupdateCommonPaths(self,showShortPaths=None):ifnotshowShortPathsisNone:self.showShortPaths=showShortPathsforgrpinself.rootItem.childs:ifisinstance(grp,RepoGroupItem):ifself.showShortPaths:grp.updateCommonPath()else:grp.updateCommonPath('')
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.