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.
# treeview.py - changelog viewer implementation## 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.'''importgtkimportgobjectimportpangoimportosimporttimefromtortoisehg.util.i18nimport_fromtortoisehg.utilimporthglibfromtortoisehg.hgtk.logviewimporttreemodelfromtortoisehg.hgtk.logview.graphcellimportCellRendererGraphfromtortoisehg.hgtk.logview.revgraphimport*COLS='graph rev id revhex branch changes msg user date utc age tag'classTreeView(gtk.ScrolledWindow):__gproperties__={'repo':(gobject.TYPE_PYOBJECT,'Repository','The Mercurial repository being visualized',gobject.PARAM_CONSTRUCT_ONLY|gobject.PARAM_WRITABLE),'limit':(gobject.TYPE_PYOBJECT,'Revision Display Limit','The maximum number of revisions to display',gobject.PARAM_READWRITE),'original-tip-revision':(gobject.TYPE_PYOBJECT,'Tip revision when application opened','Revisions above this number will be drawn green',gobject.PARAM_READWRITE),'msg-column-visible':(gobject.TYPE_BOOLEAN,'Summary','Show summary column',True,gobject.PARAM_READWRITE),'user-column-visible':(gobject.TYPE_BOOLEAN,'User','Show user column',True,gobject.PARAM_READWRITE),'date-column-visible':(gobject.TYPE_BOOLEAN,'Date','Show date column',False,gobject.PARAM_READWRITE),'utc-column-visible':(gobject.TYPE_BOOLEAN,'UTC','Show UTC/GMT date column',False,gobject.PARAM_READWRITE),'age-column-visible':(gobject.TYPE_BOOLEAN,'Age','Show age column',False,gobject.PARAM_READWRITE),'rev-column-visible':(gobject.TYPE_BOOLEAN,'Rev','Show revision number column',False,gobject.PARAM_READWRITE),'id-column-visible':(gobject.TYPE_BOOLEAN,'ID','Show revision ID column',False,gobject.PARAM_READWRITE),'revhex-column-visible':(gobject.TYPE_BOOLEAN,'Rev/ID','Show revision number/ID column',False,gobject.PARAM_READWRITE),'branch-column-visible':(gobject.TYPE_BOOLEAN,'Branch','Show branch',False,gobject.PARAM_READWRITE),'changes-column-visible':(gobject.TYPE_BOOLEAN,'Changes','Show changes column',False,gobject.PARAM_READWRITE),'tag-column-visible':(gobject.TYPE_BOOLEAN,'Tags','Show tag column',False,gobject.PARAM_READWRITE),'branch-color':(gobject.TYPE_BOOLEAN,'Branch color','Color by branch',False,gobject.PARAM_READWRITE)}__gsignals__={'revisions-loaded':(gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,()),'batch-loaded':(gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,()),'revision-selected':(gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,())}def__init__(self,repo,limit=500,stbar=None):"""Create a new TreeView. :param repo: Repository object to show """gtk.ScrolledWindow.__init__(self)self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)self.set_shadow_type(gtk.SHADOW_IN)self.batchsize=limitself.repo=repoself.currevid=Noneself.stbar=stbarself.grapher=Noneself.graphdata=[]self.index={}self.opts={'outgoing':[],'orig-tip':None,'npreviews':0,'branch-color':False,'show-graph':True}self.construct_treeview()defset_repo(self,repo,stbar=None):self.repo=repoself.stbar=stbardefsearch_in_tree(self,model,column,key,iter,data):"""Searches all fields shown in the tree when the user hits crtr+f, not just the ones that are set via tree.set_search_column. Case insensitive """key=key.lower()row=model[iter]ifrow[treemodel.HEXID].startswith(key):returnFalseforcolin(treemodel.REVID,treemodel.COMMITER,treemodel.MESSAGE):ifkeyinstr(row[col]).lower():returnFalsereturnTruedefcreate_log_generator(self,graphcol,pats,opts):ifself.repoisNone:self.grapher=Nonereturnonly_branch=opts.get('branch',None)ifopts.get('filehist')isnotNone:self.grapher=filelog_grapher(self.repo,opts['filehist'])elifgraphcol:end=0ifonly_branchisnotNone:b=self.repo.branchtags()ifonly_branchinb:node=b[only_branch]start=self.repo.changelog.rev(node)else:start=len(self.repo.changelog)-1elifopts.get('revrange'):iflen(opts['revrange'])>=2:start,end=opts['revrange']else:start=opts['revrange'][0]end=startelse:start=len(self.repo.changelog)-1noheads=opts.get('noheads',False)ifopts.get('branch-view',False):self.grapher=branch_grapher(self.repo,start,end,only_branch,self.opts.get('branch-color'))else:self.grapher=revision_grapher(self.repo,start,end,only_branch,noheads,self.opts.get('branch-color'))elifopts.get('revlist',None):self.grapher=dumb_log_generator(self.repo,opts['revlist'])else:self.grapher=filtered_log_generator(self.repo,pats,opts)self.opts['show-graph']=graphcolself.graphdata=[]self.index={}self.max_cols=1self.model=Noneself.limit=self.batchsizedefpopulate(self,revid=None):'Fill the treeview with contents'stopped=Falseifself.repoisNone:stopped=TruereturnFalseifos.name=="nt":timer=time.clockelse:timer=time.timestartsec=timer()try:while(notself.limit)orlen(self.graphdata)<self.limit:(rev,node,lines,wfile)=self.grapher.next()self.max_cols=max(self.max_cols,len(lines))self.index[rev]=len(self.graphdata)self.graphdata.append((rev,node,lines,wfile))ifself.model:rowref=self.model.get_iter(len(self.graphdata)-1)path=self.model.get_path(rowref)self.model.row_inserted(path,rowref)cursec=timer()ifcursec<startsecorcursec>startsec+0.1:breakexceptStopIteration:stopped=Trueifstopped:passelifself.limitisNone:returnTrueeliflen(self.graphdata)<self.limit:returnTrueifnotlen(self.graphdata):self.treeview.set_model(None)ifself.stbarisnotNone:self.stbar.end()self.emit('revisions-loaded')returnFalseself.graph_cell.columns_len=self.max_colswidth=self.graph_cell.get_size(self.treeview)[2]ifwidth>500:width=500gcol=self.tvcolumns['graph']gcol.set_fixed_width(width)gcol.set_visible(self.opts.get('show-graph'))ifnotself.model:model=treemodel.TreeModel(self.repo,self.graphdata,self.opts)self.treeview.set_model(model)self.model=modelself.emit('batch-loaded')ifstopped:self.emit('revisions-loaded')ifrevidisnotNone:self.set_revision_id(revid)ifself.stbarisnotNone:self.stbar.end()revision_text=_('%(count)d of %(total)d Revisions')%{'count':len(self.model),'total':len(self.repo)}self.stbar.set_text(revision_text,name='rev')returnFalsedefdo_get_property(self,property):pn=property.namecv='-column-visible'ifpn.endswith(cv):colname=pn[:-len(cv)]returnself.tvcolumns[colname].get_visible()elifpn=='branch-color':returnself.opts.get('branch-color')elifpn=='repo':returnself.repoelifpn=='limit':returnself.limitelse:raiseAttributeError,'unknown property %s'%pndefdo_set_property(self,property,value):pn=property.namecv='-column-visible'ifpn.endswith(cv):colname=pn[:-len(cv)]self.tvcolumns[colname].set_visible(value)elifpn=='branch-color':self.opts['branch-color']=valueelifpn=='repo':self.repo=valueelifpn=='limit':self.batchsize=valueelse:raiseAttributeError,'unknown property %s'%pndefget_revid_at_path(self,path):returnself.model[path][treemodel.REVID]defget_path_at_revid(self,revid):ifrevidinself.index:row_index=self.index[revid]iter=self.model.get_iter(row_index)path=self.model.get_path(iter)returnpathelse:returnNonedefget_wfile_at_path(self,path):ifself.model:returnself.model[path][treemodel.WFILE]else:returnNonedefnext_revision_batch(self,size):ifnotself.grapher:self.emit('revisions-loaded')returnself.batchsize=sizeself.limit+=self.batchsizeifself.stbarisnotNone:self.stbar.begin()gobject.idle_add(self.populate)defload_all_revisions(self):ifnotself.grapher:self.emit('revisions-loaded')returnself.limit=Noneifself.stbarisnotNone:self.stbar.begin()gobject.idle_add(self.populate)defscroll_to_revision(self,revid):ifrevidinself.index:row=self.index[revid]self.treeview.scroll_to_cell(row,use_align=True,row_align=0.5)defset_revision_id(self,revid,load=False):"""Change the currently selected revision. :param revid: Revision id of revision to display. """ifrevidinself.index:row=self.index[revid] self.treeview.set_cursor(row)
self.treeview.grab_focus()
elif load:
- handler = None
+ handler, stophandler = None, None def loaded(dummy):
if revid in self.index:
if handler is not None:
self.disconnect(handler)
+ handler = None self.set_revision_id(revid)
self.scroll_to_revision(revid)
else:
self.next_revision_batch(self.batchsize)
+ def stopped(dummy):+ if handler is not None:+ self.disconnect(handler)+ handler = None+ if stophandler is not None:+ self.disconnect(stophandler)+ stophandler = None+ self.stbar.set_text(_('Changeset not found in current view')) try:
ctx = self.repo[revid]
if ctx.rev() == -1:
- self.stbar.set_text('Null changeset is not viewable')
+ self.stbar.set_text(_('Null changeset is not viewable')) return
except Exception, e:
self.stbar.set_text(str(e))
return
handler = self.connect('batch-loaded', loaded)
+ stophandler = self.connect('revisions-loaded', stopped) self.next_revision_batch(self.batchsize)
def refresh(self, graphcol, pats, opts):
self.opts.update(opts)ifself.repoisnotNone:hglib.invalidaterepo(self.repo)iflen(self.repo)>0:self.create_log_generator(graphcol,pats,opts)ifself.stbarisnotNone:self.stbar.begin()gobject.idle_add(self.populate,self.currevid)else:self.treeview.set_model(None)self.stbar.set_text(_('Repository is empty'))defconstruct_treeview(self):self.treeview=gtk.TreeView()self.treeview.set_rules_hint(True)self.treeview.set_reorderable(False)self.treeview.set_enable_search(True)self.treeview.set_search_equal_func(self.search_in_tree,None)self.treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)self.treeview.connect("cursor-changed",self._on_selection_changed)self.treeview.set_property('fixed-height-mode',True)self.treeview.show()self.add(self.treeview)self.tvcolumns={}self.graph_cell=CellRendererGraph()col=self.tvcolumns['graph']=gtk.TreeViewColumn(_('Graph'))col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.pack_start(self.graph_cell,expand=False)col.add_attribute(self.graph_cell,"node",treemodel.GRAPHNODE)col.add_attribute(self.graph_cell,"in-lines",treemodel.LAST_LINES)col.add_attribute(self.graph_cell,"out-lines",treemodel.LINES)cell=gtk.CellRendererText()cell.set_property("width-chars",8)cell.set_property("ellipsize",pango.ELLIPSIZE_END)cell.set_property("xalign",1.0)col=self.tvcolumns['rev']=gtk.TreeViewColumn(_('Rev'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.REVID)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",15)cell.set_property("ellipsize",pango.ELLIPSIZE_END)cell.set_property("family","Monospace")col=self.tvcolumns['id']=gtk.TreeViewColumn(_('ID'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.HEXID)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",22)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['revhex']=gtk.TreeViewColumn(_('Rev/ID'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)col.add_attribute(cell,"markup",treemodel.REVHEX)cell=gtk.CellRendererText()cell.set_property("width-chars",15)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['branch']=gtk.TreeViewColumn(_('Branch'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.BRANCH)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",10)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['changes']=gtk.TreeViewColumn(_('Changes'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"markup",treemodel.CHANGES)cell=gtk.CellRendererText()cell.set_property("width-chars",80)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['msg']=gtk.TreeViewColumn(_('Summary'))col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_end(cell,expand=True)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)col.add_attribute(cell,"markup",treemodel.MESSAGE)cell=gtk.CellRendererText()cell.set_property("width-chars",20)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['user']=gtk.TreeViewColumn(_('User'))col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.COMMITER)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",20)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['date']=gtk.TreeViewColumn(_('Local Date'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.LOCALTIME)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",20)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['utc']=gtk.TreeViewColumn(_('Universal Date'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.UTC)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",16)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['age']=gtk.TreeViewColumn(_('Age'))col.set_visible(True)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.AGE)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)cell=gtk.CellRendererText()cell.set_property("width-chars",10)cell.set_property("ellipsize",pango.ELLIPSIZE_END)col=self.tvcolumns['tag']=gtk.TreeViewColumn(_('Tags'))col.set_visible(False)col.set_resizable(True)col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)col.set_fixed_width(cell.get_size(self.treeview)[2])col.pack_start(cell,expand=True)col.add_attribute(cell,"text",treemodel.TAGS)col.add_attribute(cell,"foreground",treemodel.FGCOLOR)self.columns=COLS.split()defset_columns(self,columns):if' '.join(columns)!=' '.join(self.columns):cols=self.treeview.get_columns()forcninself.columns:c=self.tvcolumns[cn]ifcincols:self.treeview.remove_column(c)forcnincolumns:try:c=self.tvcolumns[cn]self.treeview.append_column(c)exceptKeyError:continueself.columns=columnsdefget_columns(self):returnself.columnsdef_on_selection_changed(self,treeview):"""callback for when the treeview changes."""(path,focus)=treeview.get_cursor()ifpathandself.model:self.currevid=self.model[path][treemodel.REVID]self.emit('revision-selected')
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.