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.
# Published under the GNU GPL, v2 or later.# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org># Copyright (C) 2007 Henry Ludemann <misc@hl.id.au># Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>importosimporttempfileimportpythoncomfromwin32com.shellimportshell,shellconimportwin32conimportwin32processimportwin32eventimportwin32uiimportwin32guiimportwin32gui_structimportwin32apiimport_winregfrommercurialimporthg,utilfromthgutilimport*importmenuthgtry:frommercurial.errorimportRepoErrorexceptImportError:frommercurial.repoimportRepoError# FIXME: quick workaround traceback caused by missing "closed" # attribute in win32trace.importsysfrommercurialimportuidefwrite_err(self,*args):forainargs:sys.stderr.write(str(a))ui.ui.write_err=write_errS_OK=0S_FALSE=1defget_clone_repo_name(dir,repo_name):dest_clone=os.path.join(dir,repo_name)ifos.path.exists(dest_clone):dest_clone=os.path.join(dir,"Clone of "+repo_name)i=2whileos.path.exists(dest_clone):dest_clone=os.path.join(dir,"Clone of (%s) %s"%(i,repo_name))i+=1returndest_clone"""Windows shell extension that adds context menu items to Mercurial repository"""classContextMenuExtension(menuthg.menuThg):_reg_progid_="Mercurial.ShellExtension.ContextMenu"_reg_desc_="Mercurial Shell Extension"_reg_clsid_="{EEE9936B-73ED-4D45-80C9-AF918354F885}"_com_interfaces_=[shell.IID_IShellExtInit,shell.IID_IContextMenu]_public_methods_=["Initialize",# From IShellExtInit"QueryContextMenu","InvokeCommand","GetCommandString"# IContextMenu]registry_keys=[(_winreg.HKEY_CLASSES_ROOT,r"*\shellex\ContextMenuHandlers\TortoiseHg",[(None,_reg_clsid_)]),(_winreg.HKEY_CLASSES_ROOT,r"Directory\Background\shellex\ContextMenuHandlers\TortoiseHg",[(None,_reg_clsid_)]),(_winreg.HKEY_CLASSES_ROOT,r"Directory\shellex\ContextMenuHandlers\TortoiseHg",[(None,_reg_clsid_)]),(_winreg.HKEY_CLASSES_ROOT,r"Folder\shellex\ContextMenuHandlers\TortoiseHg",[(None,_reg_clsid_)]),(_winreg.HKEY_CLASSES_ROOT,r"Directory\shellex\DragDropHandlers\TortoiseHg",[(None,_reg_clsid_)]),(_winreg.HKEY_CLASSES_ROOT,r"Folder\shellex\DragDropHandlers\TortoiseHg",[(None,_reg_clsid_)]),]def__init__(self):self.folder=Noneself.fnames=[]self.menuitems={}menuthg.menuThg.__init__(self)defInitialize(self,folder,dataobj,hkey):iffolder:self.folder=shell.SHGetPathFromIDList(folder)ifdataobj:format_etc=win32con.CF_HDROP,None,1,-1,pythoncom.TYMED_HGLOBALsm=dataobj.GetData(format_etc)num_files=shell.DragQueryFile(sm.data_handle,-1)foriinrange(num_files):self.fnames.append(shell.DragQueryFile(sm.data_handle,i))def_create_menu(self,parent,menus,pos,idCmd,idCmdFirst):formenu_infoinmenus:ifmenu_info.isSep():win32gui.InsertMenu(parent,pos,win32con.MF_BYPOSITION|win32con.MF_SEPARATOR,idCmdFirst+idCmd,None)elifmenu_info.isSubmenu():submenu=win32gui.CreatePopupMenu()idCmd=self._create_menu(submenu,menu_info.get_menus(),0,idCmd,idCmdFirst)opt={'text':menu_info.menutext,'wID':idCmdFirst+idCmd,'hSubMenu':submenu,}ifmenu_info.icon:icon_path=get_icon_path("tortoise",menu_info.icon)opt['hbmpChecked']=opt['hbmpUnchecked']= \
icon_to_bitmap(icon_path)item,_=win32gui_struct.PackMENUITEMINFO(**opt)win32gui.InsertMenuItem(parent,pos,True,item)self.menuitems[idCmd]=("","")else:fstate=win32con.MF_BYCOMMANDifmenu_info.stateisFalse:fstate|=win32con.MF_GRAYEDopt={'text':menu_info.menutext,'fState':fstate,'wID':idCmdFirst+idCmd,}ifmenu_info.icon:icon_path=get_icon_path("tortoise",menu_info.icon)opt['hbmpChecked']=opt['hbmpUnchecked']= \
icon_to_bitmap(icon_path)item,_=win32gui_struct.PackMENUITEMINFO(**opt)win32gui.InsertMenuItem(parent,pos,True,item)self.menuitems[idCmd]=(menu_info.helptext,menu_info.hgcmd)idCmd+=1pos+=1returnidCmddefQueryContextMenu(self,hMenu,indexMenu,idCmdFirst,idCmdLast,uFlags):ifuFlags&shellcon.CMF_DEFAULTONLY:return0thgmenu=[]# a brutal hack to detect if we are the first menu to go on to the # context menu. If we are not the first, then add a menu separator# The number '30000' is just a guess based on my observationprint"idCmdFirst = ",idCmdFirstifidCmdFirst>=30000:thgmenu.append(menuthg.TortoiseMenuSep())# As we are a context menu handler, we can ignore verbs.ifself.folder:cwd=self.folderelifself.fnames:f=self.fnames[0]iflen(self.fnames)==1andos.path.isdir(f):cwd=fself.fnames=[]else:cwd=os.path.dirname(f)self.menuitems={}ifself.folderandself.fnames:# get menus with drag-n-drop supportthgmenu+=self.get_commands_dragdrop(self.fnames,self.folder)repo=menuthg.open_repo(self.folder)else:# get menus for hg menurepo=menuthg.open_repo(cwd)ifrepo:thgmenu+=self.get_commands(repo,cwd,self.fnames)else:thgmenu+=self.get_norepo_commands(cwd,self.fnames)self.cwd=cwdself.repo=repoidCmd=self._create_menu(hMenu,thgmenu,indexMenu,0,idCmdFirst)# Return total number of menus & submenus we've addedreturnidCmddefInvokeCommand(self,ci):mask,hwnd,verb,params,dir,nShow,hotkey,hicon=ciifverb>>16:# This is a textual verb invocation... not supported.returnS_FALSEifverbnotinself.menuitems:raiseException("Unsupported command id %i!"%verb)self.run_dialog(self.menuitems[verb][1])defGetCommandString(self,cmd,uFlags):ifuFlags&shellcon.GCS_VALIDATEAoruFlags&shellcon.GCS_VALIDATEW:ifcmdinself.menuitems:returnS_OKreturnS_FALSEifuFlags&shellcon.GCS_VERBAoruFlags&shellcon.GCS_VERBW:returnS_FALSEifuFlags&shellcon.GCS_HELPTEXTAoruFlags&shellcon.GCS_HELPTEXTW:# The win32com.shell implementation encodes the resultant# string into the correct encoding depending on the flags.returnself.menuitems[cmd][0]returnS_FALSEdefrun_dialog(self,hgcmd):cwd=self.cwd if self.repo:
# Convert filenames to be relative to cwd
files = []
- cwd_rel = cwd[len(repo.root+os.sep):]
+ cwd_rel = cwd[len(self.repo.root+os.sep):]
for f in self.fnames:
cpath = util.canonpath(self.repo.root, cwd, f)
if cpath.startswith(cwd_rel):
cpath=cpath[len(cwd_rel):]files.append(cpath)else:files.append(f)self.fnames=filesgpopts=" %s"%hgcmdifself.fnames:fd,tmpfile=tempfile.mkstemp(prefix="tortoisehg_filelist_")os.write(fd,"\n".join(self.fnames))os.close(fd)gpopts+=" --listfile %s"%(shellquote(tmpfile))app_path=find_path("hgtk",get_prog_root(),'.EXE;.BAT')ifnotapp_path:app_path=find_path("hgtk",None,'.EXE;.BAT')cmdline=shellquote(app_path)+gpoptstry:importsubprocesspop=subprocess.Popen(cmdline,shell=False,cwd=cwd,creationflags=win32con.CREATE_NO_WINDOW,stderr=subprocess.STDOUT,stdout=subprocess.PIPE,stdin=subprocess.PIPE)exceptwin32api.error,details:win32ui.MessageBox("Error executing command - %s"%(details),"gpopen")
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.