o ]LbX@sddlmZddlZddlmZddlmZmZddlm Z m Z m Z m Z m Z mZmZmZmZmZddd ZGd d d eZ dd d ZddZdddZddZddZddZddZdS))absolute_importN)_)hexshort) bookmarks branchmaperrorobsoletephasespycompatscmutil setdiscovery treediscoveryutilFc s|ds t||||S|r#|jjtfdd|Dr#|d|fStj|j||| |d}|\}}}|rG|sG|jjt fdd|D}t |||pPt |fS)aReturn a tuple (common, anyincoming, heads) used to identify the common subset of nodes between repo and remote. "common" is a list of (at least) the heads of the common subset. "anyincoming" is testable as a boolean indicating if any nodes are missing locally. If remote does not support getbundle, this actually is a list of roots of the nodes that would be incoming, to be supplied to changegroupsubset. No code except for pull should be relying on this fact any longer. "heads" is either the supplied heads, or else the remote's heads. "ancestorsof" if not None, restrict the discovery to a subset defined by these nodes. Changeset outside of this set won't be considered (but may still appear in "common"). If you pass heads and they are all known locally, the response lists just these heads in "common" and in "heads". Please use findcommonoutgoing to compute the set of outgoing nodes to give extensions a good hook into outgoing. s getbundlec3|]}|VqdSN.0h knownnoder5/usr/lib/python3/dist-packages/mercurial/discovery.py ;z%findcommonincoming..F)abortwhenunrelated ancestorsofc3|]}| VqdSrrrn)has_noderrrI) capablerfindcommonincoming changeloghasnodeallrfindcommonheadsuianylist) reporemoteheadsforcerrescommonanyincsrvheadsr)r!rrr$ s$   r$c@s@eZdZdZ d ddZddZejddZejd d Z dS) outgoingaRepresents the result of a findcommonoutgoing() call. Members: ancestorsof is a list of the nodes whose ancestors are included in the outgoing operation. missing is a list of those ancestors of ancestorsof that are present in local but not in remote. common is a set containing revs common between the local and the remote repository (at least all of those that are ancestors of ancestorsof). commonheads is the list of heads of common. excluded is the list of missing changeset that shouldn't be sent remotely. Some members are computed on demand from the heads, unless provided upfront by discovery.Nc sd||fvsJj}|dur|}|rDg}|D]}|fdd||Dq|||\}} } t|| }fdd|D}n|sJjg}||_||_||_ d|_ d|_ g|_ dS)Ncsg|] }|jkr|qSr)nullid)rp)r,rr nsz%outgoing.__init__..cg|]}|vr|qSrrr)includedrrr7u) r%r.extendparents nodesbetweensetr5 commonheadsr_revlog_common_missingexcluded) selfr,r?r missingrootscl discbasesr csetsrootsr.r)r9r,r__init__cs(  zoutgoing.__init__cCs"|j|j|j}|\|_|_dSr)r@findcommonmissingr?rrArB)rDsetsrrr_computecommonmissingszoutgoing._computecommonmissingcC|jdur ||jSr)rArMrDrrrr1 zoutgoing.commoncCrNr)rBrMrOrrrmissingrPzoutgoing.missing)NNN) __name__ __module__ __qualname____doc__rJrMr propertycacher1rQrrrrr4Ms  r4cs|t|dd}|durt||||d}|\|_}}|jjtjp!|j} | s,|p)||_ nc|durD| d|_ dd| dD|_ nK|j |j|} | \|_} g|_} g|_ } | D]}||}|tjksn|rt| |q]| |q]t| t| kr|}nt||| }||_ |r||j fdd|jD}t |||_t |jfd d|j D|_ |S) aNReturn an outgoing instance to identify the nodes present in repo but not in other. If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) are included. If you already know the local repo's heads, passing them in onlyheads is faster than letting them be recomputed here. If commoninc is given, it must be the result of a prior call to findcommonincoming(repo, other, force) to avoid recomputing it here. If portable is given, compute more conservative common and ancestorsof, to make bundles created from the instance more portable.N)r/rsservedcSsg|]}|qSrnoderctxrrrr7z&findcommonoutgoing..ssecret() or extinct()csh|]}|qSrrevr)rFrr sz%findcommonoutgoing..cr8rrr)r?rrr7r:)r4r$r? _phasecache phaserootsr secretobsstorer.rfilteredr>rCr%rKrArBphaseextinctappendlennewheadsrM ancestors)r,other onlyheadsr/ commonincportableog_any_hds mayexcluderL allmissingrQrCrXrZr missingrevsr)rFr?rfindcommonoutgoingsB        rtcsN|j}|j}|j}|j}i}t}t}|jD]}||} || || q| } | di } Wdn1sCwY|j } t | D]*\} }| |vrYqPg}g}|D]}| |rk||q_||q_|t||f|| <qP|D] } | |vrdggf|| <q}t|ddt |D}||dd|Dt |D]\} }||| ddd<qt |D]\} }|D] }|dur|q|gf|| <q|jr%|jjfdd|jD}|fd d|jDO}|jj|d d }tt |D]!\} }|\}}}}t|||}|t|d |t|df|| <q|S) acompute a summary of branch and heads status before and after push return {'branch': ([remoteheads], [newheads], [unsyncedheads], [discardedheads])} mapping - branch: the branch name, - remoteheads: the list of remote heads known locally None if the branch is new, - newheads: the new remote heads (known locally) with outgoing pushed, - unsyncedheads: the list of remote heads unknown locally, - discardedheads: the list of heads made obsolete by the push. branchmapNcss,|]\}}|ddur||dfVqdS)rNrrrbranchr.rrrrs  z _headssummary..cs|]}|VqdSrr\rYrrrr rrch|]}|qSrrrtorevrrr^r[z _headssummary..cryrrrrzrrr^r[T) inclusiver)r, unfilteredr-r4r%r>rQaddrwcommandexecutor callcommandresultr&r iteritemsrfr+rremotebranchcacheupdatesortrbr]rr?risorted_postprocessobsolete)pushopr,r-r4rFheadssum missingctxbranchesr rZe remotemaprrwr.knownunsyncedrnewmaprhitemsl futureheadsallfuturecommon remoteheads unsyncedheads placeholderrrrzr _headssummaryst           rcs`|jjtfdd|D}|d||j}tdd|D}|r&dg}ng}d|||gfiS)z;Compute branchmapsummary for repo without branchmap supportc3s|] }|r|VqdSrrrrrrr/z#_oldheadssummary..sheads(%ln + %ln)csrxrrW)rcrrrr6rN)r%r&rr>rQ)r,rr4incoldheadsrrhrrrr_oldheadssummary(src s|j}|j}|j|}|dddi}Wdn1s$wYt}fdd|j ddD}D]6}| |}|rc||vrc||||} } t || | rb| | q<||vrr||vrr| |q<|S)Nslistkeyss namespaces bookmarkscsg|]}|qSr) expandname)rblocalbookmarksrrr7Psz _nowarnheads..spushing)r,r}r- _bookmarksrrrr>r) configlistgetr validdestr~rX) rr,r-rremotebookmarksbookmarkedheads newbookmarksbmrnodelctxrctxrrr _nowarnheads?s6      rcCsB|j}|j}|j}|j}|j}t|j}||jgkrdS| dr(t |}nt ||||}||_ ddt |D}|r|sdt|} t} |D] \} } } }|r]| | qP| t|@} | rqtd| t| f}ntd| }td}tj||d t|}d}tt |D]\}} | \}}}}|durt}nt|}||d}t|}|||rd|vrd} nt||} | dur|jtd n|dur|jtd | n |jtd || f|dur t|d kr t|}|dur td|}td}nt|t|krt|||}|r|durl|dvr8tdt |d|f}n(||d!rVtdt |d||d!df}n tdt |d}|rhtd}ntd}|durz|j"tdn |j"td||D] }|j"dt |qq|rtj||d dS)zpCheck that a push won't add any outgoing head raise StateError error and display ui message as needed. NrucSs g|] \}}|ddur|qS)rNrrvrrrr7~s  zcheckheads..s, s0push creates new remote branches: %s (%d closed)s$push creates new remote branches: %ss8use 'hg push --new-branch' to create new remote branches)hints,remote has heads that are not known locally s0remote has heads that are not known locally: %s s?remote has heads on branch '%s' that are not known locally: %s rs0push creates new branch '%s' with multiple headss?merge or see 'hg help push' for details about pushing new heads)sdefaultNs.push creates new remote head %s on branch '%s'rs2push creates new remote head %s with bookmark '%s'spush creates new remote head %ssHpull and merge or see 'hg help push' for details about pushing new headssnew remote heads: s!new remote heads on branch '%s': s %s )#r,r}r-r4r newbranchboolincomingr5r#rr pushbranchmapr rjoinrr>r iterbranchesr~rrgr StateErrorrrr nodesummariesr)statusr+rrnote)rr,r-r4rrrr newbranches branchnamesclosedbranchestagr.tipisclosederrmsgr nowarnheadserrormsgrwrhrdiscardedheadsoldhsdhsnewhsrrrr checkheadsbs                  rcs|j}|jjjtjjjfddfdd}t t j |j j }t}t}t}t} |D]$} | vrH|| q<|| dur[d} |j| t| | | q sz&_postprocessobsolete..cs |vSrr)r ) futurecommonr{rrr s Ns=checkheads: remote head unknown locally has local marker: %s rsobsoletesonly(%n, (%ln+%ln))c3rrr)rr)ispublicrrrCrz'_postprocessobsolete..c3s|] }|vVqdSrrr)futurenonobsoleter{rrrDrc3rrrr) hasoutmarkerrrrEr")r,r}r%indexget_revr rr_rd functoolspartialpushingmarkerforrb successorsr>r~rr)debugrrgr getrevs frozensetpoprwrevsrfrXr*)rrcandidate_newhsr,ispushedsuccessorsmarkersr discardedlocalcandidate unknownheadsrmsgobsrevsnhrcurrent_branch branchrevs branchnodesrr)rrrrrrr{rrrsh           %rc Cs|j}|g}t|}|rB|}||rdS||d}|D]!}|d} | s,|dp+d} | D]} | |vr>|| || q.q|s dS)atrue if some markers are to be pushed for node We cannot just look in to the pushed obsmarkers from the pushop because discovery might have filtered relevant markers. In addition listing all markers relevant to all changesets in the pushed set would be too expensive (O(len(repo))) (note: There are cache opportunity in this function. but it would requires a two dimensional stack.) TrrF)rr>rrr~rf) rbrrXrstackseencurrentmarkersmnextsr rrrrRs(     r)NFN)NFNF)F) __future__rri18nrrXrrrrr r r r r rrrr$objectr4rtrrrrrrrrrrs  0 -F @ V# [