test: fix test-evolve.t
Metaedit take the current date when no date is given. When we added default-
date, the date ended up to be the same and the behavior changed. Fix the text
by disabling default-date in the metaedit call and update the comment about
what is needed to fix correctly the test; take the changeset date when
metaediting only one changeset.
from__future__importabsolute_importimportweakreffrommercurial.i18nimport_frommercurialimport(branchmap,bundle2,discovery,error,exchange,extensions,wireproto,)from.importtopicmapdef_headssummary(orig,repo,remote,outgoing):publishing=('phases'notinremote.listkeys('namespaces')orbool(remote.listkeys('phases').get('publishing',False)))ifpublishingornotremote.capable('topics'):returnorig(repo,remote,outgoing)oldrepo=repo.__class__oldbranchcache=branchmap.branchcacheoldfilename=branchmap._filenametry:classrepocls(repo.__class__):def__getitem__(self,key):ctx=super(repocls,self).__getitem__(key)oldbranch=ctx.branchdefbranch():branch=oldbranch()topic=ctx.topic()iftopic:branch="%s:%s"%(branch,topic)returnbranchctx.branch=branchreturnctxrepo.__class__=repoclsbranchmap.branchcache=topicmap.topiccachebranchmap._filename=topicmap._filenamesummary=orig(repo,remote,outgoing)forkey,valueinsummary.iteritems():if':'inkey:# This is a topicifvalue[0]isNoneandvalue[1]:summary[key]=([value[1].pop(0)],)+value[1:]returnsummaryfinally:repo.__class__=oldrepobranchmap.branchcache=oldbranchcachebranchmap._filename=oldfilenamedefwireprotobranchmap(orig,repo,proto):oldrepo=repo.__class__try:classrepocls(repo.__class__):defbranchmap(self):usetopic=notself.publishing()returnsuper(repocls,self).branchmap(topic=usetopic)repo.__class__=repoclsreturnorig(repo,proto)finally:repo.__class__=oldrepo# Discovery have deficiency around phases, branch can get new heads with pure# phases change. This happened with a changeset was allowed to be pushed# because it had a topic, but it later become public and create a new branch# head.## Handle this by doing an extra check for new head creation server sidedef_nbheads(repo):data={}forbinrepo.branchmap().iterbranches():if':'inb[0]:continuedata[b[0]]=len(b[1])returndatadefhandlecheckheads(orig,op,inpart):orig(op,inpart)ifop.repo.publishing():returntr=op.gettransaction()iftr.hookargs['source']notin('push','serve'):# not a pushreturntr._prepushheads=_nbheads(op.repo)reporef=weakref.ref(op.repo)oldvalidator=tr.validatordefvalidator(tr):repo=reporef()ifrepoisnotNone:repo.invalidatecaches()finalheads=_nbheads(repo)forbranch,oldnbintr._prepushheads.iteritems():newnb=finalheads.pop(branch,0)ifoldnb<newnb:msg=_('push create a new head on branch "%s"'%branch)raiseerror.Abort(msg)forbranch,newnbinfinalheads.iteritems():if1<newnb:msg=_('push create more than 1 head on new branch "%s"'%branch)raiseerror.Abort(msg)returnoldvalidator(tr)tr.validator=validatorhandlecheckheads.params=frozenset()def_pushb2phases(orig,pushop,bundler):hascheck=any(p.type=='check:heads'forpinbundler._parts)ifpushop.outdatedphasesandnothascheck:exchange._pushb2ctxcheckheads(pushop,bundler)returnorig(pushop,bundler)defwireprotocaps(orig,repo,proto):caps=orig(repo,proto)ifrepo.peer().capable('topics'):caps.append('topics')returncapsdefmodsetup(ui):"""run at uisetup time to install all destinations wrapping"""extensions.wrapfunction(discovery,'_headssummary',_headssummary)extensions.wrapfunction(wireproto,'branchmap',wireprotobranchmap)extensions.wrapfunction(wireproto,'_capabilities',wireprotocaps)extensions.wrapfunction(bundle2,'handlecheckheads',handlecheckheads)# we need a proper wrap b2 part stuffbundle2.handlecheckheads.params=frozenset()bundle2.parthandlermapping['check:heads']=bundle2.handlecheckheadsextensions.wrapfunction(exchange,'_pushb2phases',_pushb2phases)exchange.b2partsgenmapping['phase']=exchange._pushb2phases