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.
"""shlib.py - TortoiseHg shell utilities Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>This software may be used and distributed according to the termsof the GNU General Public License, incorporated herein by reference."""importosimportsysimportcPickleimporttimefrommercurial.i18nimport_frommercurialimportutilfrommercurialimporthgclassSimpleMRUList(object):def__init__(self,size=10,reflist=[],compact=True):self._size=sizeself._list=reflistifcompact:self.compact()def__iter__(self):foreleminself._list:yieldelemdefadd(self,val):ifvalinself._list:self._list.remove(val)self._list.insert(0,val)self.flush()defget_size(self):returnself._sizedefset_size(self,size):self._size=sizeself.flush()defflush(self):whilelen(self._list)>self._size:delself._list[-1]defcompact(self):''' remove duplicate in list '''newlist=[]forvinself._list:ifvnotinnewlist:newlist.append(v)self._list[:]=newlistclassSettings(object):def__init__(self,appname,path=None):self._appname=appnameself._data={}self._path=pathandpathorself._get_path(appname)self._audit()self.read()defget_value(self,key,default=None,create=False):ifkeyinself._data:returnself._data[key]elifcreate:self._data[key]=defaultreturndefaultdefset_value(self,key,value):self._data[key]=valuedefmrul(self,key,size=10):''' wrapper method to create a most-recently-used (MRU) list '''ls=self.get_value(key,[],True)ml=SimpleMRUList(size=size,reflist=ls)returnmldefget_keys(self):returnself._data.keys()defget_appname(self):returnself._appnamedefread(self):self._data.clear()ifos.path.exists(self._path):try:f=file(self._path,'rb')self._data=cPickle.loads(f.read())f.close()exceptException:passdefwrite(self):self._write(self._path,self._data)def_write(self,appname,data):s=cPickle.dumps(data)f=util.atomictempfile(appname,'wb',None)f.write(s)f.rename()def_get_path(self,appname):ifos.name=='nt':returnos.path.join(os.environ.get('APPDATA'),'TortoiseHg',appname)else:returnos.path.join(os.path.expanduser('~'),'.tortoisehg',appname)def_audit(self):ifos.path.exists(os.path.dirname(self._path)):returnos.makedirs(os.path.dirname(self._path))defget_system_times():t=os.times()ift[4]==0.0:# Windows leaves this as zero, so use time.clock()t=(t[0],t[1],t[2],t[3],time.clock())returntdefget_tortoise_icon(thgicon):'''Find a tortoise icon, apply to PyGtk window'''# The context menu should set this variablevar=os.environ.get('THG_ICON_PATH',None)paths=varand[var]or[]try:# Else try relative paths from hggtk, the repository layoutfdir=os.path.dirname(__file__)paths.append(os.path.join(fdir,'..','icons'))# ... or the unix installer layoutpaths.append(os.path.join(fdir,'..','..','..','share','pixmaps','tortoisehg','icons'))paths.append(os.path.join(fdir,'..','..','..','..','share','pixmaps','tortoisehg','icons'))exceptNameError:# __file__ is not always availablepassforpinpaths:path=os.path.join(p,'tortoise',thgicon)ifos.path.isfile(path):returnpathelse:print_('icon not found'),thgiconreturnNonedefversion():try:import__version__return__version__.versionexceptImportError:return_('unknown')ifos.name=='nt':defshell_notify(paths):try:fromwin32com.shellimportshell,shellcon import pywintypes
except ImportError:
return
- dirs = []+ dirs = set() for path in paths:
abspath = os.path.abspath(path)
if not os.path.isdir(abspath):
abspath = os.path.dirname(abspath)
- if abspath not in dirs:- dirs.append(abspath)
+ dirs.add(abspath)
# send notifications to deepest directories first
- dirs.sort(lambda x, y: len(y) - len(x))- for dir in dirs:
+ for dir in sorted(dirs, key=len, reverse=True):
try:
pidl, ignore = shell.SHILCreateFromPath(dir, 0)
except pywintypes.com_error:
returnifpidlisNone:continueshell.SHChangeNotify(shellcon.SHCNE_UPDATEITEM,shellcon.SHCNF_IDLIST|shellcon.SHCNF_FLUSH,pidl,None)defupdate_thgstatus(ui,root,wait=False):'''Rewrite the file .hg/thgstatus Caches the information provided by repo.status() in the file .hg/thgstatus, which can then be read by the overlay shell extension to display overlay icons for directories. The file .hg/thgstatus contains one line for each directory that has removed, modified or added files (in that order of preference). Each line consists of one char for the status of the directory (r, m or a), followed by the relative path of the directory in the repo. If the file .hg/thgstatus is empty, then the repo's working directory is clean. Specify wait=True to wait until the system clock ticks to the next second before accessing Mercurial's dirstate. This is useful when Mercurial's .hg/dirstate contains unset entries (in output of "hg debugstate"). unset entries happen if .hg/dirstate was updated within the same second as Mercurial updated the respective file in the working tree. This happens with a high probability for example when cloning a repo. The overlay shell extension will display unset dirstate entries as (potentially false) modified. Specifying wait=True ensures that there are no unset entries left in .hg/dirstate when this function exits. '''ifwait:tref=time.time()tdelta=float(int(tref))+1.0-trefif(tdelta>0.0):time.sleep(tdelta)repo=hg.repository(ui,root)# a fresh repo object is neededrepostate=repo.status()# will update .hg/dirstate as a side effectmodified,added,removed,deleted=repostate[:4]dirstatus={}defdirname(f):return'/'.join(f.split('/')[:-1])forfninadded:dirstatus[dirname(fn)]='a'forfninmodified:dirstatus[dirname(fn)]='m'forfninremoved+deleted:dirstatus[dirname(fn)]='r'f=open(repo.join("thgstatus"),'wb')fordninsorted(dirstatus):f.write(dirstatus[dn]+dn+'\n')f.close()else:defshell_notify(paths):ifnotpaths:returnnotify=os.environ.get('THG_NOTIFY','.tortoisehg/notify')ifnotos.path.isabs(notify):notify=os.path.join(os.path.expanduser('~'),notify)os.environ['THG_NOTIFY']=notifyifnotos.path.isfile(notify):returnf_notify=open(notify,'w')try:f_notify.write('\n'.join([os.path.abspath(path)forpathinpaths]))finally:f_notify.close()defupdate_thgstatus(*args,**kws):pass
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.