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.
# TortoiseHg plugin for Nautilus## Copyright (C) 2007-9 Steve Borho## Stolen mercilessly from nautilus-bzr, thanks guys# Copyright (C) 2006 Jeff Bailey# Copyright (C) 2006 Wouter van Heyst# Copyright (C) 2006 Jelmer Vernooij## Published under the GNU GPLimportgtkimportgobjectimportnautilustry:frommercurialimportdemandimportexceptImportError:# workaround to use user's local python libsuserlib=os.path.expanduser('~/lib/python')ifos.path.exists(userlib)anduserlibnotinsys.path:sys.path.append(userlib)frommercurialimportdemandimportdemandimport.enable()importosimportsubprocessimportsysimporturllibfrommercurialimporthg,ui,match,utilfrommercurial.nodeimportshortnofilecmds='about serve synch repoconfig userconfig merge unmerge'.split()nocachecmds='about serve repoconfig userconfig'.split()classHgExtension(nautilus.MenuProvider,nautilus.ColumnProvider,nautilus.InfoProvider,nautilus.PropertyPageProvider):def__init__(self):self.cacherepo=Noneself.cacheroot=Noneself.scanStack=[]# check if nautilus-thg.py is a symlink firstpfile=__file__ifpfile.endswith('.pyc'):pfile=pfile[:-1]path=os.path.dirname(os.path.dirname(os.path.realpath(pfile)))thgpath=os.path.normpath(path)testpath=os.path.join(thgpath,'thgutil')ifos.path.isdir(testpath)andthgpathnotinsys.path:sys.path.insert(0,thgpath)# else assume thgutil is already in PYTHONPATHtry:fromthgutilimportpaths,debugthg,menuthgexceptImportError,e:printeself.menu=Nonereturnself.hgtk=paths.find_in_path('hgtk')self.menu=menuthg.menuThg()globaldebugfifdebugthg.debug('N'):debugf=debugthg.debugfelse:debugf=debugthg.debugf_Nodeficon(self,iname):fromthgutilimportpathsreturnpaths.get_tortoise_icon(iname)defget_path_for_vfs_file(self,vfs_file):ifvfs_file.is_gone()orvfs_file.get_uri_scheme()!='file':returnNonereturnurllib.unquote(vfs_file.get_uri()[7:])defget_repo_for_path(self,path):''' Find mercurial repository for vfs_file Returns hg.repo '''p=os.path.isdir(path)andpathoros.path.dirname(path)whilenotos.path.isdir(os.path.join(p,".hg")):oldp=pp=os.path.dirname(p)ifp==oldp:returnNoneifp==self.cacheroot:returnself.cacherepofromthgutilimporthglib# Keep one repo cachedtry:self.cacheroot=pself.cacherepo=hg.repository(ui.ui(),path=p)returnself.cacherepoexcepthglib.RepoError:self.cacheroot=Noneself.cacherepo=NonereturnNoneexceptStandardError,e:debugf(e)returnNonedefrun_dialog(self,menuitem,hgtkcmd,cwd=None):''' hgtkcmd - hgtk subcommand '''ifcwd:#bgself.files=[]else:cwd=self.cwdrepo=self.get_repo_for_path(cwd)cmdopts=[sys.executable,self.hgtk,hgtkcmd]ifhgtkcmdnotinnofilecmdsandself.files:pipe=subprocess.PIPEcmdopts+=['--listfile','-']else:pipe=Noneproc=subprocess.Popen(cmdopts,cwd=cwd,stdin=pipe,shell=False)ifpipe:proc.stdin.write('\n'.join(self.files))proc.stdin.close()ifhgtkcmdnotinnocachecmds:# Remove cached repo object, dirstate may changeself.cacherepo=Noneself.cacheroot=NonedefbuildMenu(self,vfs_files,bg): '''Build menu'''
self.pos = 0
self.files = []
- files = []
+ files = []
for vfs_file in vfs_files:
f = self.get_path_for_vfs_file(vfs_file)
if f:
files.append(f)ifnotfiles:returnifbgorlen(files)==1andvfs_files[0].is_directory():cwd=files[0]files=[]else:cwd=os.path.dirname(files[0])repo=self.get_repo_for_path(cwd)ifrepo:menus=self.menu.get_commands(repo,cwd,files)self.files=fileselse:menus=self.menu.get_norepo_commands(cwd,files)self.cwd=cwdreturnself._buildMenu(menus) def _buildMenu(self, menus):
'''Build one level of a menu'''
items = []
-if self.files:
+if self.files:
passcwd = None
else: #bg
passcwd = self.cwd
formenu_infoinmenus:idstr='HgNautilus::%02d%s'%(self.pos,menu_info.hgcmd)self.pos+=1ifmenu_info.isSep():# can not insert a separator till nowpasselifmenu_info.isSubmenu():ifhasattr(nautilus,'Menu'):item=nautilus.MenuItem(idstr,menu_info.menutext,menu_info.helptext)submenu=nautilus.Menu()item.set_submenu(submenu)forsubiteminself._buildMenu(menu_info.get_menus()):submenu.append_item(subitem)items.append(item)else:#submenu not suportedforsubiteminself._buildMenu(menu_info.get_menus()):items.append(subitem)else:ifmenu_info.state:item=nautilus.MenuItem(idstr,menu_info.menutext,menu_info.helptext,self.icon(menu_info.icon))item.connect('activate',self.run_dialog,menu_info.hgcmd,passcwd)items.append(item)returnitemsdefget_background_items(self,window,vfs_file):'''Build context menu for current directory'''ifvfs_fileandself.menu:returnself.buildMenu([vfs_file],True)else:self.files=[]defget_file_items(self,window,vfs_files):'''Build context menu for selected files/directories'''ifvfs_filesandself.menu:returnself.buildMenu(vfs_files,False)defget_columns(self):returnnautilus.Column("HgNautilus::80hg_status","hg_status","HG Status","Version control status"),def_get_file_status(self,repo,localpath):fromthgutilimportcachethgcachestate=cachethg.get_state(localpath,repo)cache2state={cachethg.UNCHANGED:('default','clean'),cachethg.ADDED:('cvs-added','added'),cachethg.MODIFIED:('cvs-modified','modified'),cachethg.UNKNOWN:('new','unrevisioned'),cachethg.IGNORED:(None,'ignored'),cachethg.NOT_IN_REPO:(None,''),cachethg.ROOT:('generic','root'),cachethg.UNRESOLVED:('cvs-confilict','unresolved')}emblem,status=cache2state.get(cachestate,(None,'?'))returnemblem,statusdefupdate_file_info(self,file):'''Queue file for emblem and hg status update'''self.scanStack.append(file)iflen(self.scanStack)==1:gobject.idle_add(self.fileinfo_on_idle)deffileinfo_on_idle(self):'''Update emblem and hg status for files when there is time'''ifnotself.scanStack:returnFalsevfs_file=self.scanStack.pop()path=self.get_path_for_vfs_file(vfs_file)ifnotpath:returnTrueemblem,status=self._get_file_status(self.cacherepo,path)ifemblemisnotNone:vfs_file.add_emblem(emblem)vfs_file.add_string_attribute('hg_status',status)returnTrue# property page borrowed from http://www.gnome.org/~gpoo/hg/nautilus-hg/def__add_row(self,row,label_item,label_value):label=gtk.Label(label_item)label.set_use_markup(True)label.set_alignment(1,0)self.table.attach(label,0,1,row,row+1,gtk.FILL,gtk.FILL,0,0)label.show()label=gtk.Label(label_value)label.set_use_markup(True)label.set_alignment(0,1)label.show()self.table.attach(label,1,2,row,row+1,gtk.FILL,0,0,0)defget_property_pages(self,vfs_files):iflen(vfs_files)!=1:returnfile=vfs_files[0]path=self.get_path_for_vfs_file(file)ifpathisNoneorfile.is_directory():returnrepo=self.get_repo_for_path(path)ifrepoisNone:returnlocalpath=path[len(repo.root)+1:]emblem,status=self._get_file_status(repo,path)# Get the information from Mercurialctx=repo['.']try:fctx=ctx.filectx(localpath)rev=fctx.filelog().linkrev(fctx.filerev())except:rev=ctx.rev()ctx=repo.changectx(rev)node=short(ctx.node())date=util.datestr(ctx.date(),'%Y-%m-%d %H:%M:%S %1%2')parents='\n'.join([short(p.node())forpinctx.parents()])description=ctx.description()user=ctx.user()user=gobject.markup_escape_text(user)tags=', '.join(ctx.tags())branch=ctx.branch()self.property_label=gtk.Label('Mercurial')self.table=gtk.Table(7,2,False)self.table.set_border_width(5)self.table.set_row_spacings(5)self.table.set_col_spacings(5)self.__add_row(0,'<b>Status</b>:',status)self.__add_row(1,'<b>Last-Commit-Revision</b>:',str(rev))self.__add_row(2,'<b>Last-Commit-Description</b>:',description)self.__add_row(3,'<b>Last-Commit-Date</b>:',date)self.__add_row(4,'<b>Last-Commit-User</b>:',user)iftags:self.__add_row(5,'<b>Tags</b>:',tags)ifbranch!='default':self.__add_row(6,'<b>Branch</b>:',branch)self.table.show()returnnautilus.PropertyPage("MercurialPropertyPage::status",self.property_label,self.table),
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.