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.
# repotreeitem.py - treeitems 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.importsys,osfrommercurialimportnodefrommercurialimportui,hg,util,errorfromtortoisehg.utilimporthglibfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportqtlibfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*xmlClassMap={'allgroup':'AllRepoGroupItem','group':'RepoGroupItem','repo':'RepoItem','subrepo':'SubrepoItem','treeitem':'RepoTreeItem',}inverseXmlClassMap={}defxmlToClass(ele):returnxmlClassMap[ele]defclassToXml(classname):iflen(inverseXmlClassMap)==0:fork,vinxmlClassMap.iteritems():inverseXmlClassMap[v]=kreturninverseXmlClassMap[classname]defundumpObject(xr):classname=xmlToClass(str(xr.name().toString()))class_=getattr(sys.modules[RepoTreeItem.__module__],classname)obj=class_()obj.undump(xr)returnobjclassRepoTreeItem(object):def__init__(self,parent=None):self._parent=parentself.childs=[]self._row=0defappendChild(self,child):child._row=len(self.childs)child._parent=selfself.childs.append(child)definsertChild(self,row,child):child._row=rowchild._parent=selfself.childs.insert(row,child)defchild(self,row):returnself.childs[row]defchildCount(self):returnlen(self.childs)defcolumnCount(self):return2defdata(self,column,role):returnQVariant()defsetData(self,column,value):returnFalsedefrow(self):returnself._rowdefparent(self):returnself._parentdefmenulist(self):return[]defflags(self):returnQt.NoItemFlagsdefremoveRows(self,row,count):cs=self.childsremove=cs[row:row+count]keep=cs[:row]+cs[row+count:]self.childs=keepforcinremove:c._row=0c._parent=Nonefori,cinenumerate(keep):c._row=ireturnTruedefdump(self,xw):forcinself.childs:c.dumpObject(xw)defundump(self,xr):whilenotxr.atEnd():xr.readNext()ifxr.isStartElement():item=undumpObject(xr)self.appendChild(item)elifxr.isEndElement():breakdefdumpObject(self,xw):xw.writeStartElement(classToXml(self.__class__.__name__))self.dump(xw)xw.writeEndElement()defisRepo(self):returnFalsedefdetails(self):return''defgetRepoItem(self,reporoot):forcinself.childs:ri=c.getRepoItem(reporoot)ifri:returnrireturnNonedefokToDelete(self):returnTrueclassRepoItem(RepoTreeItem):def__init__(self,root=None,parent=None):RepoTreeItem.__init__(self,parent)self._root=rootor''self._shortname=u''self._basenode=node.nullidself._repotype='hg'# The _valid property is used to display a "warning" icon for repos# that cannot be open# If root is set we assume that the repo is valid (an actual validity# test would require calling hg.repository() which is expensive)# Regardless, self._valid may be set to False if self.undump() failsifself._root:self._valid=Trueelse:self._valid=FalsedefisRepo(self):returnTruedefrootpath(self):returnself._rootdefshortname(self):ifself._shortname:returnself._shortnameelse:returnhglib.tounicode(os.path.basename(self._root))defrepotype(self):returnself._repotypedefbasenode(self):"""Return node id of revision 0"""returnself._basenodedefsetBaseNode(self,basenode):self._basenode=basenodedefsetShortName(self,uname):self._shortname=unamedefdata(self,column,role):ifrole==Qt.DecorationRole:ifcolumn==0:ico=qtlib.geticon('hg')ifnotself._valid:ico=_overlaidicon(ico,qtlib.geticon('dialog-warning'))returnQVariant(ico)returnQVariant()ifcolumn==0:returnQVariant(self.shortname())elifcolumn==1:returnQVariant(hglib.tounicode(self._root))returnQVariant()defmenulist(self):return['open','remove','clone',None,'explore','terminal',None,'settings']defflags(self):returnQt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsDragEnableddefremoveRows(self,row,count):returnFalsedefdump(self,xw):xw.writeAttribute('root',hglib.tounicode(self._root))xw.writeAttribute('shortname',self.shortname())xw.writeAttribute('basenode',node.hex(self.basenode()))defundump(self,xr):self._valid=Truea=xr.attributes()self._root=hglib.fromunicode(a.value('','root').toString())self._shortname=unicode(a.value('','shortname').toString())self._basenode=node.bin(str(a.value('','basenode').toString()))RepoTreeItem.undump(self,xr)defdetails(self):return_('Local Repository %s')%hglib.tounicode(self._root)defgetRepoItem(self,reporoot):if(reporoot==self._rootor(os.name=='nt'andreporoot.lower()==self._root.lower())):returnselfreturnNonedefappendSubrepos(self,repo=None):invalidRepoList=[]try:sri=NoneifrepoisNone:repo=hg.repository(ui.ui(),self._root)wctx=repo['.']forsubpathinwctx.substate:sri=Noneabssubpath=repo.wjoin(subpath)subtype=wctx.substate[subpath][2]sriIsValid=os.path.isdir(abssubpath)sri=SubrepoItem(abssubpath,subtype=subtype)sri._valid=sriIsValidself.appendChild(sri)ifnotsriIsValid:self._valid=Falsesri._valid=FalseinvalidRepoList.append(repo.wjoin(subpath))returninvalidRepoListcontinueifsubtype=='hg':# Only recurse into mercurial subrepossctx=wctx.sub(subpath)invalidSubrepoList=sri.appendSubrepos(sctx._repo)ifinvalidSubrepoList:self._valid=FalseinvalidRepoList+=invalidSubrepoListexcept(EnvironmentError,error.RepoError,util.Abort),e:# Add the repo to the list of repos/subrepos# that could not be openself._valid=Falseifsri:sri._valid=FalseinvalidRepoList.append(abssubpath)invalidRepoList.append(self._root)returninvalidRepoListdef_overlaidicon(base,overlay):"""Generate overlaid icon"""# TODO: This was copied from manifestmodel.py# TODO: generalize this function as a utilitypixmap=base.pixmap(16,16)painter=QPainter(pixmap)painter.setCompositionMode(QPainter.CompositionMode_SourceOver)painter.drawPixmap(0,0,overlay.pixmap(16,16))delpainterreturnQIcon(pixmap)classSubrepoItem(RepoItem):_subrepoType2IcoMap={'hg':'hg','git':'thg-git-subrepo','svn':'thg-svn-subrepo',}def__init__(self,repo=None,parent=None,parentrepo=None,subtype='hg'):RepoItem.__init__(self,repo,parent)self._parentrepo=parentrepoself._repotype=subtypeifself._repotype!='hg':# Make sure that we cannot drag non hg subrepos# To do so we disable the dumpObject method for non hg subreposdefdoNothing(dummy):passself.dumpObject=doNothing# Limit the context menu to those actions that are valid for non# mercurial subreposdefnonHgMenulist():return['remove',None,'explore','terminal']self.menulist=nonHgMenulistdefdata(self,column,role):ifrole==Qt.DecorationRole:ifcolumn==0:subiconame=SubrepoItem._subrepoType2IcoMap.get(self._repotype,None)ifsubiconameisNone:# Unknown (or generic) subrepo typeico=qtlib.geticon('thg-subrepo')else:# Overlay the "subrepo icon" on top of the selected subrepo# type iconico=qtlib.geticon(subiconame)ico=_overlaidicon(ico,qtlib.geticon('thg-subrepo'))ifnotself._valid:ico=_overlaidicon(ico,qtlib.geticon('dialog-warning'))returnQVariant(ico)returnQVariant() else:
return super(SubrepoItem, self).data(column, role)
+ def menulist(self):+ print self._parent+ if isinstance(self._parent, RepoGroupItem):+ return super(SubrepoItem, self).menulist()+ else:+ return ['open', 'clone', None, 'explore', 'terminal',+ None, 'settings']+class RepoGroupItem(RepoTreeItem):
def __init__(self, name=None, parent=None):
RepoTreeItem.__init__(self,parent)ifname:self.name=nameelse:self.name=QString()defdata(self,column,role):ifrole==Qt.DecorationRole:ifcolumn==0:s=QApplication.style()ico=s.standardIcon(QStyle.SP_DirIcon)returnQVariant(ico)returnQVariant()ifcolumn==0:returnQVariant(self.name)returnQVariant()defsetData(self,column,value):ifcolumn==0:self.name=value.toString()returnTruereturnFalsedefmenulist(self):return['openAll','add',None,'newGroup',None,'rename','remove',None,'reloadRegistry']defflags(self):return(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsDropEnabled|Qt.ItemIsDragEnabled|Qt.ItemIsEditable)defchildRoots(self):return[c._rootforcinself.childs]defdump(self,xw):xw.writeAttribute('name',self.name)RepoTreeItem.dump(self,xw)defundump(self,xr):a=xr.attributes()self.name=a.value('','name').toString()RepoTreeItem.undump(self,xr)defokToDelete(self):returnFalseclassAllRepoGroupItem(RepoGroupItem):def__init__(self,parent=None):RepoTreeItem.__init__(self,parent)self.name=_('default')defmenulist(self):return['openAll','add',None,'newGroup',None,'rename',None,'reloadRegistry']defundump(self,xr):a=xr.attributes()name=a.value('','name').toString()ifname:self.name=nameRepoTreeItem.undump(self,xr)
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.