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.
# Copyright (c) 2009-2010 LOGILAB S.A. (Paris, FRANCE).# http://www.logilab.fr/ -- mailto:contact@logilab.fr## This program is free software; you can redistribute it and/or modify it under# the terms of the GNU General Public License as published by the Free Software# Foundation; either version 2 of the License, or (at your option) any later# version.## This program is distributed in the hope that it will be useful, but WITHOUT# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.## You should have received a copy of the GNU General Public License along with# this program; if not, write to the Free Software Foundation, Inc.,# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.frommercurialimporterrorfromtortoisehg.util.utilimporttounicode,Curryfromtortoisehg.hgqt.graphimportGraphfromtortoisehg.hgqt.graphimportrevision_grapherfromtortoisehg.hgqt.configimportHgConfigfromtortoisehg.hgqtimporticonasgeticonfromPyQt4importQtCore,QtGuiconnect=QtCore.QObject.connectSIGNAL=QtCore.SIGNALnullvariant=QtCore.QVariant()# XXX make this better than a poor hard written list...COLORS=["blue","darkgreen","red","green","darkblue","purple","cyan",QtCore.Qt.darkYellow,"magenta","darkred","darkmagenta","darkcyan","gray","yellow",]COLORS=[str(QtGui.QColor(x).name())forxinCOLORS]#COLORS = [str(color) for color in QtGui.QColor.colorNames()]defget_color(n,ignore=()):""" Return a color at index 'n' rotating in the available colors. 'ignore' is a list of colors not to be chosen. """ignore=[str(QtGui.QColor(x).name())forxinignore]colors=[xforxinCOLORSifxnotinignore]ifnotcolors:# ghh, no more available colors...colors=COLORSreturncolors[n%len(colors)]defcvrt_date(date):""" Convert a date given the hg way, ie. couple (date, tz), into a formatted QString """date,tzdelay=datereturnQtCore.QDateTime.fromTime_t(int(date)).toString(QtCore.Qt.LocaleDate)defgettags(model,ctx,gnode):ifctx.rev()isNone:return""mqtags=['qbase','qtip','qparent']tags=ctx.tags()ifmodel.hide_mq_tags:tags=[tfortintagsiftnotinmqtags]return",".join(tags)defgetlog(model,ctx,gnode):ifctx.rev()isnotNone:msg=tounicode(ctx.description())ifmsg:msg=msg.splitlines()[0]else:msg="WORKING DIRECTORY"returnmsg# XXX maybe it's time to make these methods of the model...# in following lambdas, ctx is a hg changectx_columnmap={'ID':lambdamodel,ctx,gnode:ctx.rev()isnotNoneandstr(ctx.rev())or"",'Log':getlog,'Author':lambdamodel,ctx,gnode:tounicode(ctx.user()),'Date':lambdamodel,ctx,gnode:cvrt_date(ctx.date()),'Tags':gettags,'Branch':lambdamodel,ctx,gnode:ctx.branch(),'Filename':lambdamodel,ctx,gnode:gnode.extra[0],}_tooltips={'ID':lambdamodel,ctx,gnode:ctx.rev()isnotNoneandctx.hex()or"Working Directory",}# in following lambdas, r is a hg repo_maxwidth={'ID':lambdaself,r:str(len(r.changelog)),'Date':lambdaself,r:cvrt_date(r.changectx(0).date()),'Tags':lambdaself,r:sorted(r.tags().keys(),key=lambdax:len(x))[-1][:10],'Branch':lambdaself,r:sorted(r.branchtags().keys(),key=lambdax:len(x))[-1],'Author':lambdaself,r:'author name','Filename':lambdaself,r:self.filename,}defdatacached(meth):""" decorator used to cache 'data' method of Qt models. It will *not* cache nullvariant return values (so costly non-null values can be computed and filled as a background process) """defdata(self,index,role):ifnotindex.isValid():returnnullvariantrow=index.row()col=index.column()if(row,col,role)inself._datacache:returnself._datacache[(row,col,role)]result=meth(self,index,role)ifresultisnotnullvariant:self._datacache[(row,col,role)]=resultreturnresultreturndataclassHgRepoListModel(QtCore.QAbstractTableModel):""" Model used for displaying the revisions of a Hg *local* repository """_allcolumns=('ID','Branch','Log','Author','Date','Tags',)_columns=('ID','Branch','Log','Author','Date','Tags',)_stretchs={'Log':1,}_getcolumns="getChangelogColumns"def__init__(self,repo,branch='',fromhead=None,follow=False,parent=None):""" repo is a hg repo instance """QtCore.QAbstractTableModel.__init__(self,parent)self._datacache={}self._hasmq=Falseself.mqueues=[]self.wd_revs=[]self.graph=Noneself._fill_timer=Noneself.rowcount=0self.repo=repoself.load_config()self.setRepo(repo,branch=branch,fromhead=fromhead,follow=follow)defsetRepo(self,repo,branch='',fromhead=None,follow=False):oldrepo=self.repoself.repo=repoifoldrepo.root!=repo.root:self.load_config()self._datacache={}try:wdctxs=self.repo.changectx(None).parents()excepterror.Abort:# might occur if reloading during a mq operation (or# whatever operation playing with hg history)returnself._hasmq=hasattr(self.repo,"mq")ifself._hasmq:self.mqueues=self.repo.mq.series[:]self.wd_revs=[ctx.rev()forctxinwdctxs]self._user_colors={}self._branch_colors={}grapher=revision_grapher(self.repo,start_rev=fromhead,follow=follow,branch=branch)self.graph=Graph(self.repo,grapher,self.max_file_size)self.rowcount=0self.emit(SIGNAL('layoutChanged()'))self.heads=[self.repo.changectx(x).rev()forxinself.repo.heads()]self.ensureBuilt(row=self.fill_step)QtCore.QTimer.singleShot(0,Curry(self.emit,SIGNAL('filled')))self._fill_timer=self.startTimer(50)defensureBuilt(self,rev=None,row=None):""" Make sure rev data is available (graph element created). """ifself.graph.isfilled():returnrequired=0buildrev=revn=len(self.graph)ifrevisnotNone:ifnandself.graph[-1].rev<=rev:buildrev=Noneelse:required=self.fill_step/2elifrowisnotNoneandrow>(n-self.fill_step/2):required=row-n+self.fill_stepifrequiredorbuildrev:self.graph.build_nodes(nnodes=required,rev=buildrev)self.updateRowCount()elifrowandrow>self.rowcount:# asked row was already built, but views where not aware of thisself.updateRowCount()elifrevisnotNoneandrev<=self.graph[self.rowcount].rev:# asked rev was already built, but views where not aware of thisself.updateRowCount()deftimerEvent(self,event):ifevent.timerId()==self._fill_timer:self.emit(SIGNAL('showMessage'),'filling (%s)'%(len(self.graph)))ifself.graph.isfilled():self.killTimer(self._fill_timer)self._fill_timer=Noneself.emit(SIGNAL('showMessage'),'')self.emit(SIGNAL('loaded'))# we only fill the graph data strctures without telling# views (until we atually did the full job), to keep# maximal GUI reactivityelifnotself.graph.build_nodes(nnodes=self.fill_step):self.killTimer(self._fill_timer)self._fill_timer=Noneself.updateRowCount()self.emit(SIGNAL('showMessage'),'')self.emit(SIGNAL('loaded'))defupdateRowCount(self):currentlen=self.rowcountnewlen=len(self.graph)ifnewlen>self.rowcount:self.beginInsertRows(QtCore.QModelIndex(),currentlen,newlen-1)self.rowcount=newlenself.endInsertRows()defrowCount(self,parent=None):returnself.rowcountdefcolumnCount(self,parent=None):returnlen(self._columns)defload_config(self):cfg=HgConfig(self.repo.ui)self._users,self._aliases=cfg.getUsers()self.dot_radius=cfg.getDotRadius(default=8)self.rowheight=cfg.getRowHeight()self.fill_step=cfg.getFillingStep()self.max_file_size=cfg.getMaxFileSize()self.hide_mq_tags=cfg.getMQHideTags()cols=getattr(cfg,self._getcolumns)()ifcolsisnotNone:validcols=[colforcolincolsifcolinself._allcolumns]iflen(validcols)!=len(cols):wrongcols=[colforcolincolsifcolnotinself._allcolumns]print"WARNING! %s are not valid column names. Check your configuration."%','.join(wrongcols)print" reverting to default columns configuration"elif'Log'notinvalidcolsor'ID'notinvalidcols:print"WARNING! 'Log' and 'ID' are mandatory. Check your configuration."print" reverting to default columns configuration"else:self._columns=tuple(validcols)defmaxWidthValueForColumn(self,column):column=self._columns[column]ifcolumnin_maxwidth:return_maxwidth[column](self,self.repo)returnNonedefuser_color(self,user):ifuserinself._aliases:user=self._aliases[user]ifuserinself._users:try:color=self._users[user]['color']color=QtGui.QColor(color).name()self._user_colors[user]=colorexcept:passifusernotinself._user_colors:self._user_colors[user]=get_color(len(self._user_colors),self._user_colors.values())returnself._user_colors[user]defuser_name(self,user):returnself._aliases.get(user,user)defnamedbranch_color(self,branch):ifbranchnotinself._branch_colors:self._branch_colors[branch]=get_color(len(self._branch_colors))returnself._branch_colors[branch]defcol2x(self,col):return(1.2*self.dot_radius+0)*col+self.dot_radius/2+3@datacacheddefdata(self,index,role):ifnotindex.isValid():returnnullvariantrow=index.row()self.ensureBuilt(row=row)column=self._columns[index.column()]gnode=self.graph[row]ctx=self.repo.changectx(gnode.rev)ifrole==QtCore.Qt.DisplayRole:ifcolumn=='Author':#authorreturnQtCore.QVariant(self.user_name(_columnmap[column](self,ctx,gnode)))elifcolumn=='Log': msg = _columnmap[column](self, ctx, gnode)
return QtCore.QVariant(msg)
return QtCore.QVariant(_columnmap[column](self, ctx, gnode))
- elif role == QtCore.Qt.ToolTipRole:- msg = "<b>Branch:</b> %s<br>\n" % ctx.branch()- msg += _tooltips.get(column, _columnmap[column])(self, ctx, gnode)- return QtCore.QVariant(msg) elif role == QtCore.Qt.ForegroundRole:
if column == 'Author': #author
return QtCore.QVariant(QtGui.QColor(self.user_color(ctx.user())))
ifcolumn=='Branch':#branchreturnQtCore.QVariant(QtGui.QColor(self.namedbranch_color(ctx.branch())))elifrole==QtCore.Qt.DecorationRole:ifcolumn=='Log':radius=self.dot_radiusw=(gnode.cols)*(1*radius+0)+20h=self.rowheightdot_x=self.col2x(gnode.x)-radius/2dot_y=h/2pix=QtGui.QPixmap(w,h)pix.fill(QtGui.QColor(0,0,0,0))painter=QtGui.QPainter(pix)painter.setRenderHint(QtGui.QPainter.Antialiasing)pen=QtGui.QPen(QtCore.Qt.blue)pen.setWidth(2)painter.setPen(pen)lpen=QtGui.QPen(pen)lpen.setColor(QtCore.Qt.black)painter.setPen(lpen)fory1,y2,linesin((0,h,gnode.bottomlines),(-h,0,gnode.toplines)):forstart,end,colorinlines:lpen=QtGui.QPen(pen)lpen.setColor(QtGui.QColor(get_color(color)))lpen.setWidth(2)painter.setPen(lpen)x1=self.col2x(start)x2=self.col2x(end)painter.drawLine(x1,dot_y+y1,x2,dot_y+y2)dot_color=QtGui.QColor(self.namedbranch_color(ctx.branch()))dotcolor=QtGui.QColor(dot_color)ifgnode.revinself.heads:penradius=2pencolor=dotcolor.darker()else:penradius=1pencolor=QtCore.Qt.blackdot_y=(h/2)-radius/2painter.setBrush(dotcolor)pen=QtGui.QPen(pencolor)pen.setWidth(penradius)painter.setPen(pen)tags=set(ctx.tags())icn=Noneifgnode.revinself.wd_revs:icn=geticon('clean')eliftags.intersection(self.mqueues):icn=geticon('mqpatch')ificn:icn.paint(painter,dot_x-5,dot_y-5,17,17)else:painter.drawEllipse(dot_x,dot_y,radius,radius)painter.end()ret=QtCore.QVariant(pix)returnretreturnnullvariantdefheaderData(self,section,orientation,role):iforientation==QtCore.Qt.Horizontalandrole==QtCore.Qt.DisplayRole:returnQtCore.QVariant(self._columns[section])returnnullvariantdefrowFromRev(self,rev):row=self.graph.index(rev)ifrow==-1:row=NonereturnrowdefindexFromRev(self,rev):self.ensureBuilt(rev=rev)row=self.rowFromRev(rev)ifrowisnotNone:returnself.index(row,0)returnNonedefclear(self):"""empty the list"""self.graph=Noneself._datacache={}self.notify_data_changed()defnotify_data_changed(self):self.emit(SIGNAL("layoutChanged()"))
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.