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 Henry Ludemann <misc@hl.id.au># Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>importosimportwin32apiimportwin32confromwin32com.shellimportshell,shellconimport_winregfrommercurialimporthg,cmdutil,utilfrommercurialimportrepoas_repoimportthgutilimportsys# FIXME: quick workaround traceback caused by missing "closed" # attribute in win32trace.frommercurialimportuidefwrite_err(self,*args):forainargs:sys.stderr.write(str(a))ui.ui.write_err=write_err# file/directory statusUNCHANGED="unchanged"ADDED="added"MODIFIED="modified"UNKNOWN="unknown"NOT_IN_REPO="n/a"# file status cacheCACHE_TIMEOUT=5000overlay_cache={}cache_tick_count=0cache_root=Nonecache_pdir=None# some misc constantsS_OK=0S_FALSE=1defadd_dirs(list):dirs=set()forfinlist:dir=os.path.dirname(f)ifdirindirs:continuewhiledir:dirs.add(dir)dir=os.path.dirname(dir)list.extend(dirs)class IconOverlayExtension(object):
"""
Class to implement icon overlays for source controlled files.
+ Specialized classes are created for each overlay icon. Displays a different icon based on version control status.
NOTE: The system allocates only 15 slots in _total_ for all
icon overlays; we (will) use 6, tortoisecvs uses 7... not a good
- recipe for a happy system.
+ recipe for a happy system. By utilizing the TortoiseOverlay.dll+ we can share overlay slots with the other tortoises. """
counter = 0
_com_interfaces_=[shell.IID_IShellIconOverlayIdentifier]_public_methods_=["GetOverlayInfo","GetPriority","IsMemberOf"]_reg_threading_='Apartment'defGetOverlayInfo(self):return("",0,0)defGetPriority(self):return0def_get_state(self,upath):""" Get the state of a given path in source control. """globaloverlay_cache,cache_tick_countglobalcache_root,cache_pdir#print "called: _get_state(%s)" % pathtc=win32api.GetTickCount()try:# handle some Asian charsetspath=upath.encode('mbcs')except:path=upath# check if path is cachedpdir=os.path.dirname(path)ifcache_pdir==pdirandoverlay_cache:iftc-cache_tick_count<CACHE_TIMEOUT:try:status=overlay_cache[path]except:status=UNKNOWNprint"%s: %s (cached)"%(path,status)returnstatuselse:print"Timed out!!"overlay_cache.clear()# path is a driveifpath.endswith(":\\"):overlay_cache[path]=UNKNOWNreturnNOT_IN_REPO# open repoifcache_pdir==pdir:root=cache_rootelse:print"find new root"cache_pdir=pdircache_root=root=thgutil.find_root(pdir)print"_get_state: root = ",rootifrootisNone:print"_get_state: not in repo"overlay_cache={None:None}cache_tick_count=win32api.GetTickCount()returnNOT_IN_REPOtry:tc1=win32api.GetTickCount()repo=hg.repository(ui.ui(),path=root)print"hg.repository() took %d ticks"%(win32api.GetTickCount()-tc1)# check if to display overlay icons in this repoglobal_opts=ui.ui().configlist('tortoisehg','overlayicons',[])repo_opts=repo.ui.configlist('tortoisehg','overlayicons',[])print"%s: global overlayicons = "%path,global_optsprint"%s: repo overlayicons = "%path,repo_optsis_netdrive=thgutil.netdrive_status(path)isnotNoneif(is_netdriveand'localdisks'inglobal_opts) \
or'False'inrepo_opts:print"%s: overlayicons disabled"%pathoverlay_cache={None:None}cache_tick_count=win32api.GetTickCount()returnNOT_IN_REPOexcept_repo.RepoError:# We aren't in a working treeprint"%s: not in repo"%diroverlay_cache[path]=UNKNOWNreturnNOT_IN_REPO# get file statustc1=win32api.GetTickCount()modified,added,removed,deleted=[],[],[],[]unknown,ignored,clean=[],[],[]files=[]try:files,matchfn,anypats=cmdutil.matchpats(repo,[pdir])modified,added,removed,deleted,unknown,ignored,clean= \
repo.status(files=files,list_ignored=True,list_clean=True,list_unknown=True)# add directory status to listforgrpin(clean,modified,added,removed,deleted,ignored,unknown):add_dirs(grp)exceptutil.Abort,inst:print"abort: %s"%instprint"treat as unknown : %s"%pathreturnUNKNOWNprint"status() took %d ticks"%(win32api.GetTickCount()-tc1)# cached file infotc=win32api.GetTickCount()overlay_cache={}forgrp,stin((ignored,UNKNOWN),(unknown,UNKNOWN),(clean,UNCHANGED),(added,ADDED),(removed,MODIFIED),(deleted,MODIFIED),(modified,MODIFIED)):forfingrp:fpath=os.path.join(repo.root,os.path.normpath(f))overlay_cache[fpath]=stifpathinoverlay_cache:status=overlay_cache[path]else:status=overlay_cache[path]=UNKNOWNprint"%s: %s"%(path,status)cache_tick_count=win32api.GetTickCount()returnstatusdefIsMemberOf(self,path,attrib):try:tc=win32api.GetTickCount()ifself._get_state(path)==self.state:returnS_OKreturnS_FALSEfinally:print"IsMemberOf: _get_state() took %d ticks"% \
(win32api.GetTickCount()-tc)defmake_icon_overlay(name,icon_type,state,clsid):""" Make an icon overlay COM class. Used to create different COM server classes for highlighting the files with different source controlled states (eg: unchanged, modified, ...). """classname="%sOverlay"%nameprog_id="Mercurial.ShellExtension.%s"%classnamedesc="Mercurial icon overlay shell extension for %s files"%name.lower()reg=[(_winreg.HKEY_LOCAL_MACHINE,r"Software\TortoiseOverlays\%s"%icon_type)]cls=type(classname,(IconOverlayExtension,),dict(_reg_clsid_=clsid,_reg_progid_=prog_id,_reg_desc_=desc,registry_keys=reg,stringKey="HG",state=state))_overlay_classes.append(cls)# We need to register the class as global, as pythoncom will# create an instance of it.globals()[classname]=cls_overlay_classes=[]make_icon_overlay("Changed","Modified",MODIFIED,"{4D0F33E1-654C-4A1B-9BE8-E47A98752BAB}")make_icon_overlay("Unchanged","Normal",UNCHANGED,"{4D0F33E2-654C-4A1B-9BE8-E47A98752BAB}")make_icon_overlay("Added","Added",ADDED,"{4D0F33E3-654C-4A1B-9BE8-E47A98752BAB}")
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.