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.
If the repository has an 'mq' member, then poll for changes in .hg/patches/queue (where queue folder changes occur) and also poll the series file in the current queue folder.
# thgrepo.py - TortoiseHg additions to key Mercurial classes## Copyright 2010 George Marrows <george.marrows@gmail.com>## This software may be used and distributed according to the terms of the# GNU General Public License version 2 or any later version.## See mercurial/extensions.py, comments to wrapfunction, for this approach# to extending repositories and change contexts.importosimportsysfromPyQt4.QtCoreimport*frommercurialimporthg,util,error,bundlerepo,extensions,filemerge,nodefrommercurialimportuiasuimodfrommercurial.utilimportpropertycachefromtortoisehg.utilimporthglibfromtortoisehg.util.patchctximportpatchctx_repocache={}if'THGDEBUG'inos.environ:defdbgoutput(*args):sys.stdout.write(' '.join([str(a)forainargs])+'\n')else:defdbgoutput(*args):passdefrepository(_ui=None,path='',create=False,bundle=None):'''Returns a subclassed Mercurial repository to which new THG-specific methods have been added. The repository object is obtained using mercurial.hg.repository()'''ifbundle:if_uiisNone:_ui=uimod.ui()repo=bundlerepo.bundlerepository(_ui,path,bundle)repo._pyqtobj=ThgRepoWrapper(repo)repo.__class__=_extendrepo(repo)returnrepoifcreateorpathnotin_repocache:if_uiisNone:_ui=uimod.ui()repo=hg.repository(_ui,path,create)repo._pyqtobj=ThgRepoWrapper(repo)repo.__class__=_extendrepo(repo)_repocache[path]=reporeturnrepoifnotos.path.exists(os.path.join(path,'.hg/')):del_repocache[path]# this error must be in local encodingraiseerror.RepoError('%s is not a valid repository'%path)return_repocache[path]classThgRepoWrapper(QObject):configChanged=pyqtSignal()repositoryChanged=pyqtSignal()repositoryDestroyed=pyqtSignal()workingBranchChanged=pyqtSignal()def__init__(self,repo):QObject.__init__(self)self.repo=repoself.busycount=0repo.configChanged=self.configChangedrepo.repositoryChanged=self.repositoryChangedrepo.workingBranchChanged=self.workingBranchChangedrepo.repositoryDestroyed=self.repositoryDestroyedself.recordState()try:freq=repo.ui.config('tortoisehg','pollfreq','500')freq=max(100,int(freq))except:freq=500self._timerevent=self.startTimer(freq)deftimerEvent(self,event):ifnotos.path.exists(self.repo.path):dbgoutput('Repository destroyed',self.repo.root)self.repositoryDestroyed.emit()self.killTimer(self._timerevent)ifself.repo.rootin_repocache:del_repocache[self.repo.root]elifself.busycount==0:self.pollStatus()else:dbgoutput('no poll, busy',self.busycount)defpollStatus(self):ifnotos.path.exists(self.repo.path)orself.locked():returnifself._checkdirstate():returnself._checkrepotime()self._checkuimtime()deflocked(self):ifos.path.lexists(self.repo.join('wlock')):returnTrueifos.path.lexists(self.repo.sjoin('lock')):returnTruereturnFalsedefrecordState(self):try:self._parentnodes=self._getrawparents()self._repomtime=self._getrepomtime()self._dirstatemtime=os.path.getmtime(self.repo.join('dirstate'))self._branchmtime=os.path.getmtime(self.repo.join('branch'))self._rawbranch=self.repo.opener('branch').read()exceptEnvironmentError,ValueError:self._dirstatemtime=Noneself._branchmtime=Noneself._rawbranch=Nonedef_getrawparents(self):try:returnself.repo.opener('dirstate').read(40)exceptEnvironmentError:returnNone def _getrepomtime(self):
'Return the last modification time for the repo'
- watchedfiles = [self.repo.sjoin('00changelog.i'),
- self.repo.join('patches/series')]+ watchedfiles = [self.repo.sjoin('00changelog.i')]+ if hasattr(self.repo, 'mq'):+watchedfiles.append(self.repo.mq.join('series'))+watchedfiles.append(self.repo.join('patches/queue')) try:
mtime = [os.path.getmtime(wf) for wf in watchedfiles \
if os.path.isfile(wf)]
ifmtime:returnmax(mtime)exceptEnvironmentError:returnNonedef_checkrepotime(self):'Check for new changelog entries, or MQ status changes'ifself._repomtime<self._getrepomtime():dbgoutput('detected repository change')ifself.locked():dbgoutput('lock still held - ignoring for now')returnself.recordState()self.repo.thginvalidate()self.repositoryChanged.emit()def_checkdirstate(self):'Check for new dirstate mtime, then working parent changes'try:mtime=os.path.getmtime(self.repo.join('dirstate'))exceptEnvironmentError:returnFalseifmtime<=self._dirstatemtime:returnFalseself._dirstatemtime=mtimenodes=self._getrawparents()ifnodes!=self._parentnodes:dbgoutput('dirstate change found')ifself.locked():dbgoutput('lock still held - ignoring for now')returnTrueself.recordState()self.repo.thginvalidate()self.repositoryChanged.emit()returnTruetry:mtime=os.path.getmtime(self.repo.join('branch'))exceptEnvironmentError:returnFalseifmtime<=self._branchmtime:returnFalseself._branchmtime=mtimetry:newbranch=self.repo.opener('branch').read()exceptEnvironmentError:returnFalseifnewbranch!=self._rawbranch:dbgoutput('branch time change')ifself.locked():dbgoutput('lock still held - ignoring for now')returnTrueself._rawbranch=newbranchself.repo.thginvalidate()self.workingBranchChanged.emit()returnTruereturnFalsedef_checkuimtime(self):'Check for modified config files, or a new .hg/hgrc file'try:oldmtime,files=self.repo.uifiles()mtime=[os.path.getmtime(f)forfinfilesifos.path.isfile(f)]ifmax(mtime)>oldmtime:dbgoutput('config change detected')self.repo.invalidateui()self.configChanged.emit()except(EnvironmentError,ValueError):pass_uiprops='''_uifiles _uimtime _shell postpull tabwidth wsvisible maxdiff deadbranches _exts _thghiddentags displayname summarylen shortname mergetools bookmarks bookmarkcurrent'''.split()_thgrepoprops='''_thgmqpatchnames thgmqunappliedpatches _branchheads'''.split()def_extendrepo(repo):classthgrepository(repo.__class__):defchangectx(self,changeid):'''Extends Mercurial's standard changectx() method to a) return a thgchangectx with additional methods b) return a patchctx if changeid is the name of an MQ unapplied patch c) return a patchctx if changeid is an absolute patch path '''# Mercurial's standard changectx() (rather, lookup())# implies that tags and branch names live in the same namespace.# This code throws patch names in the same namespace, but as# applied patches have a tag that matches their patch name this# seems safe.ifchangeidinself.thgmqunappliedpatches:q=self.mq# must have mq to pass the previous ifreturngenPatchContext(self,q.join(changeid),rev=changeid)eliftype(changeid)isstrandos.path.isabs(changeid)and \
os.path.isfile(changeid):returngenPatchContext(repo,changeid)changectx=super(thgrepository,self).changectx(changeid)changectx.__class__=_extendchangectx(changectx)returnchangectx@propertycachedef_thghiddentags(self):ht=self.ui.config('tortoisehg','hidetags','')return[t.strip()fortinht.split()]@propertycachedefthgmqunappliedpatches(self):'''Returns a list of (patch name, patch path) of all self's unapplied MQ patches, in patch series order, first unapplied patch first.'''ifnothasattr(self,'mq'):return[]q=self.mqapplied=set([p.nameforpinq.applied])return[pnameforpnameinq.seriesifnotpnameinapplied]@propertycachedef_thgmqpatchnames(self):'''Returns all tag names used by MQ patches. Returns [] if MQ not in use.'''ifnothasattr(self,'mq'):return[]self.mq.parse_series()returnself.mq.series[:]@propertycachedef_shell(self):s=self.ui.config('tortoisehg','shell')ifs:returnsifsys.platform=='darwin':returnNone# Terminal.App does not support open-to-folderelifos.name=='nt':return'cmd.exe'else:return'xterm'@propertycachedef_uifiles(self):cfg=self.ui._ucfgfiles=set()forlineincfg._source.values():f=line.rsplit(':',1)[0]files.add(f)files.add(self.join('hgrc'))returnfiles@propertycachedef_uimtime(self):mtimes=[0]# zero will be taken if no config filesforfinself._uifiles:try:ifos.path.exists(f):mtimes.append(os.path.getmtime(f))exceptEnvironmentError:passreturnmax(mtimes)@propertycachedef_exts(self):lclexts=[]allexts=[nforn,minextensions.extensions()]forname,pathinself.ui.configitems('extensions'):ifnameinallexts:lclexts.append(name)returnlclexts@propertycachedefpostpull(self):pp=self.ui.config('tortoisehg','postpull')ifppin('rebase','update','fetch'):returnppreturn'none'@propertycachedeftabwidth(self):tw=self.ui.config('tortoisehg','tabwidth')try:tw=int(tw)tw=min(tw,16)returnmax(tw,2)except(ValueError,TypeError):return8@propertycachedefwsvisible(self):val=self.ui.config('tortoisehg','wsvisible')ifvalin('Visible','VisibleAfterIndent'):returnvalelse:return'Invisible'@propertycachedefmaxdiff(self):maxdiff=self.ui.config('tortoisehg','maxdiff')try:maxdiff=int(maxdiff)ifmaxdiff<1:returnsys.maxintexcept(ValueError,TypeError):maxdiff=1024# 1MB by defaultreturnmaxdiff*1024@propertycachedefsummarylen(self):slen=self.ui.config('tortoisehg','summarylen')try:slen=int(slen)ifslen<10:return80except(ValueError,TypeError):slen=80returnslen@propertycachedefdeadbranches(self):db=self.ui.config('tortoisehg','deadbranch','')return[b.strip()forbindb.split(',')]@propertycachedefdisplayname(self):'Display name is for window titles and similar'ifself.ui.config('tortoisehg','fullpath',False):name=self.rootelifself.ui.config('web','name',False):name=self.ui.config('web','name')else:name=os.path.basename(self.root)returnhglib.tounicode(name)@propertycachedefshortname(self):'Short name is for tables, tabs, and sentences'ifself.ui.config('web','name',False):name=self.ui.config('web','name')else:name=os.path.basename(self.root)returnhglib.tounicode(name)@propertycachedefmergetools(self):seen,installed=[],[]forkey,valueinself.ui.configitems('merge-tools'):t=key.split('.')[0]iftnotinseen:seen.append(t)iffilemerge._findtool(self.ui,t):installed.append(t)returninstalled@propertycachedefnamedbranches(self):allbranches=self.branchtags()openbrnodes=[]forbrinallbranches.iterkeys():openbrnodes.extend(self.branchheads(br,closed=False))dead=self.deadbranchesreturnsorted(brforbr,ninallbranches.iteritems()ifninopenbrnodesandbrnotindead)@propertycachedefbookmarks(self):if'bookmarks'inself._extsandhasattr(self,'_bookmarks'):returnself._bookmarkselse:return{}@propertycachedefbookmarkcurrent(self):if'bookmarks'inself._extsandhasattr(self,'_bookmarkcurrent'):returnself._bookmarkcurrentelse:returnNone@propertycachedef_branchheads(self):return[self.changectx(x)forxinself.branchmap()]defshell(self):'Returns terminal shell configured for this repo'returnself._shelldefuifiles(self):'Returns latest mtime and complete list of config files'returnself._uimtime,self._uifilesdefextensions(self):'Returns list of extensions enabled in this repository'returnself._extsdefthgmqtag(self,tag):'Returns true if `tag` marks an applied MQ patch'returntaginself._thgmqpatchnamesdefgetcurrentqqueue(self):'Returns the name of the current MQ queue'if'mq'notinself._exts:returnNonecur=os.path.basename(self.mq.path)ifcur.startswith('patches-'):cur=cur[8:]returncurdefthgshelves(self):self.shelfdir=sdir=self.join('shelves')ifos.path.isdir(sdir):return[os.path.join(sdir,s)forsinos.listdir(sdir)]return[]defthginvalidate(self):'Should be called when mtime of repo store/dirstate are changed'self.dirstate.invalidate()ifnotisinstance(repo,bundlerepo.bundlerepository):self.invalidate()ifhasattr(self,'mq'):self.mq.invalidate()forain_thgrepoprops+_uiprops:ifainself.__dict__:delattr(self,a)definvalidateui(self):'Should be called when mtime of ui files are changed'self.ui=uimod.ui()self.ui.readconfig(self.join('hgrc'))forain_uiprops:ifainself.__dict__:delattr(self,a)# todo: extensions.loadall(self.ui)defincrementBusyCount(self):'A GUI widget is starting a transaction'self._pyqtobj.busycount+=1defdecrementBusyCount(self):'A GUI widget has finished a transaction'self._pyqtobj.busycount-=1ifself._pyqtobj.busycount==0:self._pyqtobj.pollStatus()else:# A lot of logic will depend on invalidation happening# within the context of this call. Signals will not be# emitted till later, but we at least invalidate cached# data in the repositoryself.thginvalidate()returnthgrepositorydef_extendchangectx(changectx):classthgchangectx(changectx.__class__):defthgtags(self):'''Returns all unhidden tags for self'''htlist=self._repo._thghiddentagsreturn[tagfortaginself.tags()iftagnotinhtlist]defthgwdparent(self):'''True if self is a parent of the working directory'''returnself.rev()in[ctx.rev()forctxinself._repo.parents()]def_thgmqpatchtags(self):'''Returns the set of self's tags which are MQ patch names'''mytags=set(self.tags())patchtags=self._repo._thgmqpatchnamesresult=mytags.intersection(patchtags)assertlen(result)<=1,"thgmqpatchname: rev has more than one tag in series"returnresultdefthgmqappliedpatch(self):'''True if self is an MQ applied patch'''returnself.rev()isnotNoneandbool(self._thgmqpatchtags())defthgmqunappliedpatch(self):returnFalsedefthgmqpatchname(self):'''Return self's MQ patch name. AssertionError if self not an MQ patch'''patchtags=self._thgmqpatchtags()assertlen(patchtags)==1,"thgmqpatchname: called on non-mq patch"returnlist(patchtags)[0]defthgbranchhead(self):'''True if self is a branch head'''returnselfinself._repo._branchheadsdefchangesToParent(self,whichparent):parent=self.parents()[whichparent]returnself._repo.status(parent.node(),self.node())[:3]deflongsummary(self):summary=hglib.tounicode(self.description())ifself._repo.ui.configbool('tortoisehg','longsummary'):limit=80lines=summary.splitlines()iflines:summary=lines.pop(0)whilelen(summary)<limitandlines:summary+=u' '+lines.pop(0)summary=summary[0:limit]else:summary=''else:lines=summary.splitlines()summary=linesandlines[0]or''returnsummaryreturnthgchangectx_pctxcache={}defgenPatchContext(repo,patchpath,rev=None):global_pctxcacheholder=_pctxcache.get(patchpath,None)ifos.path.exists(patchpath):mtime=os.path.getmtime(patchpath)ifholderisnotNoneandmtime==holder[0]:returnholder[1]# create a new context objectctx=patchctx(patchpath,repo,rev=rev)_pctxcache[patchpath]=(mtime,ctx)returnctx
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.