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.
# treemodel.py - changelog viewer data model## Copyright 2008 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.''' Mercurial revision DAG visualization library Implements a gtk.TreeModel which visualizes a Mercurial repository revision history.Portions of this code stolen mercilessly from bzr-gtk visualizationdialog. Other portions stolen from graphlog extension.'''importgtkimportgobjectimportrefrommercurialimportutil,errorfromtortoisehg.utilimporthglibfromtortoisehg.hgtkimportgtklib# treemodel row enumerated attributesLINES=0# These elements come from the changelog walkerGRAPHNODE=1REVID=2LAST_LINES=3WFILE=4BRANCH=5# calculated on demand, not cachedHEXID=6REVHEX=7LOCALTIME=8UTC=9MESSAGE=10# calculated on demand, cachedCOMMITER=11TAGS=12FGCOLOR=13AGE=14CHANGES=15classTreeModel(gtk.GenericTreeModel):def__init__(self,repo,graphdata,opts):gtk.GenericTreeModel.__init__(self)self.repo=repoself.outgoing=opts['outgoing']self.origtip=opts['orig-tip']self.npreviews=opts['npreviews'] self.showgraph = opts['show-graph']
self.revisions = {}
self.graphdata = graphdata
- self.set_author_color()- self.hidetags = self.repo.ui.config(- 'tortoisehg', 'hidetags', '').split() self.wcparents, self.tagrevs, self.branchtags = [], [], {}
- try:- self.tagrevs = [repo[r].rev() for t, r in repo.tagslist()]- self.branchtags = repo.branchtags()
- self.wcparents = [x.rev() for x in repo.parents()]- except util.Abort:- pass+ self.refresh()
def refresh(self):
repo = self.repo
oldtags,oldparents=self.tagrevs,self.wcparentstry:oldbranches=[repo[n].rev()forninself.branchtags.values()]excepterror.RepoLookupError:oldbranches=[] hglib.invalidaterepo(repo)
- self.wcparents = [x.rev() for x in repo.parents()]
- self.tagrevs = [repo[r].rev() for t, r in repo.tagslist()]
- self.branchtags = repo.branchtags()
+ self.set_author_color()+ self.hidetags = repo.ui.config('tortoisehg', 'hidetags', '').split()++ # Check if we're using bookmarks, and have the 'track.current'+ # option set; if so, find what the 'current' bookmark is+ self.curbookmark = None+ bookmarks = None+ try:+ bookmarks = hglib.extensions.find('bookmarks')+ except KeyError:+ pass+ if bookmarks:+ if repo.ui.configbool('bookmarks', 'track.current'):+ self.curbookmark = bookmarks.current(repo)+ try:+ self.wcparents = [x.rev() for x in repo.parents()]
+ self.tagrevs = [repo[r].rev() for t, r in repo.tagslist()]
+self.branchtags = repo.branchtags()
+ except util.Abort:+ pass brevs = [repo[n].rev() for n in self.branchtags.values()]
allrevs = set(oldtags + oldparents + oldbranches +
brevs + self.wcparents + self.tagrevs)
forrevinallrevs:ifrevinself.revisions:delself.revisions[rev]defon_get_flags(self):returngtk.TREE_MODEL_LIST_ONLYdefon_get_n_columns(self):return13defon_get_column_type(self,index):ifindex==GRAPHNODE:returngobject.TYPE_PYOBJECTifindex==LINES:returngobject.TYPE_PYOBJECTifindex==REVID:returnintifindex==LAST_LINES:returngobject.TYPE_PYOBJECTifindex==WFILE:returnstrifindex==BRANCH:returnstrifindex==HEXID:returnstrifindex==REVHEX:returnstrifindex==LOCALTIME:returnstrifindex==UTC:returnstrifindex==MESSAGE:returnstrifindex==COMMITER:returnstrifindex==TAGS:returnstrifindex==FGCOLOR:returnstrifindex==AGE:returnstrifindex==CHANGES:returnstrdefon_get_iter(self,path):returnpath[0]defon_get_path(self,rowref):returnrowrefdefon_get_value(self,rowref,column):(revid,graphnode,lines,path)=self.graphdata[rowref]ifcolumn==REVID:returnrevidifcolumn==LINES:returnlinesifcolumn==LAST_LINES:ifrowref>0:returnself.graphdata[rowref-1][2]return[]ifcolumn==WFILE:returnpathor''ifcolumnin(HEXID,REVHEX,BRANCH,LOCALTIME,UTC):try:ctx=self.repo[revid]exceptIndexError:returnNoneifcolumn==HEXID:returnstr(ctx)ifcolumn==REVHEX:hexid=gtklib.markup(str(ctx),face='monospace')return'%s: %s'%(revid,hexid)ifcolumn==BRANCH:returnctx.branch()ifcolumn==LOCALTIME:returnhglib.displaytime(ctx.date())ifcolumn==UTC:returnhglib.utctime(ctx.date())ifrevidnotinself.revisions:try:ctx=self.repo[revid]exceptIndexError:returnNone# convert to Unicode for valid string operationssummary=hglib.tounicode(ctx.description()).replace(u'\0','')ifself.repo.ui.configbool('tortoisehg','longsummary'):limit=80lines=summary.splitlines()iflines:summary=lines.pop(0)whilelen(summary)<limitandlines:summary+=u' '+lines.pop(0)summary=summary[0:limit]else:summary=''else:lines=summary.splitlines()summary=linesandlines[0]or''escape=gtklib.markup_escape_text summary = escape(hglib.toutf(summary))
node = ctx.node()
- # Check if we're using bookmarks, and have the- # 'track.current' option set; if so,- # find what the 'current' bookmark is- currentBookmark = None- bookmarks = None- try:- bookmarks = hglib.extensions.find('bookmarks')- except KeyError:- pass- if bookmarks:- if self.repo.ui.configbool('bookmarks', 'track.current'):- currentBookmark = bookmarks.current(self.repo)- tags = self.repo.nodetags(node)
taglist = hglib.toutf(', '.join(tags))
tstr = ''
for tag in tags:
if tag not in self.hidetags:
style = {'color':'black', 'background':'#ffffaa'}
- if tag == currentBookmark:
+ if tag == self.curbookmark:
style['background'] = '#ffcc99'
tstr += gtklib.markup(' %s ' % tag, **style) + ' '
branch=ctx.branch()bstr=''ifself.branchtags.get(branch)==node:bstr+=gtklib.markup(' %s '%branch,color='black',background='#aaffaa')+' 'author=hglib.toutf(hglib.username(ctx.user()))age=hglib.age(ctx.date())color=self.color_func(revid,author)ifrevidinself.wcparents:sumstr=bstr+tstr+'<b><u>'+summary+'</u></b>'status=4else:sumstr=bstr+tstr+summarystatus=0ifnodeinself.outgoing:# outgoingifnotself.showgraph:marker=hglib.toutf(u'\u2191 ')# up arrowsumstr=marker+sumstrstatus+=1elifrevid>=self.origtip:ifrevid>=len(self.repo)-self.npreviews:# incomingifnotself.showgraph:marker=hglib.toutf(u'\u2193 ')# down arrowsumstr=marker+sumstrstatus+=3else:# newstatus+=2M,A,R=self.repo.status(ctx.parents()[0].node(),ctx.node())[:3]common=dict(color='black')M=Mandgtklib.markup(' %s '%len(M),background='#ffddaa',**common)or''A=Aandgtklib.markup(' %s '%len(A),background='#aaffaa',**common)or''R=Randgtklib.markup(' %s '%len(R),background='#ffcccc',**common)or''changes=''.join((M,A,R))revision=(sumstr,author,taglist,color,age,changes,status)self.revisions[revid]=revisionelse:revision=self.revisions[revid]ifcolumn==GRAPHNODE:column,color=graphnodereturn(column,color,revision[-1])else:returnrevision[column-MESSAGE]defon_iter_next(self,rowref):ifrowref<len(self.graphdata)-1:returnrowref+1returnNonedefon_iter_children(self,parent):ifparentisNone:return0returnNonedefon_iter_has_child(self,rowref):returnFalsedefon_iter_n_children(self,rowref):ifrowrefisNone:returnlen(self.graphdata)return0defon_iter_nth_child(self,parent,n):ifparentisNone:returnnreturnNonedefon_iter_parent(self,child):returnNonedefset_author_color(self):# If user has configured authorcolor in [tortoisehg], color# rows by author matchesself.author_pats=[]self.color_func=self.text_color_defaultifself.repoisnotNone:fork,vinself.repo.ui.configitems('tortoisehg'):ifnotk.startswith('authorcolor.'):continuepat=k[12:]self.author_pats.append((re.compile(pat,re.I),v))try:enabled=self.repo.ui.configbool('tortoisehg','authorcolor')excepterror.ConfigError:enabled=Falseifself.author_patsorenabled:self.color_func=self.text_color_authordeftext_color_default(self,rev,author):returnint(rev)>=self.origtipand'darkgreen'or'black'colors='''black blue deeppink mediumorchid blue burlywood4 goldenrod slateblue red2 navy dimgrey'''.split()color_cache={}deftext_color_author(self,rev,author):ifint(rev)>=self.origtip:return'darkgreen'forre,vinself.author_pats:if(re.search(author)):returnvifauthornotinself.color_cache:color=self.colors[len(self.color_cache.keys())%len(self.colors)]self.color_cache[author]=colorreturnself.color_cache[author]
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.