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.
# patchctx.py - TortoiseHg patch context class## Copyright 2011 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms of the# GNU General Public License version 2 or any later version.importosimportsysimportshleximportbinasciiimportcStringIOfrommercurialimportpatch,utilfrommercurialimportnodefrommercurial.utilimportpropertycachefromhgextimportmq,recordfromtortoisehg.utilimporthglibclasspatchctx(object):_parseErrorFileName='*ParseError*'def__init__(self,patchpath,repo,pf=None,rev=None):""" Read patch context from file :param pf: currently ignored The provided handle is used to read the patch and the patchpath contains the name of the patch. The handle is NOT closed. """self._path=patchpathself._patchname=os.path.basename(patchpath)self._repo=repoself._rev=revor'patch' self._status = [[], [], []]
self._fileorder = []
self._user = ''
- self._date = '' self._desc = ''
self._branch = ''
self._node = node.nullid
self._identity=node.nullidself._mtime=Noneself._fsize=0self._parseerror=Nonetry:self._mtime=os.path.getmtime(patchpath)self._fsize=os.path.getsize(patchpath)ph=mq.patchheader(self._path)self._ph=phhash=util.sha1(self._path) hash.update(str(self._mtime))
self._identity = hash.digest()
except EnvironmentError:
+ self._date = util.makedate() return
try:
self._branch=ph.branchor''self._node=binascii.unhexlify(ph.nodeid)exceptTypeError:passexceptAttributeError:# hacks to try to deal with older versions of mq.pyself._branch=''ph.diffstartline=len(ph.comments)ifph.message:ph.diffstartline+=1self._user=ph.useror''self._date=ph.dateandutil.parsedate(ph.date)orutil.makedate()self._desc=ph.messageand'\n'.join(ph.message).strip()or''definvalidate(self):# ensure the patch contents are re-readself._mtime=0def__contains__(self,key):returnkeyinself._filesdef__str__(self):returnnode.short(self.node())defnode(self):returnself._nodedeffiles(self):returnself._files.keys()defrev(self):returnself._revdefhex(self):returnnode.hex(self.node())defuser(self):returnself._userdefdate(self):returnself._datedefdescription(self):returnself._descdefbranch(self):returnself._branchdefparents(self):return()deftags(self):return()defbookmarks(self):return()defchildren(self):return()defextra(self):return{}defp1(self):returnNonedefp2(self):returnNonedefflags(self,wfile):ifwfile==self._parseErrorFileName:return''ifwfileinself._files:forgpinpatch.readgitpatch(self._files[wfile][0].header):ifgp.mode:islink,isexec=gp.modeifislink:return'l'elifwfileinself._status[1]:# Do not report exec mode change if file is addedreturn''elifisexec:return'x'else:# techincally, this case could mean the file has had its# exec bit cleared OR its symlink state removed# TODO: change readgitpatch() to differentiatereturn'-'return''# TortoiseHg methodsdefthgtags(self):return[]defthgwdparent(self):returnFalsedefthgmqappliedpatch(self):returnFalsedefthgmqpatchname(self):returnself._patchnamedefthgbranchhead(self):returnFalsedefthgmqunappliedpatch(self):returnTruedefthgid(self):returnself._identitydeflongsummary(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 ...returnsummarydefchangesToParent(self,whichparent):'called by filelistmodel to get list of files'ifwhichparent==0andself._files:returnself._statuselse:return[],[],[]defthgmqpatchdata(self,wfile):'called by fileview to get diff data'ifwfile==self._parseErrorFileName:return'\n\n\nErrors while parsing patch:\n'+str(self._parseerror)ifwfileinself._files:buf=cStringIO.StringIO()forchunkinself._files[wfile]:chunk.write(buf)returnbuf.getvalue()return''@propertycachedef_files(self):ifnothasattr(self,'_ph')ornotself._ph.haspatch:return{}M,A,R=0,1,2defget_path(a,b):type=(a=='/dev/null')andAorMtype=(b=='/dev/null')andRortyperawpath=(b!='/dev/null')andboraifnot(rawpath.startswith('a/')orrawpath.startswith('b/')):returntype,rawpathreturntype,rawpath.split('/',1)[-1]files={}pf=open(self._path,'rb')try:try:# consume comments and headersforiinrange(self._ph.diffstartline):pf.readline()forchunkinrecord.parsepatch(pf):ifnotisinstance(chunk,record.header):continuetop=patch.parsefilename(chunk.header[-2])bot=patch.parsefilename(chunk.header[-1])type,path=get_path(top,bot)ifpathnotinchunk.files():type,path=0,chunk.files()[-1]ifpathnotinfiles:self._status[type].append(path)files[path]=[chunk]self._fileorder.append(path)files[path].extend(chunk.hunks)exceptpatch.PatchError,e:self._status[2].append(self._parseErrorFileName)files[self._parseErrorFileName]=[]self._parseerror=eif'THGDEBUG'inos.environ:printefinally:pf.close()returnfiles
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.