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 GPLimportgtkimportgobjectimportosimportnautilusimportsubprocessimportsysimporttempfileimporturllibtry:frommercurialimporthg,ui,match,utilexceptImportError:# workaround to use user's local python libsuserlib=os.path.expanduser('~/lib/python')ifos.path.exists(userlib)anduserlibnotinsys.path:sys.path.append(userlib)frommercurialimporthg,ui,match,utiltry:frommercurial.errorimportRepoErrorexceptImportError:frommercurial.repoimportRepoErrorfrommercurial.nodeimportshortTORTOISEHG_PATH='~/tools/tortoisehg-dev'nofilecmds='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=None# check if nautilus-thg.py is a symlink firstpfile=__file__ifpfile.endswith('.pyc'):pfile=pfile[:-1]path=os.path.dirname(os.path.realpath(pfile))thgpath=os.path.normpath(os.path.join(path,'..'))testpath=os.path.join(thgpath,'tortoise')ifos.path.isdir(testpath):ifthgpathnotinsys.path:sys.path.insert(0,thgpath)else:# try environment or hard-coded paththgpath=os.environ.get('TORTOISEHG_PATH',TORTOISEHG_PATH)thgpath=os.path.normpath(os.path.expanduser(thgpath))ifos.path.exists(thgpath)andthgpathnotinsys.path:sys.path.insert(0,thgpath)# else assume tortoise is already in PYTHONPATHtry:importtortoise.thgutilimporttortoise.menuthgexceptImportError,e:# if thgutil is not found, then repository cannot be found# if menuthg is not found, you have an older version in sys.pathprinteself.menu=Nonereturnself.env=os.environself.env['PYTHONPATH']=':'.join(sys.path) self.env['TORTOISEHG_PATH'] = thgpath
self.env['THG_ICON_PATH'] = os.path.join(thgpath, 'icons')
- self.hgproc = os.path.join(thgpath, 'hgproc.py')
+ self.hgproc = tortoise.thgutil.find_path('hgtk',
+ tortoise.thgutil.get_prog_root())+ if not self.hgproc:+ self.hgproc = tortoise.thgutil.find_path('hgtk')
self.ipath = os.path.join(thgpath, 'icons', 'tortoise')
self.menu = tortoise.menuthg.menuThg()
deficon(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:])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.cacherepo# Keep one repo cachedtry:self.cacheroot=pself.cacherepo=hg.repository(ui.ui(),path=p)returnself.cacherepoexceptRepoError:self.cacheroot=Noneself.cacherepo=NonereturnNonedefrun_dialog(self,menuitem,hgcmd,cwd=None):''' hgcmd - hgproc subcommand '''ifcwd:#bgself.files=[]else:cwd=self.cwdrepo=self.get_repo_for_path(cwd)ifhgcmd=='vdiff':diffcmd=repo.ui.config('tortoisehg','vdiff',None)ifdiffcmdisNone:hgcmd='diff'else:cmdline=['hg',diffcmd]cmdline.extend(self.files) subprocess.Popen(cmdline, shell=False, env=self.env, cwd=cwd)
return
- cmdopts = [sys.executable, self.hgproc]- cmdopts += ['--command', hgcmd]
+ cmdopts = [sys.executable, self.hgproc, hgcmd]
if hgcmd not in nofilecmds and self.files:
# Use temporary file to store file list (avoid shell command
# line limitations)fd,tmpfile=tempfile.mkstemp(prefix="tortoisehg_filelist_")os.write(fd,"\n".join(self.files))os.close(fd)cmdopts+=['--listfile',tmpfile]subprocess.Popen(cmdopts,cwd=cwd,env=self.env,shell=False)ifhgcmdnotinnocachecmds:# Remove cached repo object, dirstate may changeself.cacherepo=Noneself.cacheroot=NonedefbuildMenu(self,vfs_files,bg):'''Build menu'''self.pos=0self.files=[]files=[self.get_path_for_vfs_file(f)forfinvfs_files]ifbg:cwd=files[0]files=[]repo=self.get_repo_for_path(cwd)else:f=files[0]cwd=os.path.isdir(f)andforos.path.dirname(f)repo=self.get_repo_for_path(cwd)ifrepo:menus=self.menu.get_commands(repo,cwd,files)forfinfiles:cpath=util.canonpath(repo.root,cwd,f)ifcpath.startswith(cwd):cpath=cpath[len(cwd+os.sep):]self.files.append(cpath)else:self.files.append(f)else: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'%self.posself.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):fromtortoiseimportcachethgcachestate=cachethg.get_state(localpath,repo)cache2state={cachethg.UNCHANGED:('default','clean'),cachethg.ADDED:('cvs-aded','added'),cachethg.MODIFIED:('cvs-modified','modified'),cachethg.UNKNOWN:('new','unrevisioned'),cachethg.IGNORED:(None,'ignored'),cachethg.NOT_IN_REPO:(None,'')}emblem,status=cache2state.get(cachestate)ifstatus==None:status='?'returnemblem,statusdefupdate_file_info(self,file):'''Return emblem and hg status for this file'''path=self.get_path_for_vfs_file(file)ifnotpath:returnemblem,status=self._get_file_status(self.cacherepo,path)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,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.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')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.