
    q&f                     V    d dl mZ d dlmZmZ d dlmZ dZd Z	d Z
d Zdd	Zd
 Zd Zy)   )hex)utilvfs)urlutils   logexchangec              #   h  K   t        j                  | j                  j                  t                    }|j	                  |      sy ||      }d}|D ]<  }|j                         }|s|dk(  r|dz  }	 |j                  d      \  }}}|||f > |j                          y# t        $ r Y [w xY ww)z
    reads a file from .hg/logexchange/ directory and yields it's content
    filename: the file to be read
    yield a tuple (node, remotepath, name)
    N    r       )	vfsmodr   joinremotenamedirexistsstripsplit
ValueErrorclose)	repofilenamer   flinenolinenoderemoternames	            7/usr/lib/python3/dist-packages/mercurial/logexchange.pyreadremotenamefiler      s      **TXX]]=1
2C::hHAF zz|Q;aKF	"&**U"3D&%%% GGI  		s*   A1B24B#B2#	B/,B2.B//B2c              #   `   K   t        | d      D ]  }|  t        | d      D ]  }|  yw)a  
    read the details about the remotenames stored in .hg/logexchange/ and
    yields a tuple (node, remotepath, name). It does not yields information
    about whether an entry yielded is branch or bookmark. To get that
    information, call the respective functions.
    	   bookmarks   branchesN)r   )r   bmentrybranchentrys      r   readremotenamesr!   4   s?      &dL9 )$< s   ,.c                    t        j                  | j                  j                  t                    } ||dd      }|j	                  d       t        t        | |            }t        |      D ]#  \  }}}	||k7  s|j	                  d|||	fz         % t        |j                               D ]I  \  }
}|dk(  r|D ]  }|j	                  d|||
fz          *|dk(  s0|s3|j	                  d|||
fz         K |j                          y )N   wT)
atomictemps   0

s	   %s %s %s
r   r   )
r
   r   r   r   writesetr   sorteditemsr   )r   
remotepathnamesnametyper   r   olddatar   oldpathr   namens               r   writeremotenamefiler0   B   s   
**TXX]]=1
2CHdt,A GGH$T845G &w >guj GGOtWe&<<=> U[[]+ D
d{" A1j$*??@A%4T*BBCD GGI    Nc                     | j                         }	 |rt        | ||d       |rt        | ||d       |j                          y# |j                          w xY w)z
    save remotenames i.e. remotebookmarks and remotebranches in their
    respective files under ".hg/logexchange/" directory.
    r   r   N)wlockr0   release)r   r)   branches	bookmarksr3   s        r   saveremotenamesr7   Z   sI    
 JJLEj)\Jj(KHs    A Ac                    |j                         }|}|r*t        j                  |j                  j                        }n t        |t              s|j                         }| j                  j                  d      D ]\  \  }}t        j                  |      }t        j                  t        |            }t        j                  |      }||k(  s||k(  sY|} |S  |S )zreturns remote paths   paths)localr   pconvert_reporoot
isinstancebytesurluiconfigitemsr   
removeauth)r   r   r9   rpathpathr?   	noauthurls          r   
activepathrF   i   s     LLNE Efll//0&

 WW((2 
	c&&s+	 mmE#J'MM),	%<9-EL
 Lr1   c                 (   t        | |      }|j                         5 }|j                  dddi      j                         }ddd       i }| j	                         }|j                         5 }|j                  di       j                         }ddd       j                         D ]G  \  }}	g ||<   |	D ]8  }
|
|v s||
   j                         r||   j                  t        |
             : I t        | ||       y# 1 sw Y   xY w# 1 sw Y   ~xY w)z
    pulls bookmarks and branches information of the remote repo during a
    pull or clone operation.
    localrepo is our local repository
    remoterepo is the peer instance
    s   listkeyss	   namespacer   Ns	   branchmap)
rF   commandexecutorcallcommandresult
unfilteredr(   obsoleteappendr   r7   )	localrepo
remoterepor)   er6   bmapr   	branchmapbranchnodesr   s              r   pullremotenamesrU      s    Iz2J		#	#	% MMl

 &( 	 D!D		#	#	% =MM,3::<	= #* /V 	/Dt|DJ$7$7$9V##CI.	// Iz4;1 = =s   #C<*!D<DD)NN)r   r    r   r   r
   utilsr   r   r   r!   r0   r7   rF   rU    r1   r   <module>rY      s9    
 80:!<r1   