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.
# Trivial Mercurial plugin for Nautilus## Copyright (C) 2007 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 GPLimportgconfimportgtkimportgobjectfrommercurialimporthg,ui,match,utilfrommercurial.nodeimportshortimporttortoise.menuthgimportnautilusimportosimportsubprocessimportsysimporttempfileimporttimeimporturllibtry:frommercurial.errorimportRepoErrorexceptImportError:frommercurial.repoimportRepoErrorTORTOISEHG_PATH='~/tools/tortoisehg-dev'TERMINAL_KEY='/desktop/gnome/applications/terminal/exec'classHgExtension(nautilus.MenuProvider,nautilus.ColumnProvider,nautilus.InfoProvider,nautilus.PropertyPageProvider):def__init__(self):self.cacherepo=Noneself.cacheroot=Noneself.client=gconf.client_get_default()thgpath=os.environ.get('TORTOISEHG_PATH',os.path.expanduser(TORTOISEHG_PATH))os.environ['TORTOISEHG_PATH']=thgpathos.environ['THG_ICON_PATH']=os.path.join(thgpath,'icons')self.hgproc=os.path.join(thgpath,'hgproc.py')self.ipath=os.path.join(thgpath,'icons','tortoise')self.menu=tortoise.menuthg.menuThg()self.menu.handlers=selfdeficon(self,iname):returnos.path.join(self.ipath,iname)defget_path_for_vfs_file(self,vfs_file):ifvfs_file.get_uri_scheme()!='file':returnNonereturnurllib.unquote(vfs_file.get_uri()[7:])defclear_cached_repo(self):self.cacheroot=Noneself.cacherepo=Nonedefget_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.cacherepo# Keep one repo cachedtry:self.cacheroot=pself.cacherepo=hg.repository(ui.ui(),path=p)returnself.cacherepoexceptRepoError:self.cacheroot=Noneself.cacherepo=NonereturnNone#start dialogsdef_open_terminal(self,window,info):path=self.get_path_for_vfs_file(vfs_file)ifpathisNone:returnos.chdir(path)terminal=self.client.get_string(TERMINAL_KEY)os.system('%s &'%terminal)def_about(self,window,info):self._run_dialog('about',filelist=False)def_add(self,window,vfs_files):self._run_dialog('add')self.clear_cached_repo()def_clone(self,window,info):self._run_dialog('clone')def_commit(self,window,vfs_files):self._run_dialog('commit')self.clear_cached_repo()def_datamine(self,window,vfs_files):self._run_dialog('datamine')def_diff(self,window,vfs_files):path=self.files[0]ifpathisNone:returnrepo=self.get_repo_for_path(path)ifrepoisNone:returndiffcmd=repo.ui.config('tortoisehg','vdiff',None)ifdiffcmdisNone:self._run_dialog('diff')else:cmdline=['hg',diffcmd]cwd=os.path.isdir(path)andpathoros.path.dirname(path)paths=[self.get_path_for_vfs_file(f)forfinvfs_files]subprocess.Popen(cmdline+paths,shell=False,cwd=cwd)def_history(self,window,info):self._run_dialog('history')self.clear_cached_repo()def_init(self,window,info):self._run_dialog('init')def_recovery(self,window,info):self._run_dialog('recovery')self.clear_cached_repo()def_revert(self,window,vfs_files):self._run_dialog('revert')self.clear_cached_repo()def_serve(self,window,info):self._run_dialog('serve',filelist=False) def _status(self, window, info):
self._run_dialog('status')
- def _sync(self, window, info):
+ def _synch(self, window, info):
self._run_dialog('synch', filelist=False)
self.clear_cached_repo()
def_config_repo(self,window,info):self._run_dialog('config')def_config_user(self,window,info):self._run_dialog('config',filelist=False)def_unmerge(self,window,info):self._run_dialog('checkout',filelist=False,extras=['--','--clean',str(self.rev0)])self.clear_cached_repo()def_shelve(self,window,info):print"not supported"# will be replaced_vdiff=_diffdef_rename(self,window,info):print"not supported"# will be replaceddef_remove(self,window,info):print"not supported"# will be replaceddef_annotate(self,window,info):print"not supported"# will be replaceddef_update(self,window,info):print"not supported"# will be replaceddef_merge(self,window,info):print"not supported"# will be replaced def _grep(self, window, info):
print "not supported" # will be replaced
- def _synch(self, window, info):- print "not supported" # will be replaced- def _run_dialog(self, hgcmd, filelist=True, extras=[]):
'''
hgcmd - hgproc subcommand
filelist - bool for whether to generate file list for hgproc '''paths=self.filesifpaths[0]isNone:returnpath=paths[0]repo=self.get_repo_for_path(path)cwd=os.path.isdir(path)andpathoros.path.dirname(path)ifrepoisnotNone:root=repo.rootelse:root=cwdcmdopts=[sys.executable,self.hgproc]cmdopts+=['--root',root]cmdopts+=['--cwd',cwd]cmdopts+=['--command',hgcmd]iffilelist:# Use temporary file to store file list (avoid shell command# line limitations)fd,tmpfile=tempfile.mkstemp(prefix="tortoisehg_filelist_")os.write(fd,"\n".join(paths))os.close(fd)cmdopts+=['--listfile',tmpfile,'--deletelistfile']cmdopts.extend(extras)subprocess.Popen(cmdopts,cwd=cwd,shell=False)# Remove cached repo object, dirstate may changeself.cacherepo=Noneself.cacheroot=NonedefbuildMenu(self,menuf,vfsfile):'''Build menu'''self.files=[self.get_path_for_vfs_file(f)forfinvfsfile]returnself._buildMenu(menuf(self.files))def_buildMenu(self,menus,pos=0):'''Build menu'''items=[]formenu_infoinmenus:pos+=1idstr='HgNautilus::%02d'%posifmenu_info.isSep():#can not insert a separator till nowpasselifmenu_info.isSubmenu():ifnautilus.__dict__.get('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(),pos):items.append(subitem)pos+=1else:ifmenu_info.state:item=nautilus.MenuItem(idstr,menu_info.menutext,menu_info.helptext,self.icon(menu_info.icon))item.connect('activate',menu_info.handler,'')items.append(item)returnitemsdefget_background_items(self,window,vfs_file):'''Build context menu for current directory'''ifvfs_file:returnself.buildMenu(self.menu.get_commands,[vfs_file])defget_file_items(self,window,vfs_files):'''Build context menu for selected files/directories'''ifvfs_files:returnself.buildMenu(self.menu.get_commands,vfs_files)defget_columns(self):returnnautilus.Column("HgNautilus::80hg_status","hg_status","HG Status","Version control status"),def_get_file_status(self,repo,localpath):emblem=Nonestatus='?'# This is not what the API is optimized for, but this appears# to work efficiently enoughmatcher=match.always(repo.root,localpath)changes=repo.dirstate.status(matcher,True,True,True)(lookup,modified,added,removed,deleted,unknown,ignored,clean)=changesiflocalpathinclean:emblem='default'status='clean'eliflocalpathinmodified:emblem='cvs-modified'status='modified'eliflocalpathinadded:emblem='cvs-aded'status='added'eliflocalpathinunknown:emblem='new'status='unrevisioned'eliflocalpathinignored:status='ignored'eliflocalpathindeleted:# Should be hard to reach this stateemblem='stockmail-priority-high'status='deleted'returnemblem,statusdefupdate_file_info(self,file):'''Return emblem and hg status for this file'''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,localpath)ifemblemisnotNone:file.add_emblem(emblem)file.add_string_attribute('hg_status',status)# property page borrowed from http://www.gnome.org/~gpoo/hg/nautilus-hg/def__add_row(self,table,row,label_item,label_value):label=gtk.Label(label_item)label.set_use_markup(True)label.set_alignment(1,0)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()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,localpath)# Get the information from Mercurialctx=repo.changectx(None).parents()[0]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')table=gtk.Table(7,2,False)table.set_border_width(5)table.set_row_spacings(5)table.set_col_spacings(5)self.__add_row(table,0,'<b>Status</b>:',status)self.__add_row(table,1,'<b>Last-Commit-Revision</b>:',str(rev))self.__add_row(table,2,'<b>Last-Commit-Description</b>:',description)self.__add_row(table,3,'<b>Last-Commit-Date</b>:',date)self.__add_row(table,4,'<b>Last-Commit-User</b>:',user)iftags:self.__add_row(table,5,'<b>Tags</b>:',tags)ifbranch!='default':self.__add_row(table,6,'<b>Branch</b>:',branch)table.show()returnnautilus.PropertyPage("MercurialPropertyPage::status",self.property_label,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.