typos: fix typos in several locations
A user at Google attempted to fix our local copy because they had noticed a
typo (accross instead of across), but this will just get overwritten on our
next import. This commit fixes that case and a few others that my editor found.
Most of the typos were in comments, but user-visible output is changed in a few
cases:
- accross -> across
- splitted -> split
- ambigious -> ambiguous
- evolvestte -> evolvestate (this is in a ui.debug, so not often seen)
There is another typo that I wanted to fix, but didn't: 'supercede' is spelled
'superseed' in a few locations. I believe this is only internal to the
extension, instead of being user-visible, so while it could probably be fixed
easily, I wasn't 100% sure it didn't end up in a file on disk or something and
might cause problems, so I left it alone.
# stack.py - code related to stack workflow## This software may be used and distributed according to the terms of the# GNU General Public License version 2 or any later version.frommercurial.i18nimport_frommercurialimport(destutil,context,error,node,phases,obsolete,util,)from.evolvebitsimportbuilddependencies,_singlesuccessorshort=node.short# TODO: compatifnotutil.safehasattr(context.basectx,'orphan'):context.basectx.orphan=context.basectx.unstableifnotutil.safehasattr(context.basectx,'isunstable'):context.basectx.isunstable=context.basectx.troubleddef_stackcandidates(repo):"""build the smaller set of revs that might be part of a stack. The intend is to build something more efficient than what revsets do in this area. """phasecache=repo._phasecacheifnotphasecache._phasesets:returnrepo.revs('(not public()) - obsolete()')ifany(sisNoneforsinphasecache._phasesets):returnrepo.revs('(not public()) - obsolete()')result=set()forsinphasecache._phasesets[phases.draft:]:result|=sresult-=obsolete.getrevs(repo,'obsolete')returnresultclassstack(object):"""object represent a stack and common logic associated to it."""def__init__(self,repo,branch=None,topic=None):self._repo=repoself.branch=branchself.topic=topicself.behinderror=Nonesubset=_stackcandidates(repo)iftopicisnotNoneandbranchisnotNone:raiseerror.ProgrammingError('both branch and topic specified (not defined yet)')eliftopicisnotNone:trevs=repo.revs("%ld and topic(%s)",subset,topic)elifbranchisnotNone:trevs=repo.revs("%ld and branch(%s) - topic()",subset,branch)else:raiseerror.ProgrammingError('neither branch and topic specified (not defined yet)')self._revs=trevsdef__iter__(self):returniter(self.revs)def__getitem__(self,index):returnself.revs[index]defindex(self,item):returnself.revs.index(item)@util.propertycachedef_dependencies(self):deps,rdeps=builddependencies(self._repo,self._revs)repo=self._reposrcpfunc=repo.changelog.parentrevs### post process to skip over possible gaps in the stack## For example in the following situation, we need to detect that "t3"# indirectly depends on t2.## o t3# |# o other# |# o t2# |# o t1pmap={}defpfuncrev(repo,rev):"""a special "parent func" that also consider successors"""parents=pmap.get(rev)ifparentsisNone:parents=[repo[_singlesuccessor(repo,repo[p])].rev()forpinsrcpfunc(rev)if0<=p]pmap[rev]=parentsreturnparentsrevs=self._revsstackrevs=set(self._revs)forrootin[rforrinrevsifnotdeps[r]]:seen=set()stack=[root]whilestack:current=stack.pop()forpinpfuncrev(repo,current):ifpinseen:continueseen.add(p)ifpinstackrevs:rdeps[p].add(root)deps[root].add(p)elifphases.public<repo[p].phase():# traverse only if we did not found a proper candidatestack.append(p)returndeps,rdeps@util.propertycachedefrevs(self):# some duplication/change from _orderrevs because we use a post# processed dependency graph.# Step 1: compute relation of revision with each otherdependencies,rdependencies=self._dependenciesdependencies=dependencies.copy()rdependencies=rdependencies.copy()# Step 2: Build the ordering# Remove the revisions with no dependency(A) and add them to the ordering.# Removing these revisions leads to new revisions with no dependency (the# one depending on A) that we can remove from the dependency graph and add# to the ordering. We progress in a similar fashion until the ordering is# builtsolvablerevs=[rforrinsorted(dependencies.keys())ifnotdependencies[r]]revs=[]whilesolvablerevs:rev=solvablerevs.pop()fordependentinrdependencies[rev]:dependencies[dependent].remove(rev)ifnotdependencies[dependent]:solvablerevs.append(dependent)deldependencies[rev]revs.append(rev)revs.extend(sorted(dependencies))# step 3: add t0ifrevs:pt1=self._repo[revs[0]].p1()else:pt1=self._repo['.']ifpt1.obsolete():pt1=self._repo[_singlesuccessor(self._repo,pt1)]revs.insert(0,pt1.rev())returnrevs@util.propertycachedefchangesetcount(self):returnlen(self._revs)@util.propertycachedeftroubledcount(self):returnlen([rforrinself._revsifself._repo[r].isunstable()])@util.propertycachedefheads(self):revs=self.revs[1:]deps,rdeps=self._dependenciesreturn[rforrinrevsifnotrdeps[r]]@util.propertycachedefbehindcount(self):revs=self.revs[1:]deps,rdeps=self._dependenciesifrevs:minroot=[min(rforrinrevsifnotdeps[r])]try:dest=destutil.destmerge(self._repo,action='rebase',sourceset=minroot,onheadcheck=False)returnlen(self._repo.revs("only(%d, %ld)",dest,minroot))excepterror.NoMergeDestAbort:return0excepterror.ManyMergeDestAbortasexc:# XXX we should make it easier for upstream to provide the informationself.behinderror=str(exc).split('-',1)[0].rstrip()return-1return0@util.propertycachedefbranches(self):branches=sorted(set(self._repo[r].branch()forrinself._revs))ifnotbranches:branches=set([self._repo[None].branch()])returnbranchesdeflabelsgen(prefix,labelssuffix):""" Takes a label prefix and a list of suffixes. Returns a string of the prefix formatted with each suffix separated with a space. """return' '.join(prefix%suffixforsuffixinlabelssuffix)defshowstack(ui,repo,branch=None,topic=None,opts=None):ifoptsisNone:opts={}iftopicisnotNoneandbranchisnotNone:msg='both branch and topic specified [%s]{%s}(not defined yet)'msg%=(branch,topic)raiseerror.ProgrammingError(msg)eliftopicisnotNone:prefix='t'iftopicnotinrepo.topics:raiseerror.Abort(_('cannot resolve "%s": no such topic found')%topic)elifbranchisnotNone:prefix='b'else:raiseerror.ProgrammingError('neither branch and topic specified (not defined yet)')fm=ui.formatter('topicstack',opts)prev=Noneentries=[]idxmap={}label='topic'iftopic==repo.currenttopic:label='topic.active'data=stackdata(repo,branch=branch,topic=topic)empty=Falseifdata['changesetcount']==0:empty=TrueiftopicisnotNone:fm.plain(_('### topic: %s')%ui.label(topic,label),label='topic.stack.summary.topic')if1<data['headcount']:fm.plain(' (')fm.plain('%d heads'%data['headcount'],label='topic.stack.summary.headcount.multiple')fm.plain(')')fm.plain('\n')fm.plain(_('### target: %s (branch)')%'+'.join(data['branches']),# XXX handle multi brancheslabel='topic.stack.summary.branches')iftopicisNone:if1<data['headcount']:fm.plain(' (')fm.plain('%d heads'%data['headcount'],label='topic.stack.summary.headcount.multiple')fm.plain(')')else:ifdata['behindcount']==-1:fm.plain(', ')fm.plain('ambiguous rebase destination - %s'%data['behinderror'],label='topic.stack.summary.behinderror')elifdata['behindcount']:fm.plain(', ')fm.plain('%d behind'%data['behindcount'],label='topic.stack.summary.behindcount')fm.plain('\n')ifempty:fm.plain(_("(stack is empty)\n"))foridx,rinenumerate(stack(repo,branch=branch,topic=topic),0):ctx=repo[r]# special case for t0, b0 as it's hard to plugin into rest of the logicifidx==0:# t0, b0 can be Noneifr==-1:continueentries.append((idx,False,ctx))prev=ctx.rev()continuep1=ctx.p1()p2=ctx.p2()ifp1.obsolete():p1=repo[_singlesuccessor(repo,p1)]ifp2.node()!=node.nullid:entries.append((idxmap.get(p1.rev()),False,p1))entries.append((idxmap.get(p2.rev()),False,p2))elifp1.rev()!=prevandp1.node()!=node.nullid:entries.append((idxmap.get(p1.rev()),False,p1))entries.append((idx,True,ctx))idxmap[ctx.rev()]=idxprev=r# super crude initial versionforidx,isentry,ctxinentries[::-1]:symbol=Nonestates=[]iscurrentrevision=repo.revs('%d and parents()',ctx.rev())ifiscurrentrevision:states.append('current')symbol='@'ifctx.orphan():symbol='$'states.append('unstable')ifnotisentry:symbol='^'# "base" is kind of a "ghost" entrystates.append('base')# none of the above if statments get executedifnotsymbol:symbol=':'states.append('clean')states.sort()fm.startitem()fm.data(isentry=isentry)ifidxisNone:fm.plain(' ')ifui.verbose:fm.plain(' ')else:fm.write('topic.stack.index','%s%%d'%prefix,idx,label='topic.stack.index '+labelsgen('topic.stack.index.%s',states))ifui.verbose:fm.write('topic.stack.shortnode','(%s)',short(ctx.node()),label='topic.stack.shortnode '+labelsgen('topic.stack.shortnode.%s',states))fm.write('topic.stack.state.symbol','%s',symbol,label='topic.stack.state '+labelsgen('topic.stack.state.%s',states))fm.plain(' ')fm.write('topic.stack.desc','%s',ctx.description().splitlines()[0],label='topic.stack.desc '+labelsgen('topic.stack.desc.%s',states))fm.condwrite(states!=['clean']andidxisnotNone,'topic.stack.state',' (%s)',fm.formatlist(states,'topic.stack.state'),label='topic.stack.state '+labelsgen('topic.stack.state.%s',states))fm.plain('\n')fm.end()defstackdata(repo,branch=None,topic=None):"""get various data about a stack :changesetcount: number of non-obsolete changesets in the stack :troubledcount: number on troubled changesets :headcount: number of heads on the topic :behindcount: number of changeset on rebase destination """data={}current=stack(repo,branch,topic)data['changesetcount']=current.changesetcountdata['troubledcount']=current.troubledcountdata['headcount']=len(current.heads)data['behindcount']=current.behindcountdata['behinderror']=current.behinderrordata['branches']=current.branchesreturndata