
    6h                    R   S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
JrJrJr  0 r\R                  " \5      rSr\" SSSS	\" S
5      4SSS	\" S5      4SSS	\" S5      4/\" S5      \R"                  SS9 SS j5       r\" S/ S\R&                  S9S 5       rS rS rS rS rS rS rg	)aU
  share a common history between several working directories

The share extension introduces a new command :hg:`share` to create a new
working directory. This is similar to :hg:`clone`, but doesn't involve
copying or linking the storage of the repository. This allows working on
different branches or changes in parallel without the associated cost in
terms of disk space.

Note: destructive operations or extensions like :hg:`rollback` should be
used with care as they can result in confusing problems.

Automatic Pooled Storage for Clones
-----------------------------------

When this extension is active, :hg:`clone` can be configured to
automatically share/pool storage across multiple clones. This
mode effectively converts :hg:`clone` to :hg:`clone` + :hg:`share`.
The benefit of using this mode is the automatic management of
store paths and intelligent pooling of related repositories.

The following ``share.`` config options influence this feature:

``share.pool``
    Filesystem path where shared repository data will be stored. When
    defined, :hg:`clone` will automatically use shared repository
    storage instead of creating a store inside each clone.

``share.poolnaming``
    How directory names in ``share.pool`` are constructed.

    "identity" means the name is derived from the first changeset in the
    repository. In this mode, different remotes share storage if their
    root/initial changeset is identical. In this mode, the local shared
    repository is an aggregate of all encountered remote repositories.

    "remote" means the name is derived from the source repository's
    path or URL. In this mode, storage is only shared if the path or URL
    requested in the :hg:`clone` command matches exactly to a repository
    that was cloned before.

    The default naming mode is "identity".

.. container:: verbose

    Sharing requirements and configs of source repository with shares:

    By default creating a shared repository only enables sharing a common
    history and does not share requirements and configs between them. This
    may lead to problems in some cases, for example when you upgrade the
    storage format from one repository but does not set related configs
    in the shares.

    Setting `format.exp-share-safe = True` enables sharing configs and
    requirements. This only applies to shares which are done after enabling
    the config option.

    For enabling this in existing shares, enable the config option and reshare.

    For resharing existing shares, make sure your working directory is clean
    and there are no untracked files, delete that share and create a new share.
    )annotations)_)	bookmarkscommandserror
extensionshg	registrartxnutilutils   ships-with-hg-core   share   Us   noupdateNs!   do not create a working directory   B	   bookmarkss   also share bookmarks    s   relatives%   point to source using a relative paths   [-U] [-B] SOURCE [DEST]T)helpcategorynorepoc           	     @    [         R                  " U UUU(       + UUS9  g)a  create a new shared repository

Initialize a new repository and working directory that shares its
history (and optionally bookmarks) with another repository.

.. note::

   using rollback or extensions that destroy/modify history (mq,
   rebase, etc.) can cause considerable confusion with shared
   clones. In particular, if two shared clones are both updated to
   the same changeset, and one of them destroys that changeset
   with rollback, the other clone will suddenly stop working: all
   operations will fail with "abort: working directory has unknown
   parent". The only known workaround is to use debugsetparents on
   the broken clone to reset it to a changeset that still exists.
)destupdater   relativer   )r	   share)uisourcer   noupdater   r   s         -/usr/lib/python3/dist-packages/hgext/share.pyr   r   [   s*    H HH
| r   s   unshare)r   c                    UR                  5       (       d  [        R                  " [        S5      5      e[        R
                  " X5        g)zmconvert a shared repository to a normal one

Copy the store data to the repo and remove the sharedpath data.
s   this is not a shared repoN)sharedr   Abortr   r	   unshare)r   repos     r   r    r       s0     ;;==kk!89::JJrr   c                    UR                  SS5      nU(       a  [        R                  " U5      nUUR                  SS5      S.US'   U " X/UQ70 UD6$ )Nr      pools
   poolnaming)r#   s   mode	shareopts)configr   
expandpath)origr   r   argsoptspools         r   cloner+      sY    99Xw'Dt$ 8]3D
 *T*T**r   c                @   [         R                  " [        S[        5        [         R                  " [        R                  S[
        5        [         R                  " [        R                  S[        5        [         R                  " [        R                  S[        5        g )N
_getbkfile_recordchange
_writerepos   clone)r   wrapfunctionr   	getbkfilebmstorerecordchange	writerepowrapcommandr   tabler+   )r   s    r   extsetupr7      sZ    I|Y?I--MI--|YG8>>8U;r   c                    [         R                  " U 5      (       a  g U R                  R                  S5      R	                  5       n[        R                  U;   $ ! [
         a     gf = f)z.Returns whether this repo has shared bookmarksFs   shared)r   bookmarksinstorevfsread
splitlinesFileNotFoundErrorr	   sharedbookmarks)r!   r   s     r   _hassharedbookmarksr?      s_    !!$'' y)446 ''  s   )A 
A'&A'c                   [        U5      (       ac  [        R                  " U5      nUbJ   [        R                  " UR
                  UR                  S5      u  p4U(       a  U$ UR                  5         UnU " U5      $ ! [         a     Nf = f)Nr   )	r?   r	   sharedreposourcer   
trypendingrootr:   closer=   )r'   r!   srcrepofppendings        r   r1   r1      s    4  %%d+
%00IItxx  I
 D
 : % s   6A< "A< <
B	B	c                   ^^ U " TU5        [        TR                  5      (       a>  [        R                  " TR                  5      mTb  SnUR	                  UUU4S j5        g g g )Ns   share-bookmarksc                &   > TR                  T5      $ N)r/   )trselfrE   s    r   <lambda>recordchange.<locals>.<lambda>   s    1Ir   )r?   _repor	   rA   addpostclose)r'   rL   rK   categoryrE   s    `  @r   r3   r3      sS    rN4::&&%%djj1)HOOH&IJ  'r   c                    U " X5        [        UR                  5      (       a-  [        R                  " UR                  5      nUb	  U " X5        g g g rJ   )r?   rO   r	   rA   )r'   rL   r!   rE   s       r   r4   r4      sE    4::&&%%djj1  'r   )NFFF)__doc__
__future__r   mercurial.i18nr   	mercurialr   r   r   r   r	   r
   r   r   cmdtablecommand
testedwithCATEGORY_REPO_CREATIONr   CATEGORY_MAINTENANCEr    r+   r7   r?   r1   r3   r4    r   r   <module>r]      s   <| # 	 	 	 


H
%
 #
 		{D!$H"IJ	|T1%<#=>67		
	  !//" FK! > 	R7+G+GH	 I	
+<
(:K r   