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 GPLimportgtkimportgobjectimport nautilus
import gnomevfs
import os
+import systry:
from mercurial import demandimport
exceptImportError:# 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()
import subprocess
-import sysimport urllib
from mercurial import hg, ui, match, util
frommercurial.nodeimportshortdef_thg_path():# 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)_thg_path()fromthgutilimportpaths,debugthg,hglib,cachethgfromhggtkimportgtklibifdebugthg.debug('N'):debugf=debugthg.debugfelse:debugf=debugthg.debugf_Nonofilecmds='about serve synch repoconfig userconfig merge unmerge'.split()classHgExtension(nautilus.MenuProvider,nautilus.ColumnProvider,nautilus.InfoProvider,nautilus.PropertyPageProvider):def__init__(self):self.scanStack=[]self.allvfs={}self.inv_dirs=set()fromthgutilimportmenuthgself.hgtk=paths.find_in_path('hgtk')self.menu=menuthg.menuThg()self.notify=os.path.expanduser('~/.tortoisehg/notify')try:f=open(self.notify,'w')f.close()ds_uri=gnomevfs.get_uri_from_local_path(self.notify)self.gmon=gnomevfs.monitor_add(ds_uri,gnomevfs.MONITOR_FILE,self.notified)except(gnomevfs.NotSupportedError,IOError),e:debugf('no notification because of %s',e)self.notify=''deficon(self,iname):returnpaths.get_tortoise_icon(iname)defget_path_for_vfs_file(self,vfs_file,store=True):ifvfs_file.get_uri_scheme()!='file':returnNonepath=urllib.unquote(vfs_file.get_uri()[7:])ifvfs_file.is_gone():self.allvfs.pop(path,'')returnNoneifstore:self.allvfs[path]=vfs_filereturnpathdefget_vfs(self,path):vfs=self.allvfs.get(path,None)ifvfsandvfs.is_gone():delself.allvfs[path]returnNonereturnvfsdefget_repo_for_path(self,path):''' Find mercurial repository for vfs_file Returns hg.repo '''p=paths.find_root(path)ifnotp:returnNonetry:returnhg.repository(ui.ui(),path=p)excepthglib.RepoError:returnNoneexceptStandardError,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()defbuildMenu(self,vfs_files,bg):'''Build menu'''self.pos=0self.files=[]files=[]forvfs_fileinvfs_files:f=self.get_path_for_vfs_file(vfs_file)iff: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=[]ifself.files:passcwd=Noneelse:#bgpasscwd=self.cwdformenu_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,localpath,repo=None):cachestate=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:returnFalsetry:vfs_file=self.scanStack.pop()path=self.get_path_for_vfs_file(vfs_file,False)ifnotpath:returnTrueoldvfs=self.get_vfs(path)ifoldvfsandoldvfs!=vfs_file:#file has changed on disc (not invalidated)self.get_path_for_vfs_file(vfs_file)#save new vfsself.invalidate([os.path.dirname(path)])emblem,status=self._get_file_status(path)ifemblemisnotNone:vfs_file.add_emblem(emblem)vfs_file.add_string_attribute('hg_status',status)exceptStandardError,e:debugf(e)returnTruedefnotified(self,mon_uri=None,event_uri=None,event=None):debugf('notified from hgtk, %s',event,level='n')f=open(self.notify,'a+')files=Nonetry:files=[line[:-1]forlineinfifline]iffiles:f.truncate(0)finally:f.close()ifnotfiles:returnroot=os.path.commonprefix(files)root=paths.find_root(root)ifroot:self.invalidate(files,root)definvalidate(self,paths,root=''):started=bool(self.inv_dirs)ifcachethg.cache_pdir==rootandrootnotinself.inv_dirs:cachethg.overlay_cache.clear()self.inv_dirs.update([os.path.dirname(root),'/',''])forpathinpaths:path=os.path.join(root,path)whilepathnotinself.inv_dirs:self.inv_dirs.add(path)path=os.path.dirname(path)ifcachethg.cache_pdir==path:cachethg.overlay_cache.clear()ifstarted:returniflen(paths)>1:self._invalidate_dirs()else:#group invalidation of directoriesgobject.timeout_add(200,self._invalidate_dirs)def_invalidate_dirs(self):forpathinself.inv_dirs:vfs=self.get_vfs(path)ifvfs:vfs.invalidate_extension_info()self.inv_dirs.clear()# 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(path,repo)# 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=gtklib.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.