^c|$ddlZddlZddlZddlZddlmZddlmZmZm Z ddl m Z m Z m Z ddlmZejZejZdZdZd Zd Zd Zd Zd ZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)GddZ*e*d de( Z+e*dde( Z,e*d!de' Z-e*d"de) Z.e*d#Z/e*dZ0e*d$de' Z1e*d%de' Z2e*d&Z3e*d'Z4e*dZ5e*d(Z6e*d)Z7e*d*d+Z8e*d,d+Z9e*d-d+Z:e*d.de) Z;e*d/de' ZGd2d3e>Z?Gd4d5e>Z@d6ZAdS)7N)_)binhexnullrev)error filemergeutil)hashutilc|d}|dd|ddz}d|S)N)splitjoin)databitss 6/usr/lib/python3/dist-packages/mercurial/mergestate.py _droponoders? ::e  D 9tBCCy D ::d  c||jjkrtj||S||SN)repo nodeconstantsnullhexr absentfilectx)hexnodectxfs r_filectxorabsentr s7#((***222&sA...1v rLOlfFCPurspusprotRdmDsaddedsremovedsmodifiedcteZdZdZejZejZd dZdZ dZ dZ dZ d Z dS) MergeActiona#represent an "action" merge need to take for a given file Attributes: _short: internal representation used to identify each action no_op: True if the action does affect the file content or tracking status narrow_safe: True if the action can be safely used for a file outside of the narrow set changes: The types of changes that this actions involves. This is a work in progress and not all actions have one yet. In addition, some requires user changes and cannot be fully decided. The value currently available are: - ADDED: the files is new in both parents - REMOVED: the files existed in one parent and is getting removed - MODIFIED: the files existed in at least one parent and is getting changed FNc||_|j|||_|jr|j|||_||_dSr)_short ALL_ACTIONSaddno_op NO_OP_ACTIONS narrow_safechanges)selfshortr6r8r9s r__init__zMergeAction.__init__s[  T""" : )   " "4 ( ( (& rc*t|jSr)hashr3r:s r__hash__zMergeAction.__hash__sDK   rc<d|jdzS)NzMergeAction<%s>ascii)r3decoder?s r__repr__zMergeAction.__repr__s 4;#5#5g#>#>>>rc|jSrr3r?s r __bytes__zMergeAction.__bytes__s {rcX|dSt|tsJ|j|jkSNF) isinstancer1r3r:others r__eq__zMergeAction.__eq__s1 =5%-----{el**rc"|j|jkSrrFrKs r__lt__zMergeAction.__lt__s{U\))r)FFN)__name__ __module__ __qualname____doc__weakrefWeakSetr4r7r<r@rDrGrMrOrrr1r1fs."'/##K#GO%%M!!!???+++ *****rr1T)r8r9agpsamcsdcscdsdgsdmk)r6skasknescmc.eZdZdZdZdZddZejdZ ejdZ ejdZ ejd Z d Z d Zed Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dS)_mergestate_baseatrack 3-way merge state of individual files The merge state is stored on disk when needed. Two files are used: one with an old format (version 1), and one with a new format (version 2). Version 2 stores a superset of the data in version 1, including new kinds of records in the future. For more about the new format, see the documentation for `_readrecordsv2`. Each record can contain arbitrary content, and has an associated type. This `type` should be a letter. If `type` is uppercase, the record is mandatory: versions of Mercurial that don't support it should abort. If `type` is lowercase, the record can be safely ignored. Currently known records: L: the node of the "local" part of the merge (hexified version) O: the node of the "other" part of the merge (hexified version) F: a file to be merged entry C: a change/delete or delete/change conflict P: a path conflict (file vs directory) f: a (filename, dictionary) tuple of optional values for a given file l: the labels for the parts of the merge. Merge record states (stored in self._state, indexed by filename): u: unresolved conflict r: resolved conflict pu: unresolved path conflict (file conflicts with directory) pr: resolved path conflict o: file was merged in favor of other parent of merge (DEPRECATED) The resolve command transitions between 'u' and 'r' for conflicts and 'pu' and 'pr' for path conflicts. c||_i|_tjt|_d|_d|_d|_i|_ d|_ dS)z^Initialize the merge state. Do not use this directly! Instead call read() or clean().NF) _repo_state collections defaultdictdict _stateextras_local_other_labels_results_dirty)r:rs rr<z_mergestate_base.__init__sN  '3D99     rcdSrrVr?s rresetz_mergestate_base.resets rNc0||_||_||_dSr)rfrgrh)r:noderLlabelss rstartz_mergestate_base.starts   rcJ|jd}tj||jS)Ns(local accessed but self._local isn't set)rfrProgrammingErrorr:msgs rlocalz_mergestate_base.local( ; =C(-- -{rc&|j|jSr)r`rur?s rlocalctxz_mergestate_base.localctxz$*%%rcJ|jd}tj||jS)Ns(other accessed but self._other isn't set)rgrrrrss rrLz_mergestate_base.other rvrc&|j|jSr)r`rLr?s rotherctxz_mergestate_base.otherctxryrcRt|jpt|jS)zWhether mergestate is active. Returns True if there appears to be mergestate. This is a rough proxy for "is a merge in progress." )boolrfrar?s ractivez_mergestate_base.actives# DK  5D$5$55rcdS)z*Write current state on disk (if necessary)NrVr?s rcommitz_mergestate_base.commitsrchttj|S)zUhash the path of a local file context for storage in the .hg/merge directory.)rr sha1digest)paths r getlocalkeyz_mergestate_base.getlocalkey"s( 8=&&--//000rctrNotImplementedErrorr:fctxlocalkeys r _make_backupz_mergestate_base._make_backup)!###rctrrr:rrflagss r_restore_backupz _mergestate_base._restore_backup,rrc ||r|jjj}nBt|}|||t|||t| |t| | g|j |<t| |j|d<d|_dS)a/add a new (potentially?) conflicting file the merge state fcl: file context for local, fco: file context for remote, fca: file context for ancestors, fd: file path of the resulting merge. note: also write the local version to the `.hg/merge` directory. ancestorlinknodeTN)isabsentr`rr mergestaterrrMERGE_RECORD_UNRESOLVEDrfilenoderrarnrerj)r:fclfcofcafdrs rr5z_mergestate_base.add/s <<>> -z/7HH!--chhjj99H   c8 , , , #  HHJJ HHJJ     HHJJ     IIKK   B69__"12 rc8t||g|j|<d|_dS)zadd a new conflicting path to the merge state path: the path that conflicts frename: the filename the conflicting file was renamed to forigin: origin of the file ('l' or 'r' for local/remote) TN)MERGE_RECORD_UNRESOLVED_PATHrarj)r:rfrenameforigins raddpathconflictz _mergestate_base.addpathconflictJs" :7GL D rcT|j||d|_dS)zHstores information which is required at commit into _stateextrasTN)reupdaterj)r:rrs r addcommitinfoz_mergestate_base.addcommitinfoSs+ $&&t,,, rc||jvSrrar:dfiles r __contains__z_mergestate_base.__contains__Ys ##rc(|j|dS)Nrrrs r __getitem__z_mergestate_base.__getitem__\s{5!!$$rcDtt|jSr)itersortedrar?s r__iter__z_mergestate_base.__iter___sF4;''(((rc4|jSr)rakeysr?s rfilesz_mergestate_base.filesbs{!!!rc4||j|d<d|_dS)NrT)rarj)r:rstates rmarkz_mergestate_base.markes % E1 rc#|K|jD]\}}|dttfvr|V dS)z%Obtain the paths of unresolved files.rN)raitemsrr)r:rentrys r unresolvedz_mergestate_base.unresolvedis[ ))++  HAuQx',   rc|jS)z8return all extras information stored with the mergestaterer?s r allextrasz_mergestate_base.allextrasss   rc|j|S)z?return extras stored with the mergestate for the given filenamer)r:filenames rextrasz_mergestate_base.extrasws **rc :||ttfvrdS|j|}|\}}}}}} } } |j|j} ||} | d}|r|j|}nd}t|||}t| | | }|j|||}| }| }d| |z|zvred| |z|zvr[| tkr6| |kr0|jj td|zn| |kr|} ||jjjkr||||| n||d ||s|j|=d |j|<d|_dSt-j|j||j|||||j \}}|s||td}|r$|rt6}nPt8}nH|rt:}n,|r||jvrt>}nt@}||f|j|<|S) zHrun merge process for dfile Returns the exit code of the merge.rrN)fileid changectxxr#sQwarning: cannot merge flags for %s without common ancestor - keeping local flags T) ignoremissing)NN)ro)!MERGE_RECORD_RESOLVEDLEGACY_RECORD_DRIVER_RESOLVEDrar`rgrgetr filectxrrevruiwarnrrrrremovecmprirjr rfrhrr ACTION_FORGET ACTION_REMOVE ACTION_GETrxACTION_ADD_MODIFIED ACTION_ADD)r:rwctx stateentryrrlfileafileanodeofileonoderoctxr anccommitnodeactxfcdrrflofla merge_retdeletedactions rresolvez_mergestate_base.resolve{s ; ! )   1[' DNAxueUEz$+&U## #677  :m,DDDxu55udE22j  u EEiikkiikk 53;$ $ $US[35F)F)FwwyyG##  ""K # tz/7 7 7  eh > > > > K  T  2 2 2wws||  E"#-DM% DK4&0 J  K    <     7 4 IIe2 3 3 3  (||~~ '''||~~ (# (DM))0FF'F(&0 ercd\}}}|jD])\}}||dz } |dkr|tkr|dz }$|dz }*|||fS)zKreturn counts for updated, merged and removed files in this session)rrrNrr)rivaluesr)r:updatedmergedremovedrrs rcountsz_mergestate_base.countssw$+ --//  IAvy1 a]**qLGGaKF''rc^tt|S)z0get unresolved count for this merge (persistent))lenlistrr?s runresolvedcountz _mergestate_base.unresolvedcounts"4))**+++rc tgtgtgtgtgi}|jD](\}\}}||||ddf)|S)z2return lists of actions to perform on the dirstateNs merge result)rrrrrrirappend)r:actionsrrrs rrz_mergestate_base.actionssx 2 2     #m1133 C CNA{6!&&4'ABBBrr)"rPrQrRrSr<rlrpr propertycacherurxrLr|rr staticmethodrrrr5rrrrrrrrrrrrrrrVrrr^r^s   D$       &&&   &&&66699911\1 $$$$$$6 $$$%%%)))"""!!!+++SSSj ( ( (,,,     rr^ceZdZdZdZedZedZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdS)rs merge/states merge/state2cLt|}||S)zPInitialize a brand new merge state, removing any existing state on disk.)rrlrmss rcleanzmergestate.cleans#     rcLt|}||S)z1Initialize the merge state, reading it from disk.)r_readrs rreadzmergestate.reads#     rct}|}|D]\}}|tkrt||_&|t krt||_F|tkrR|tttttfvrV| d}|dtkrd|j|dd<|dd|j|d<|t"kr}| dd\}}| d}i} d} | t%|kr,|| dz| || <| dz } | t%|k,| |j|<R|t&kr)| dd} d| D|_|s|||rt/j|dS) zAnalyse each record content to restore a serialized state from disk This function process "record" entry produced by the de-serialization of on disk file. r rsotherrsfilenode-sourceNc8g|]}t|dk|S)r)r).0ls r z$mergestate._read../s#@@@aSVVaZZZZZr)set _readrecords RECORD_LOCALrrf RECORD_OTHERrgLEGACY_MERGE_DRIVER_STATE RECORD_MERGEDRECORD_CHANGEDELETE_CONFLICTRECORD_PATH_CONFLICTLEGACY_MERGE_DRIVER_MERGELEGACY_RECORD_RESOLVED_OTHERrMERGE_RECORD_MERGED_OTHERreraRECORD_FILE_VALUESr RECORD_LABELSrhislowerr5rUnsupportedMergeRecords) r: unsupportedrecordsrtyperecordrr rawextras extrapartsriros rrzmergestate._reads ee ##%%$$ '$ 'ME6 $$!&kk ,&&!&kk 333,$), ||E**7777EMD%d1g./ABB+/8DKQ((,,,&,ll5!&<&<#)&__U33 #j//)),6q1u,=F:a=)FA#j//))/5!(++-''eQ//@@6@@@ ]]__ '&&&  =/ << < = =rc|}|}|||r|S|jdd}|t |ft|D]g\}}|dtkrQ|d d}| dd|dd |f||<h|S)aRead merge state from disk and return a list of record (TYPE, data) We read data from both v1 and v2 files and decide which one to use. V1 has been used by version prior to 2.9.1 and contains less data than v2. We read both versions and check if no data in v2 contradicts v1. If there is not contradiction we can safely assume that both v1 and v2 were written at the same time and use the extract data in v2. If there is contradiction we ignore v2 content as we assume an old version of Mercurial has overwritten the mergestate file and left an old v2 file around. returns list of record [(TYPE, data), ...]Nrrrr rr) _readrecordsv1_readrecordsv2 _v1v2matchr`parentsrrr enumeraterrinsertr)r: v1records v2recordsmctxidxrrs rrzmergestate._readrecords6s'')) '')) ??9i 0 0   :d#++--b1D   lDHHJJ7 8 8 8$I.. > >QQ4=((Q4::e,,DKKC(((&'dEJJt,<,<%=IcN rct}|D]i}|dtkr||)|dtkr/|tt |dfj|D] }||vrdS dS)NrrFT)rrr5rr)r:rr oldv2recs rrzmergestate._v1v2matchXs ? ?C1v%% #Q=(( =*SV*<*<=>>>  C%uu 4rc\g} |j|j}t|D]T\}}|dkr%|t |ddf0|t |ddfU|n#t$rYnwxYw|S)zread on disk merge state for version 1 file returns list of record [(TYPE, data), ...] Note: the "F" data from this file are one entry short (no "other file node" entry) rNr) r`vfs statepathv1rrrrcloseFileNotFoundError)r:rrrrs rrzmergestate._readrecordsv1fs  t/00A!!  < <166NNL!CRC ::::NNM1SbS6#:;;;; GGIIII     D sBB B)(B)cg} |j|j}|}d}t |}||kr|||dz}|dz }t d|||dzd}|dz }||||z}||z }|t kr|dd|dd}}|||f||k|n#t$rYnwxYw|S)aread on disk merge state for version 2 file This format is a list of arbitrary records of the form: [type][length][content] `type` is a single character, `length` is a 4 byte integer, and `content` is an arbitrary byte sequence of length `length`. Mercurial versions prior to 3.7 have a bug where if there are unsupported mandatory merge records, attempting to clear out the merge state with hg update --clean or similar aborts. The 't' record type works around that by writing out what those versions treat as an advisory record, but later versions interpret as special: the first character is the 'real' record type and everything onwards is the data. Returns list of records [(TYPE, data), ...].rrs>IN) r`r' statepathv2rr_unpackRECORD_OVERRIDErr)r*) r:rrroffendrlengthrs rrzmergestate._readrecordsv2{s&$  t/00A6688DCd))C))S37]+q SC!G_(=>>qAqcS6\23v O++$*1Q3K6Ev///)) GGIIII     D sC$C)) C65C6cx|jr2|}||d|_dSdSrI)rj _makerecords _writerecordsr:rs rrzmergestate.commitsF ; ''))G   w ' ' 'DKKK  rcDg}|tt|jf|tt|jf|jD]\}}|dttfvr4|td |g|zfO|d|j j jks|d|j j jkr4|td |g|zf|t d |g|zft#|jD]W\}}d d|D}|t&d||fzfX|j6d |j}|t*|f|S)Nrr rc3*K|]\}}d||fzVdS)%s%sNrV)rkvs r z*mergestate._makerecords..s@##'+q! QF"######rr:)rrrrfrrgrarrMERGE_RECORD_RESOLVED_PATHr rr`rrrrrrer rhr)r:rrr<rrros rr4zmergestate._makerecordss  c$+&6&67888 c$+&6&67888  ;,,.. L LKHat,* )5::xj1n+E+EF! 0888Q44:3;;; 15::xj1n3M3MN  uzz8*q./I/IJKKKK &t'8'>'>'@'@ A A   Hf ##/5||~~###I NN#Y(I1F%FG     < #ZZ --F NNM62 3 3 3rcZ||||dS)z,Write current state on disk (both v1 and v2)N)_writerecordsv1_writerecordsv2r6s rr5zmergestate._writerecordss0 W%%% W%%%%%rc|j|jd}t|}t |}|dt ksJ|t|jdz|D]5\}}|tkr%|dt|z6| dS)z/Write current state on disk in a version 1 filewbr s%s N) r`r'r(rnextrwriterrfrrr))r:rrirecordslrecordsrrs rr@zmergestate._writerecordsv1s JNN4+U 3 3==>>{l**** DK  5()))# 4 4KE4 %%*T"2"22333  rc |tttf}|j|jd}|D]p\}}t |dksJ||vrtd||fz}}dt |z}|t||t ||q| dS)zqWrite current state on disk in a version 2 file See the docstring for _readrecordsv2 for why we use 't'.rCrs%s%ss>sI%isN) rrrr`r'r-rr/rF_packr))r:r allowlistrkeyrformats rrAzmergestate._writerecordsv2s "<? JNN4+U 3 3  9 9ICs88q====)##+WT{-BTT*F GGE&#s4yy$77 8 8 8 8  rcp|jjd|z|dSNsmerge/)r`r'rFrrs rrzmergestate._make_backups/ Y1499;;?????rc|jd|z5}|||ddddS#1swxYwYdSrO)r`r'rFr)r:rrrrs rrzmergestate._restore_backups Z^^I0 1 1 (Q JJqvvxx ' ' ' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s)AAAcjtj|jjdddS)NsmergeT)shutilrmtreer`r'rr?s rrlzmergestate.resets, djn))(33T:::::rN)rPrQrRr(r-rrrrrrrrrr4r5r@rArrrlrVrrrrs K!K\\ /=/=/=b   D   *%%%N   +++Z&&&      @@@(((;;;;;rrc*eZdZfdZdZdZxZS) memmergestatecftt||i|_dSr)superrUr<_backups)r:r __class__s rr<zmemmergestate.__init__s, mT""++D111 rc>||j|<dSr)rrXrs rrzmemmergestate._make_backups"&))++ hrcH||j||dSr)rFrXrs rrzmemmergestate._restore_backups# 4=*E22222r)rPrQrRr<rr __classcell__)rYs@rrUrUsV...3333333rrUc |tgD]C\}}}|r|j|dd&|j|ddD|tgD]#\}}}|j|dd$|t gD]\}}}|\}}|j|dd|j||||kr|j|ddg|j|dd|tgD]#\}}}|j|dd$|tgD]D\}}}|r|j|ddd'|j|ddE|tgD]$\}}}|j|ddd%|tgD]\}}}|tgD]\}}}|tgD]\}}}|tgD]z\}}}|rH|j|} | jo| j } |j|| ddP|r||nd} |j|dd| {|t"gD]\}}}|\} } }}}|r| |k} |j|| dd| | kr\|r|j| dd| |kr|j| |{|j| || |kr|j|ddd|r|j| dd|t$gD]\}}}|\}}|rV|j|dd|j|dd|j||c|j|dd|j|dd|t&gD]c\}}}|\}}|r9|j|dd|j||F|j|ddddS)z$record merge actions to the dirstateTF) p1_tracked wc_tracked)r^r_possibly_dirty)r^r_p2_infoN)r^r_parentfiledata)rrdirstate update_filerACTION_PATH_CONFLICT_RESOLVEcopyrr ACTION_EXEC ACTION_KEEPACTION_KEEP_ABSENTACTION_KEEP_NEWr get_entry any_trackedadded ACTION_MERGEACTION_DIR_RENAME_MOVE_LOCALACTION_LOCAL_DIR_RENAME_GET)rr branchmerge getfiledatarargsrtf0origf0 old_entryr^rbf1f2famoveancflags r recordupdatesr} s{ M266MM 4  M M % %aDU % K K K K M % %aEe % L L L L M266II 4 !!!%!HHHH $@"EENN 4 V !!!$!GGG 61%%% << M % %bTe % L L L L M % %bUu % M M M M J33HH 4 !!!$!GGGG $7<<LL 4  L M % %dtD &     M % %aEd % K K K K K44  4 !! $4 "     K44  4  $6;;  4  OR88  4  J33 4   //22I".Fy3FJ M % %% &    0;D[^^N M % %- &     L"55"" 4 $BD#  qJ M % %% &    RxxM--t.77M&&r1----M&&r1---Qww ))$4*  ))5U*  $@"EENN 4D  N M % %aEd % K K K M % %bTe % L L L M  r1 % % % % M % %aDT % J J J M % %bUu % M M M M $?DDKK 4D  K M % %aEd % K K K M  r1 % % % % M % %aDT % J J J J KKr)BrbrRstructrTi18nrrnrrrrr r utilsr packrJunpackr.rr rrrr rrr rrrr>r r/r rrr  CHANGE_ADDEDCHANGE_REMOVEDCHANGE_MODIFIEDr1rrrrACTION_PATH_CONFLICTrerACTION_CREATEDACTION_DELETED_CHANGEDACTION_CHANGED_DELETEDrnrprorhrirjrgACTION_CREATED_MERGECONVERT_MERGE_ACTIONSr^rrUr}rVrrrs     -    # $" !  $ $   4*4*4*4*4*4*4*4*n DdNKKK  DdNKKK [4 F F F [4 I I I "{4((*{511!k t\Tt\JJJ$U++$U++{4  )k%00*{511k$d+++ ![d333+e4000k$D/JJJ "{ t\  jjjjjjjjZ L;L;L;L;L;!L;L;L;^ 3 3 3 3 3$ 3 3 3BKBKBKBKBKr