File: //usr/lib/python3/dist-packages/mercurial/__pycache__/archival.cpython-310.pyc
o
�]Lb_. � @ s^ d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZddl m
Z
ddlmZ ddl
mZ ddlmZmZmZm
Z
mZmZmZ ddlmZ ejZd Zd
Zdd� Zd
gddgddgdgddgd�Zdd� Zdd� Z ddd� Z!dd� Z"G dd� de#�Z$G dd � d e#�Z%G d!d"� d"e#�Z&e&e$d#d$� d%d$� d&d$� d'd$� e%d(�Z' ) * +d.d,d-�Z(dS )/� )�absolute_importN� )�_��nullrev)�open)�error� formatter�match�pycompat�scmutil�util�vfs)�
stringutili � i � c C s� |rt �|�}n,t| t�std��tj�| �}|�� }t �
|g �D ]}|�|�r3|dt|� � } nq!tj�t �
|��}t �|�}|�d�sK|d7 }|�d�rV|dd� }|�d�setj�|�sed|v rlt�td���|S ) zWchoose prefix to use for names in archive. make sure prefix is
safe for consumers.s dest must be string if no prefixN� /s ./� s ../s /../s* archive prefix contains illegal components)r
�normpath�
isinstance�bytes�
ValueError�os�path�basename�lower�exts�get�endswith�len� localpath�pconvert�
startswith�isabsr �Abortr )�dest�kind�prefixr �sfx�lpfx� r( �4/usr/lib/python3/dist-packages/mercurial/archival.py�
tidyprefix) s(
�
r* s .tars .tbz2s .tar.bz2s .tgzs .tar.gzs .zips .txzs .tar.xz)� tar� tbz2� tgz� zip� txzc s6 t �t�D ]\}}t� fdd�|D ��r| S qd S )Nc 3 s � | ]}� � |�V qd S �N)r )�.0�ext�r# r( r) � <genexpr>P s � zguesskind.<locals>.<genexpr>)r � iteritemsr �any)r# r$ �
extensionsr( r3 r) � guesskindN s
�r8 c C s | D ]}| | S | t S r0 r )�repo�revr( r( r) �_rootctxU s r; sy
repo: {root}
node: {ifcontains(rev, revset("wdir()"), "{p1node}{dirty}", "{node}")}
branch: {branch|utf8}
{ifeq(latesttagdistance, 0, join(latesttag % "tag: {tag}", "\n"),
separate("\n",
join(latesttag % "latesttag: {tag}", "\n"),
"latesttagdistance: {latesttagdistance}",
"changessincelatesttag: {changessincelatesttag}"))}
c C s� | � � }d|j�ddt�i}t�� }t�|j|d|�}|�� |j| d� |j t
|��� d� | �� du rEd}| j
d d
�r?d}|j |d� |�� |�� S )
z!build content of .hg_archival.txts templates experimentals archivemetatemplates archive��ctx)�rootN� T)�missing� +)�dirty)r9 �ui�config�_defaultmetatemplater
�stringior � startitem�context�datar; �hexr: rB �end�getvalue)r= r9 �opts�out�fmrB r( r( r) �
buildmetadatam s"