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.
# 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.importosimportsysimportshutilimporttempfilefromPyQt4.QtCoreimport*frommercurialimporthg,util,error,bundlerepo,extensions,filemerge,nodefrommercurialimportmerge,subrepofrommercurialimportuiasuimodfrommercurial.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.__class__=_extendrepo(repo)repo._pyqtobj=ThgRepoWrapper(repo)returnrepoifcreateorpathnotin_repocache:if_uiisNone:_ui=uimod.ui()try:repo=hg.repository(_ui,path,create)repo.__class__=_extendrepo(repo)repo._pyqtobj=ThgRepoWrapper(repo)_repocache[path]=reporeturnrepoexceptEnvironmentError:raiseerror.RepoError('Cannot open repository at %s'%path)ifnotos.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()workingDirectoryChanged=pyqtSignal()workingBranchChanged=pyqtSignal()def__init__(self,repo):QObject.__init__(self)self.repo=repoself.busycount=0repo.configChanged=self.configChangedrepo.repositoryChanged=self.repositoryChangedrepo.repositoryDestroyed=self.repositoryDestroyedrepo.workingDirectoryChanged=self.workingDirectoryChangedrepo.workingBranchChanged=self.workingBranchChangedself.recordState()ifisinstance(repo,bundlerepo.bundlerepository):dbgoutput('not watching F/S events for bundle repository')else:self.watcher=QFileSystemWatcher(self)self.watcher.addPath(repo.path)self.watcher.directoryChanged.connect(self.onDirChange)self.watcher.fileChanged.connect(self.onFileChange)self.addMissingPaths()@pyqtSlot(QString)defonDirChange(self,directory):'Catch any writes to .hg/ folder, most importantly lock files'self.pollStatus()self.addMissingPaths()@pyqtSlot(QString)defonFileChange(self,file):'Catch writes or deletions of files we are interested in'self.pollStatus()self.addMissingPaths()defaddMissingPaths(self):'Add files to watcher that may have been added or replaced'existing=[fforfinself._getwatchedfiles()ifos.path.isfile(f)]files=[unicode(f)forfinself.watcher.files()]forfinexisting:ifhglib.tounicode(f)notinfiles:dbgoutput('add file to watcher:',f)self.watcher.addPath(f)_,files=self.repo.uifiles()forfinfiles:iffandos.path.exists(f)andhglib.tounicode(f)notinfiles:dbgoutput('add ui file to watcher:',f)self.watcher.addPath(f)defpollStatus(self):ifnotos.path.exists(self.repo.path):dbgoutput('Repository destroyed',self.repo.root)self.repositoryDestroyed.emit()# disable watcher by removing all watched pathsdirs=self.watcher.directories()ifdirs:self.watcher.removePaths(dirs)files=self.watcher.files()iffiles:self.watcher.removePaths(files)ifself.repo.rootin_repocache:del_repocache[self.repo.root]returnifself.locked():dbgoutput('locked, aborting')returnifself._checkdirstate():dbgoutput('dirstate changed, exiting')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:returnNonedef_getwatchedfiles(self):watchedfiles=[self.repo.sjoin('00changelog.i')]watchedfiles.append(self.repo.join('localtags'))watchedfiles.append(self.repo.join('bookmarks'))watchedfiles.append(self.repo.join('bookmarks.current'))ifhasattr(self.repo,'mq'):watchedfiles.append(self.repo.mq.join('series'))watchedfiles.append(self.repo.mq.join('guards'))watchedfiles.append(self.repo.join('patches.queue'))returnwatchedfilesdef_getrepomtime(self):'Return the last modification time for the repo'try:existing=[fforfinself._getwatchedfiles()ifos.path.isfile(f)]mtime=[os.path.getmtime(wf)forwfinexisting]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 postpull tabwidth maxdiff deadbranches _exts _thghiddentags displayname summarylen shortname mergetools namedbranches'''.split()# _bookmarkcurrent is a Mercurial property, we include it here to work# around a bug in hg-1.8. It should be removed when we drop support for# Mercurial 1.8_thgrepoprops='''_thgmqpatchnames thgmqunappliedpatches _branchheads _bookmarkcurrent'''.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)isstrand'\0'notinchangeidand \
os.path.isabs(changeid)andos.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.parseseries()returnself.mq.series[:]@propertydefthgactivemqname(self):'''Currenty-active qqueue name (see hgext/mq.py:qqueue)'''ifnothasattr(self,'mq'):returnn=os.path.basename(self.mq.path)ifn.startswith('patches-'):returnn[8:]else:returnn@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'):ifname.startswith('hgext.'):name=name[6:]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@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.configbool('tortoisehg','fullpath'):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)@propertycachedef_branchheads(self):heads=[]forbranchname,nodesinself.branchmap().iteritems():heads.extend(nodes)returnheadsdefuifiles(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') if os.path.isdir(sdir):
def getModificationTime(x):
return os.path.getmtime(os.path.join(sdir, x))
-return sorted(os.listdir(sdir),
+shelves = sorted(os.listdir(sdir),
key=getModificationTime, reverse=True)
+ return [s for s in shelves if \+ os.path.isfile(os.path.join(self.shelfdir, s))] return []
def thginvalidate(self):
'Should be called when mtime of repo store/dirstate are changed'self.dirstate.invalidate()ifnotisinstance(repo,bundlerepo.bundlerepository):self.invalidate()# mq.queue.invalidate does not handle queue changes, so force# the queue object to be rebuiltif'mq'inself.__dict__:delattr(self,'mq')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)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()defthgbackup(self,path):'Make a backup of the given file in the repository "trashcan"'# The backup name will be the same as the orginal file plus '.bak'trashcan=self.join('Trashcan')ifnotos.path.isdir(trashcan):os.mkdir(trashcan)ifnotos.path.exists(path):returnname=os.path.basename(path)root,ext=os.path.splitext(name)dest=tempfile.mktemp(ext+'.bak',root+'_',trashcan)shutil.copyfile(path,dest)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):returnFalsedefthgid(self):returnself._nodedefthgmqpatchname(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'''returnself.node()inself._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''ifsummaryandlen(lines)>1:summary+=u' \u2026'# ellipsis ...returnsummaryreturnthgchangectx_pctxcache={}defgenPatchContext(repo,patchpath,rev=None):global_pctxcachetry:ifos.path.exists(patchpath)andpatchpathin_pctxcache:cachedctx=_pctxcache[patchpath]ifcachedctx._mtime==os.path.getmtime(patchpath)and \
cachedctx._fsize==os.path.getsize(patchpath):returncachedctxexceptEnvironmentError:pass# create a new context objectctx=patchctx(patchpath,repo,rev=rev)_pctxcache[patchpath]=ctxreturnctxdefrecursiveMergeStatus(repo):ms=merge.mergestate(repo)forwfileinms:yieldrepo.root,wfile,ms[wfile]try:wctx=repo[None]forsinwctx.substate:sub=wctx.sub(s)ifisinstance(sub,subrepo.hgsubrepo):forroot,file,statusinrecursiveMergeStatus(sub._repo):yieldroot,file,statusexcept(EnvironmentError,error.Abort,error.RepoError):passdefrelatedRepositories(repoid):'Yields root paths for local related repositories'fromtortoisehg.hgqtimportreporegistry,repotreemodelf=QFile(reporegistry.settingsfilename())f.open(QIODevice.ReadOnly)try:foreinrepotreemodel.iterRepoItemFromXml(f):ife.basenode()==repoid:yielde.rootpath(),e.shortname()except:f.close()raiseelse:f.close()
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.