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.
# filedata.py - generate displayable file data## 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, incorporated herein by reference.importosimportrefrommercurialimporterror,match,patch,util,mdifffrommercurialimportuiasuimodfromtortoisehg.utilimporthglib,patchctxfromtortoisehg.hgqt.i18nimport_classFileData(object):def__init__(self,ctx,ctx2,wfile,status=None):self.contents=Noneself.ucontents=Noneself.error=Noneself.olddata=Noneself.diff=Noneself.flabel=u''self.elabel=u''try:self.readStatus(ctx,ctx2,wfile,status)except(EnvironmentError,error.LookupError),e:self.error=hglib.tounicode(str(e))defcheckMaxDiff(self,ctx,wfile,maxdiff=None):p=_('File or diffs not displayed: ')try:fctx=ctx.filectx(wfile)ifctx.rev()isNone:size=fctx.size()else:# fctx.size() can read all data into memory in rename cases so# we read the size directly from the filelog, this is deeper# under the API than I prefer to go, but seems necessarysize=fctx._filelog.rawsize(fctx.filerev())except(EnvironmentError,error.LookupError),e:self.error=p+hglib.tounicode(str(e))returnNoneifsize>maxdiff:self.error=p+_('File is larger than the specified max size.\n''maxdiff = %s KB')%(maxdiff//1024)returnNonetry:data=fctx.data()if'\0'indataorctx.isKbf(wfile):self.error=p+_('File is binary.\n')returnNoneexcept(EnvironmentError,util.Abort),e:self.error=p+hglib.tounicode(str(e))returnNonereturnfctx,datadefisValid(self):returnself.errorisNonedefreadStatus(self,ctx,ctx2,wfile,status):defgetstatus(repo,n1,n2,wfile):m=match.exact(repo.root,repo.getcwd(),[wfile])modified,added,removed=repo.status(n1,n2,match=m)[:3]ifwfileinmodified:return'M'ifwfileinadded:return'A'ifwfileinremoved:return'R'ifwfileinctx:return'C'returnNoneisbfile=Falserepo=ctx._repoself.flabel+=u'<b>%s</b>'%hglib.tounicode(wfile)ifisinstance(ctx,patchctx.patchctx):self.diff=ctx.thgmqpatchdata(wfile)flags=ctx.flags(wfile)ifflagsin('x','-'):lbl=_("exec mode has been <font color='red'>%s</font>")change=(flags=='x')and_('set')or_('unset')self.elabel=lbl%changeelifflags=='l':self.flabel+=_(' <i>(is a symlink)</i>')returnifctx2:# If a revision to compare to was provided, we must put it in# the context of the subrepo as wellifctx2._repo.root!=ctx._repo.root:wsub2,wfileinsub2,sctx2= \
hglib.getDeepestSubrepoContainingFile(wfile,ctx2)ifwsub2:ctx2=sctx2absfile=repo.wjoin(wfile)if(wfileinctxand'l'inctx.flags(wfile))or \
os.path.islink(absfile):ifwfileinctx:data=ctx[wfile].data()else:data=os.readlink(absfile)self.contents=dataself.flabel+=_(' <i>(is a symlink)</i>')returnifstatusisNone:status=getstatus(repo,ctx.p1().node(),ctx.node(),wfile)ifctx2isNone:ctx2=ctx.p1()ifstatus=='S':try:frommercurialimportsubrepo,commandsdefgenSubrepoRevChangedDescription(subrelpath,sfrom,sto,repo):"""Generate a subrepository revision change description"""out=[]defgetLog(_ui,srepo,opts):_ui.pushbuffer()try:commands.log(_ui,srepo,**opts)logOutput=_ui.popbuffer()excepterror.ParseError,e:# Some mercurial versions have a bug that results in# saving a subrepo node id in the .hgsubstate file# which ends with a "+" character. If that is the# case, add a warning to the output, but try to# get the revision information anywaylogOutput=''forn,revinenumerate(opts['rev']):ifrev.endswith('+'):logOutput+=_('[WARNING] Invalid subrepo ''revision ID:\n\t%s\n\n')%revopts['rev'][n]=rev[:-1]commands.log(_ui,srepo,**opts)logOutput+=_ui.popbuffer()returnlogOutputopts={'date':None,'user':None,'rev':[sfrom]}subabspath=os.path.join(repo.root,subrelpath)missingsub=notos.path.isdir(subabspath)incompletesub=Falsesfromlog=''defisinitialrevision(rev):returnall([el=='0'forelinrev])ifisinitialrevision(sfrom):sfrom=''ifisinitialrevision(sto):sto=''ifnotsfromandnotsto:sstatedesc='new'out.append(_('Subrepo created and set to initial revision.')+u'\n\n')returnout,sstatedescelifnotsfrom:sstatedesc='new'out.append(_('Subrepo initialized to revision:')+u'\n\n')elifnotsto:sstatedesc='removed'out.append(_('Subrepo removed from repository.')+u'\n\n')returnout,sstatedescelifsfrom==sto:sstatedesc='unchanged'out.append(_('Subrepo was not changed.')+u'\n\n')out.append(_('Subrepo state is:')+u'\n\n')ifmissingsub:out.append(_('changeset: %s')%sfrom+u'\n')else:out.append(hglib.tounicode(getLog(_ui,srepo,opts)))returnout,sstatedescelse:sstatedesc='changed'out.append(_('Revision has changed to:')+u'\n\n')ifmissingsub:sfromlog=_('changeset: %s')%sfrom+u'\n\n'else:sfromlog=hglib.tounicode(getLog(_ui,srepo,opts))ifnotsfromlog:incompletesub=Truesfromlog=_('changeset: %s')%sfrom+u'\n\n'sfromlog=_('From:')+u'\n'+sfromlogifmissingsub:stolog=_('changeset: %s')%sto+'\n\n'sfromlog+=_('Subrepository not found in the working ''directory.')+'\n'sfromlog+=_('Further subrepository revision ''information cannot be retrieved.')+'\n'elifincompletesub:stolog=_('changeset: %s')%sto+'\n\n'sfromlog+=_('Subrepository is either damaged or ''missing some revisions')+'\n'sfromlog+=_('Further subrepository revision ''information cannot be retrieved.')+'\n'sfromlog+=_('You may need to open the missing ''subrepository and manually\n''pull the missing revisions from its ''source repository.')+'\n'else:opts['rev']=[sto]stolog=getLog(_ui,srepo,opts)ifnotstolog:stolog=_('Initial revision')+u'\n'out.append(hglib.tounicode(stolog))ifsfromlog:out.append(hglib.tounicode(sfromlog))returnout,sstatedescsrev=ctx.substate.get(wfile,subrepo.nullstate)[1]srepo=Nonetry:subabspath=os.path.join(ctx._repo.root,wfile)ifnotos.path.isdir(subabspath):sactual=''else:sub=ctx.sub(wfile)ifisinstance(sub,subrepo.hgsubrepo):srepo=sub._reposactual=srepo['.'].hex()else:self.error=_('Not a Mercurial subrepo, not previewable')returnexcept(util.Abort),e:sactual=''out=[]_ui=uimod.ui()ifsrepoisNoneorctx.rev()isnotNone:data=[]else:_ui.pushbuffer()commands.status(_ui,srepo)data=_ui.popbuffer()ifdata:out.append(_('File Status:')+u'\n')out.append(hglib.tounicode(data))out.append(u'\n')sstatedesc='changed'ifctx.rev()isnotNone:sparent=ctx.p1().substate.get(wfile,subrepo.nullstate)[1]subrepochange,sstatedesc= \
genSubrepoRevChangedDescription(wfile,sparent,srev,ctx._repo)out+=subrepochangeelse:sstatedesc='dirty'ifsrev!=sactual:subrepochange,sstatedesc= \
genSubrepoRevChangedDescription(wfile,srev,sactual,ctx._repo)out+=subrepochangeifdata:sstatedesc+=' and dirty'elifsrevandnotsactual:sstatedesc='removed'self.ucontents=u''.join(out).strip()lbl={'changed':_('(is a changed sub-repository)'),'unchanged':_('(is an unchanged sub-repository)'),'dirty':_('(is a dirty sub-repository)'),'new':_('(is a new sub-repository)'),'removed':_('(is a removed sub-repository)'),'changed and dirty':_('(is a changed and dirty sub-repository)'),'new and dirty':_('(is a new and dirty sub-repository)'),'removed and dirty':_('(is a removed sub-repository)')}[sstatedesc]self.flabel+=' <i>'+lbl+'</i>'ifsactual:lbl=_(' <a href="subrepo:%s">open...</a>')self.flabel+=lbl%hglib.tounicode(srepo.root)except(EnvironmentError,error.RepoError,util.Abort),e:self.error=_('Error previewing subrepo: %s')% \
hglib.tounicode(str(e))return# TODO: elif check if a subdirectory (for manifest tool)maxdiff=repo.maxdiffmde=_('File or diffs not displayed: ''File is larger than the specified max size.\n''maxdiff = %s KB')%(maxdiff//1024)ifstatusin('R','!'):ifwfileinctx.p1():fctx=ctx.p1()[wfile]iffctx._filelog.rawsize(fctx.filerev())>maxdiff:self.error=mdeelse:olddata=fctx.data()if'\0'inolddata:self.error='binary file' else:
self.contents = olddata
self.flabel += _(' <i>(was deleted)</i>')
- elif ctx.p1().hasBfile(wfile):
+ elif hasattr(ctx.p1(), 'hasBfile') and ctx.p1().hasBfile(wfile):
self.error = 'binary file'
self.flabel += _(' <i>(was deleted)</i>')
else:
self.flabel+=_(' <i>(was added, now missing)</i>')returnifstatusin('I','?','C'):ifctx.rev()isNone:ifstatusin('I','?'):self.flabel+=_(' <i>(is unversioned)</i>')ifos.path.getsize(absfile)>maxdiff:self.error=mdereturnelse:data=util.posixfile(absfile,'r').read()elifctx.hasBfile(wfile):data='\0'else:data=ctx.filectx(wfile).data()if'\0'indata:self.error='binary file'else:self.contents=datareturnifstatusin('M','A'):ifctx.hasBfile(wfile):wfile=ctx.standin(wfile)isbfile=Trueres=self.checkMaxDiff(ctx,wfile,maxdiff)ifresisNone:ifstatus=='A':self.flabel+=_(' <i>(was added)</i>')returnfctx,newdata=resself.contents=newdatachange=Noneforpfctxinfctx.parents():if'x'infctx.flags()and'x'notinpfctx.flags():change=_('set')elif'x'notinfctx.flags()and'x'inpfctx.flags():change=_('unset')ifchange:lbl=_("exec mode has been <font color='red'>%s</font>")self.elabel=lbl%changeifstatus=='A':renamed=fctx.renamed()ifnotrenamed:self.flabel+=_(' <i>(was added)</i>')returnoldname,node=renamedfr=hglib.tounicode(oldname)self.flabel+=_(' <i>(renamed from %s)</i>')%frolddata=repo.filectx(oldname,fileid=node).data()elifstatus=='M':ifwfilenotinctx2:# merge situation where file was added in other branchself.flabel+=_(' <i>(was added)</i>')returnoldname=wfileolddata=ctx2[wfile].data()else:returnself.olddata=olddatanewdate=util.datestr(ctx.date())olddate=util.datestr(ctx2.date())revs=[str(ctx),str(ctx2)]diffopts=patch.diffopts(repo.ui,{})diffopts.git=Falseifisbfile:olddata+='\0'newdata+='\0'self.diff=mdiff.unidiff(olddata,olddate,newdata,newdate,oldname,wfile,revs,diffopts)
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.