HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/builtins.cpython-39.pyc
a

���_�o�@s>dZddlmZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZe�e�d�ddl
mZmZmZdd	lmZmZmZmZmZdd
lmZmZddlmZmZmZmZddlm Z m!Z!m"Z"m#Z#m$Z$d�d
d�Z%d�dd�Z&d�dd�Z'd�dd�Z(d�dd�Z)d�dd�Z*dd�Z+dd�Z,d�dd�Z-dd �Z.d!d"�Z/Gd#d$�d$e�Z0Gd%d&�d&e�Z1Gd'd(�d(e�Z2Gd)d*�d*e�Z3Gd+d,�d,e�Z4Gd-d.�d.e�Z5Gd/d0�d0e�Z6Gd1d2�d2e�Z7Gd3d4�d4e�Z8Gd5d6�d6e�Z9Gd7d8�d8e�Z:Gd9d:�d:e�Z;Gd;d<�d<e�Z<Gd=d>�d>e�Z=Gd?d@�d@e�Z>GdAdB�dBe�Z?GdCdD�dDe�Z@GdEdF�dFe�ZAGdGdH�dHe�ZBGdIdJ�dJe�ZCGdKdL�dLe�ZDGdMdN�dNe�ZEGdOdP�dPe�ZFGdQdR�dRe�ZGGdSdT�dTe�ZHGdUdV�dVe�ZIGdWdX�dXe�ZJGdYdZ�dZe�ZKGd[d\�d\e�ZLGd]d^�d^e�ZMGd_d`�d`e�ZNGdadb�dbe�ZOdcdd�ZPdedf�ZQGdgdh�dhe�ZRdidj�ZSdkdl�ZTd�dodp�ZUGdqdr�dre�ZVGdsdt�dte�ZWGdudv�dve�ZXGdwdx�dxe�ZYGdydz�dze�ZZGd{d|�d|e�Z[Gd}d~�d~e�Z\Gdd��d�e�Z]Gd�d��d�e�Z^Gd�d��d�e�Z_Gd�d��d�e�Z`Gd�d��d�e�ZaGd�d��d�e�ZbGd�d��d�e�ZcGd�d��d�e�ZdGd�d��d�e�ZeGd�d��d�e�ZfGd�d��d�e�ZgGd�d��d�e�ZhGd�d��d�e�ZiGd�d��d�e�ZjGd�d��d�e�ZkGd�d��d�e�ZlGd�d��d�e�ZmGd�d��d�e�ZnGd�d��d�e�ZoGd�d��d�e�ZpGd�d��d�e�ZqGd�d��d�e�ZrGd�d��d�e�ZsGd�d��d�e�ZtGd�d��d�e�ZuGd�d��d�e�ZvGd�d��d�e�ZwGd�d��d�e�ZxGd�d��d�e�ZyGd�d��d�e�ZzGd�d��d�e�Z{Gd�d��d�e�Z|Gd�d��d�e�Z}Gd�d„d�e�Z~Gd�dĄd�e~�ZGd�dƄd�e�Z�Gd�dȄd�e�Z�Gd�dʄd�e�Z�Gd�d̄d�e�Z�Gd�d΄d�e�Z�Gd�dЄd�e�Z�Gd�d҄d�e�Z�Gd�dԄd�e�Z�Gd�dքd�e�Z�Gd�d؄d�e�Z�Gd�dڄd�e�Z�Gd�d܄d�e�Z�Gd�dބd�e�Z�Gd�d�d�e�Z�Gd�d�d�e�Z�Gd�d�d�e�Z�Gd�d�d�e�Z�Gd�d�d�e�Z�d�d�Z�dS)�zbuiltin brz commands�)�absolute_importN�)�errors)�lazy_importa�
import time

import breezy
from breezy import (
    branch as _mod_branch,
    bugtracker,
    cache_utf8,
    controldir,
    directory_service,
    delta,
    config as _mod_config,
    globbing,
    gpg,
    hooks,
    lazy_regex,
    log,
    merge as _mod_merge,
    mergeable as _mod_mergeable,
    merge_directive,
    osutils,
    reconfigure,
    rename_map,
    revision as _mod_revision,
    symbol_versioning,
    timestamp,
    transport,
    tree as _mod_tree,
    ui,
    urlutils,
    views,
    )
from breezy.branch import Branch
from breezy.conflicts import ConflictList
from breezy.transport import memory
from breezy.smtp_connection import SMTPConnection
from breezy.workingtree import WorkingTree
from breezy.i18n import gettext, ngettext
)�Command�builtin_command_registry�display_command)�
ListOption�Option�RegistryOption�custom_help�_parse_revision_str)�RevisionSpec�RevisionInfo)�PY3�	text_type�	viewitems�
viewvalues)�mutter�note�warning�is_quiet�get_verbosity_levelcCs\z|��}Wntjy(|jjYS0|dur6|S|j|d�}|��}|durV|S|jS)z/Return location of branch for this control dir.N��possible_transports)�get_branch_referencer�NotBranchError�root_transport�base�open_branch�get_bound_location)�control_dirr�targetZthis_branchZmaster_location�r#�1/usr/lib/python3/dist-packages/breezy/builtins.py�_get_branch_locationbs�r%c	Cs�t||d�}ztjj||d�}Wntjy<d|fYS0z|��Wn"tjtjfyld|fYS0|j	j
o�|j|jk|fSdS)z�Check if the branch in control_dir is colocated.

    :param control_dir: Control directory
    :return: Tuple with boolean indicating whether the branch is colocated
        and the full URL to the actual branch
    rFN)r%�
controldir�
ControlDir�openrr�open_workingtree�
NoWorkingTree�NotLocalUrl�_formatZcolocated_branches�control_url)r!r�this_url�rootr#r#r$�
_is_colocatedts"��

�r0cCs\tj�|�}d|vrXd|vrXt||�\}}|rDt�|dt�|�i�St�|dt�|��S|S)z�Lookup the location for a new sibling branch.

    :param control_dir: Control directory to find sibling branches from
    :param location: Name of the new branch
    :return: Full location to the new branch
    �/�\�branch�..)Zdirectory_serviceZdirectoriesZdereferencer0�urlutilsZjoin_segment_parameters�escape�join)r!�locationrZ	colocatedr.r#r#r$�lookup_new_sibling_branch�s�r9cCsRz|j||d�WStjtjfyLt|�}t�t�|dt�	|���YS0dS)z�Open a branch, possibly a sibling of another.

    :param control_dir: Control directory relative to which to lookup the
        location.
    :param location: Location to look up
    :return: branch to open
    rr4N)
rrrZNoColocatedBranchSupportr%�Branchr(r5r7r6)r!r8rr.r#r#r$�open_sibling_branch�s���r;cCs\|dur>|durd}ztj||d�WStjy<d}Yn0tjj||d�}t|||d�S)z�Open a nearby branch.

    :param near: Optional location of container from which to open branch
    :param location: Location of the branch
    :return: Branch instance
    N�.r)r:r(rrr&r'r;)�nearr8r�cdirr#r#r$�open_nearby_branch�s�
��r?ccs�z|��}Wntjy$d}Yn0|dur\ztj||d�}Wq`tjyXd}Yq`0nd}|dusn|jr�|dur||j}t|���D]\}}||fVq�n<|j�	�}|j
dd�D]$}t�|j
|j
��d�}||fVq�dS)z�Iterate over the siblings of a branch.

    :param control_dir: Control directory for which to look up the siblings
    :return: Iterator over tuples with branch name and branch object
    NrT)�usingr1)rrrr:r(�namer&rZget_branchesZfind_repository�
find_branchesr5�relative_url�user_url�rstrip)r!r�	referenceZ
ref_branchrAr3�repor#r#r$�iter_sibling_branches�s2
�

��rHcCs�|rjt�|d�\}}|��rN|j��}|rN|D]}t�||�s0t�||��q0|dd�}|�|�|d<n@t�d�d}|��r�|j��}|r�|}t�	|�}t
td�|�||fS)a#
    Return a tree and list of absolute paths from a file list.

    Similar to tree_files, but add handles files a bit differently, so it a
    custom implementation.  In particular, MutableTreeTree.smart_add expects
    absolute paths, which it immediately converts to relative paths.
    rNr<�'Ignoring files outside view. View is %s)�WorkingTree�open_containing�supports_views�views�lookup_view�osutilsZ
is_inside_any�FileOutsideView�abspath�view_display_strr�gettext)�	file_list�tree�relpath�
view_files�filename�view_strr#r#r$�tree_files_for_add�s(


�rZcCs4|durdSt|�dkr,t�td�|f��|dS)Nrz7brz %s --revision takes exactly one revision identifierr)�lenr�BzrCommandErrorrS)�command_name�	revisionsr#r#r$�_get_one_revisions���r_cCsJ|dur|j}|dur2|dur(|��}qF|��}nt||�}|�|�}|S)atGet a revision tree. Not suitable for commands that change the tree.

    Specifically, the basis tree in dirstate trees is coupled to the dirstate
    and doing a commit/uncommit/pull will at best fail due to changing the
    basis revision data.

    If tree is passed in, it should be already locked, for lifetime management
    of the trees internal cached state.
    N)r3�
basis_treer_�as_tree)r]r^r3rU�rev_tree�revisionr#r#r$�_get_one_revision_trees




rdcCsFd}z(|j��d}|dur*||j��f}Wntjy@Yn0|S)z:Get the view information from a tree for change reporting.Nr)rM�
get_view_inforNZViewsNotSupported)rU�	view_info�current_viewr#r#r$�"_get_view_info_for_change_reporter,srhcCs$|durdt�|�|fStj�|�S)zOpen the tree or branch containing the specified file, unless
    the --directory option is used to specify a different branch.N)r:r(r&r'�open_containing_tree_or_branch)rX�	directoryr#r#r$�,_open_directory_or_containing_tree_or_branch8srkc@speZdZdZdgZddddeddd	d
�eddd
d
�eddd�eddd�gZddgZdZgd�Z	e
ddd��ZdS)�
cmd_statusa9Display status summary.

    This reports on versioned and unknown files, reporting them
    grouped by state.  Possible states are:

    added
        Versioned in the working copy but not in the previous revision.

    removed
        Versioned in the previous revision but removed or deleted
        in the working copy.

    renamed
        Path of this file changed from the previous revision;
        the text may also have changed.  This includes files whose
        parent directory was renamed.

    modified
        Text has changed since the previous revision.

    kind changed
        File kind has been changed (e.g. from file to directory).

    unknown
        Not versioned and not matching an ignore pattern.

    Additionally for directories, symlinks and files with a changed
    executable bit, Breezy indicates their type using a trailing
    character: '/', '@' or '*' respectively. These decorations can be
    disabled using the '--no-classify' option.

    To see ignored files use 'brz ignored'.  For details on the
    changes to file texts, use 'brz diff'.

    Note that --short or -S gives status flags for each item, similar
    to Subversion's status command. To get output similar to svn -q,
    use brz status -SV.

    If no arguments are specified, the status of the entire working
    directory is shown.  Otherwise, only the status of the specified
    files or directories is reported.  If a directory is given, status
    is reported for everything inside that directory.

    Before merges are committed, the pending merge tip revisions are
    shown. To see all pending merge revisions, use the -v option.
    To skip the display of pending merge information altogether, use
    the no-pending option or specify a file/directory.

    To compare the working directory to a specific revision, pass a
    single revision to the revision argument.

    To see which files have changed in a specific revision, or between
    two revisions, pass a revision range to the revision argument.
    This will produce the same results as calling 'brz diff --summarize'.
    �file*�show-idsrc�change�verbose�shortzUse short status indicators.�S��help�
short_name�	versionedzOnly show versioned files.�Vz
no-pendingzDon't show pending merges.�rtzno-classifyz(Do not mark object type using indicator.�st�stat�replace)�diff�revert�status-flagsFNc	Cs�ddlm}	|r*t|�dkr*t�td���t�|�\}
}|dgkrVd}|dgkrbd}n|durbd}|	|
||||j|||||d�
dS)	Nr)�show_tree_status�zBbrz status --revision takes exactly one or two revision specifiers�r<T)	�show_ids�specific_filesrc�to_filerqrvZshow_pendingrpZclassify)	�statusrr[rr\rSrJ�open_containing_paths�outf)�selfr�rTrcrqrvZ
no_pendingrpZno_classifyrrUZrelfile_listr#r#r$�run�s$�

�zcmd_status.run)FNNFFFFF)�__name__�
__module__�__qualname__�__doc__�
takes_argsr
�
takes_options�aliases�
encoding_type�	_see_alsorr�r#r#r#r$rlFs,:��
��	�rlc@s<eZdZdZdZdgZddgZdZdd�Ze	d
dd��Z
d	S)�cmd_cat_revisionz�Write out metadata for a revision.

    The revision to print can either be specified by a specific
    revision identifier, or you can use --revision.
    Tzrevision_id?rjrc�strictcCsP|�|fgdd�}t|�}|jdkr0t�||��|�d�}|j�|�d��dS)NZ	unorderedTZabsentZfulltext�utf-8)	Zget_record_stream�nextZstorage_kindr�NoSuchRevisionZget_bytes_asr��write�decode)r�r^�revid�stream�recordZrevtextr#r#r$�print_revision�s

zcmd_cat_revision.print_revisionNr<c	
CsF|dur|durt�td���|dur<|dur<t�td���tj�|�d}t|jdd�}|durvt�td�|j��|j����|dur�t	�
|�}z|�||�Wn8tjy�td��
|jj|�d��}t�|��Yn0nB|du�r"|D]2}|du�r
t�td���|�|�}|�||�q�Wd�n1�s80YdS)	N�4You can only supply one of revision_id or --revision�2You must supply either --revision or a revision_idrr^z;Repository %r does not support access to raw revision textsz,The repository {0} contains no revision {1}.r�z#You cannot specify a NULL revision.)rr\rSr&r'ri�getattr�
repository�	lock_read�
cache_utf8�encoder�r��formatrr��as_revision_id)	r��revision_idrcrj�br^�msg�rev�rev_idr#r#r$r��sD���
��

�
zcmd_cat_revision.run)NNr<)r�r�r�r��hiddenr�r��encodingr�rr�r#r#r#r$r��sr�c@s6eZdZdZddgZdgZeddd�gZdd	d
�ZdS)
�cmd_remove_treez�Remove the working tree from a given branch/checkout.

    Since a lightweight checkout is little more than a working tree
    this will refuse to run against one.

    To re-create the working tree, use "brz checkout".
    �checkout�
working-treesz	location*�forcezFRemove the working tree even if it has uncommitted or shelved changes.rxFc	Cs�|s
dg}|D]�}tj�|�}z|��}WnBtjyLt�td���Yn"tjylt�td���Yn0|s�|�	�r�t�
|��|����dur�t�
|��|j|jjkr�t�td���|��qdS)Nr<zNo working tree to removez3You cannot remove the working tree of a remote pathz>You cannot remove the working tree from a lightweight checkout)r&r'r(r)rr*r\rSr+�has_changes�UncommittedChanges�get_shelf_managerZ
last_shelfZShelvedChangesrDr3Zdestroy_workingtree)r�Z
location_listr�r8�dZworkingr#r#r$r��s0��


�zcmd_remove_tree.runN)F�	r�r�r�r�r�r�r
r�r�r#r#r#r$r��s��r�c@s0eZdZdZddeddd�gZdZd
dd�ZdS)�cmd_repair_workingtreea�Reset the working tree state file.

    This is not meant to be used normally, but more as a way to recover from
    filesystem corruption, etc. This rebuilds the working inventory back to a
    'known good' state. Any new modifications (adding a file, renaming, etc)
    will be lost, though modified files will still be detected as such.

    Most users will want something more like "brz revert" or "brz update"
    unless the state file has become corrupted.

    By default this attempts to recover the current state by looking at the
    headers of the state file. If the state file is too corrupted to even do
    that, you can supply --revision to force the state of the tree.
    rcrjr�z9Reset the tree even if it doesn't appear to be corrupted.rxTNr<Fcs�t�|�\�}|�����|sPz���Wntjy@Yn0t�td���|dur^d}n�fdd�|D�}z��	|�Wn>tjy�|dur�td�}nd}t�td��
|���Yn0dS)Nz�The tree does not appear to be corrupt. You probably want "brz revert" instead. Use "--force" if you are sure you want to reset the working tree.csg|]}|��j��qSr#)r�r3)�.0�r�rUr#r$�
<listcomp>=�z.cmd_repair_workingtree.run.<locals>.<listcomp>zS, the header appears corrupt, try passing -r -1 to set the state to the last commitr�z!failed to reset the tree state{0})rJrK�
enter_context�lock_tree_writeZcheck_staterZBzrErrorr\rSZreset_stater�)r�rcrjr��_�revision_idsZextrar#r�r$r�,s,�
�zcmd_repair_workingtree.run)Nr<F)r�r�r�r�r
r�r�r�r#r#r#r$r�s��r�c@s:eZdZdZdgZdgZeddd�dgZed
dd��Z	d
S)�	cmd_revnoz`Show current revision number.

    This is equal to the number of revisions on this branch.
    �info�	location?rU�Show revno of working tree.rxrcFr<Nc		Cs$|dur|rt�td���|rtz t�|�d}|�|���Wn$tjtjfybt�|��Yn0|j	}|�
�}nRt�|�d}|�|���|r�t|�dkr�t�td���|d�
|�}n|�
�}z|�|�}Wntjtjfy�d}Yn0d�dd�|D��}|��|j�|d	�dS)
Nz.--tree and --revision can not be used togetherrrzARevision numbers only make sense for single revisions, not ranges)�???r<css|]}t|�VqdS�N��str�r��nr#r#r$�	<genexpr>tr�z cmd_revno.run.<locals>.<genexpr>�
)rr\rSrJrKr�r�r*r+r3�
last_revisionr:r[r��revision_id_to_dotted_revnor��GhostRevisionsHaveNoRevnor7�cleanup_nowr�r�)	r�rUr8rc�wtr�r�Zrevno_t�revnor#r#r$r�Ws8�
�
z
cmd_revno.run)Fr<N)
r�r�r�r�r�r�r
r�rr�r#r#r#r$r�Js
�r�c@sJeZdZdZdZdgZdeddd�edd	d�gZe	d
ddgfd
d��Z
d
S)�cmd_revision_infozJShow revision number and revision id for a given revision identifier.
    Tzrevision_info*rcrjzHBranch to examine, rather than the one containing the working directory.rxrUr�Nr<Fc	s�z&t�|�d}|j�|�|���Wn:tjtjfy`d}t�|�d�|�����Yn0g}|dur�|�	�fdd�|D��|dur�|D]}t
�|�}|�|�
���q�t|�dkr�|r�|dur�t�|��|�|���n|�����g}	d}
|D]^}z"��|�}d�dd�|D��}
Wntj�y>d}
Yn0t|
t|
��}
|	�|
|f�q�|��|	D]&\}
}|j�d|
|
|�d�f��qjdS)	Nrc3s|]}|���VqdSr�)r�)r�r��r�r#r$r��r�z(cmd_revision_info.run.<locals>.<genexpr>r<css|]}t|�VqdSr�r�)r��ir#r#r$r��r�r�z%*s %s
r�)rJrKr3r�r�rr*r+r:�extendrZfrom_string�appendr�r[r�r�r7r��maxr�r�r�r�)r�rcrjrUZrevision_info_listr�r�Zrev_strZrev_specZrevinfos�maxlenr�Zdotted_revnor�r�r#r�r$r��sH



�zcmd_revision_info.run)r�r�r�r�r�r�rr
r�rr�r#r#r#r$r�ys

��r�c@sTeZdZdZdgZedddd�eddd	�d
ededd
�gZdZddgZ	ddd�Z
dS)�cmd_adda�Add specified files or directories.

    In non-recursive mode, all the named items are added, regardless
    of whether they were previously ignored.  A warning is given if
    any of the named files are already versioned.

    In recursive mode (the default), files are treated the same way
    but the behaviour for directories is different.  Directories that
    are already versioned do not give a warning.  All directories,
    whether already versioned or not, are searched for files or
    subdirectories that are neither versioned or ignored, and these
    are added.  This search proceeds recursively into versioned
    directories.  If no names are given '.' is assumed.

    A warning will be printed when nested trees are encountered,
    unless they are explicitly ignored.

    Therefore simply saying 'brz add' will version all files that
    are currently unknown.

    Adding a file whose parent directory is not versioned will
    implicitly add the parent, and so on up to the root. This means
    you should never need to explicitly add a directory, they'll just
    get added when you add a file in the directory.

    --dry-run will show which files would be added, but not actually
    add them.

    --file-ids-from will try to use the file ids from the supplied path.
    It looks up ids trying to find a matching parent directory with the
    same filename, and then by pure path. This option is rarely needed
    but can be useful when adding the same logical file into two
    branches that will be merged later (without showing the two different
    adds as a conflict). It is also useful when merging another project
    into a subdirectory of this one.

    Any files matching patterns in the ignore list will not be added
    unless they are explicitly mentioned.

    In recursive mode, files larger than the configuration option
    add.maximum_file_size will be skipped. Named items are never skipped due
    to file size.
    rmz
no-recursez2Don't recursively add the contents of directories.�Nrs�dry-run�8Show what would be done, but don't actually do anything.rxrpz
file-ids-fromzLookup file ids from this tree.��typertr{�remove�ignoreFNcCs4ddl}t|�\}}|dur4|��s4ttd��d}d}|dur�zt�|�\}}	Wn*tjy|t	�|�\}
}	|
�
�}Yn0|jj||	|j
t�d�}n|jj|j
t�d�}|r�|�|���|j||||d�\}}
|��t|
�dk�r0|�r0t|
�D].}|
|D]}|j
�td��||���q�qdS)NrzKIgnoring --file-ids-from, since the tree does not support setting file ids.)r�Zshould_print)�actionZsavezignored {0} matching "{1}"
)Z
breezy.addrZZsupports_setting_file_idsrrSrJrKrr*r:r`�addZAddFromBaseActionr�rZAddWithSkipLargeActionr�r�Z	smart_addr�r[�sortedr�r�)r�rTZ
no_recurse�dry_runrpZ
file_ids_from�breezyrU�	base_tree�	base_path�base_branchr��added�ignored�glob�pathr#r#r$r��sP����
��
��zcmd_add.run)FFFN)r�r�r�r�r�r
rr�r�r�r�r#r#r#r$r��s(+�����r�c@sLeZdZdZdgZedddd�gZdZedd	��Z	ed
d��Z
dd
d�ZdS)�	cmd_mkdirzlCreate a new versioned directory.

    This is equivalent to creating the directory and then adding it.
    zdir+�parentsz8No error if existing, make parent directories as needed.�prsr{cCs0|�|�rdS|�|t�|��|�|g�dSr�)�is_versioned�add_file_with_parentsrO�dirnamer���clsr�rVr#r#r$r�(s
zcmd_mkdir.add_file_with_parentscCs|�|g�dSr�)r�r�r#r#r$�add_file_single/szcmd_mkdir.add_file_singleFcCs�|r|j}n|j}|D]�}t�|�\}}|rpzt�|�Wqztyl}z|jtjkrX�WYd}~qzd}~00n
t�	|�|||�t
�s|j�t
d�|�qdS)Nz	added %s
)r�r�rJrK�os�makedirs�OSError�errnoZEEXIST�mkdirrr�r�rS)r�Zdir_listr�Zadd_file�dirr�rV�er#r#r$r�3s

z
cmd_mkdir.runN)F)r�r�r�r�r�r
r�r��classmethodr�r�r�r#r#r#r$r�s��

r�c@s&eZdZdZdgZdZedd��ZdS)�cmd_relpathz$Show path of a file relative to rootrXTcCs*t�|�\}}|j�|�|j�d�dS)Nr�)rJrKr�r�)r�rXrUrVr#r#r$r�Mszcmd_relpath.runN�r�r�r�r�r�r�rr�r#r#r#r$r�Gs
r�c@sLeZdZdZdZdgZddeddd�ed	d
ed�gZdgZ	e
ddd��Zd
S)�
cmd_inventorya7Show inventory of the current working copy or a revision.

    It is possible to limit the output to a particular entry
    type using the --kind option.  For example: --kind file.

    It is also possible to restrict the list of files to a specific
    set. For example: brz inventory --show-ids this/file
    T�lsrcrnzinclude-rootz3Include the entry for the root of the tree, if any.rx�kindz<List entries of a particular kind: file, directory, symlink.�rtr�rmNFc
Cs$|r |dvr t�td�|f��td|�}t�|�\}}|�|���|durp|�|j	�}|g}|�|���n|}g}|�|���|dur�|j
||dd�}	|j|	d�}
n|��}
t|
�D]b\}}|r�||j
kr�q�|dkr�|s�q�|�r|j�d||j�d	�f�q�|j�|�|j�d
�q�dS)N)�filerj�symlinkzinvalid kind %r specifiedZ	inventoryT)Zrequire_versioned�r�r��	%-50s %s
r�r�)rr\rSr_rJr�r�r�rar3Zfind_related_paths_across_trees�iter_entries_by_dirr�rr�r��file_idr�)
r�rcr�r�include_rootrT�	work_treerU�extra_trees�paths�entriesr��entryr#r#r$r�ns>�
��
zcmd_inventory.run)NFNFN)r�r�r�r�r�r�r
rr�r�rr�r#r#r#r$rVs$	���
�rc@s,eZdZdZdgZgZdgZdZdd�ZdS)�cmd_cpawCopy a file.

    :Usage:
        brz cp OLDNAME NEWNAME

        brz cp SOURCE... DESTINATION

    If the last argument is a versioned directory, all the other names
    are copied into it.  Otherwise, there must be exactly two arguments
    and the file is copied to a new name.

    Files cannot be copied between branches. Only files can be copied
    at the moment.
    �names*�copyr{c
s�|durg}t|�dkr&t�td���tj|dd�\}��dd�D]}|dkrDt�td���qD|�|���t�	|d�}|s�z�\}}Wn t
y�t�td	���Yn0||fg}n�fd
d��dd�D�}|D�]\}}z|�|�}Wn.tj�yt�td�|||f��Yn0|du�rBt�td
|||f���|dk�rdt�td|||f���t�
|�d}	|	dk�r�z|�|	�}
Wn.tj�y�t�td�|||	f��Yn0|
dk�r�t�td�|	|	f��|�||�q�dS)Nr��missing file argumentF�Zcanonicalizer���r�zcan not copy root of branchzDto copy multiple files the destination must be a versioned directoryc	s(g|] }|t��dt�|�g�f�qS)r)rO�joinpath�basenamer���	rel_namesr#r$r��s�zcmd_cp.run.<locals>.<listcomp>z-Could not copy %s => %s: %s is not versioned.z/Could not copy %s => %s . %s is not versioned\.rjz,Could not copy %s => %s . %s is a directory.z,Could not copy to %s: %s is not a directory.)r[rr\rSrJr�r�r�rO�isdir�
IndexError�stored_kind�
NoSuchFile�splitZcopy_one)r��
names_listrU�	file_name�
into_existing�srcZdstZpairsZsrc_kindZ
dst_parentZdst_parent_kindr#rr$r��s~�
��


���

��
��
��

��z
cmd_cp.runN)	r�r�r�r�r�r�r�r�r�r#r#r#r$r�src@s^eZdZdZdgZeddd�eddd�edd	d�gZd
dgZdZddd�Z	dd�Z
dd�ZdS)�cmd_mva�Move or rename a file.

    :Usage:
        brz mv OLDNAME NEWNAME

        brz mv SOURCE... DESTINATION

    If the last argument is a versioned directory, all the other names
    are moved into it.  Otherwise, there must be exactly two arguments
    and the file is changed to a new name.

    If OLDNAME does not exist on the filesystem but is versioned and
    NEWNAME does exist on the filesystem but is not versioned, mv
    assumes that the file has been manually moved and only updates
    its internal inventory to reflect that change.
    The same is valid when moving many SOURCE files to a DESTINATION.

    Files cannot be moved between branches.
    r�afterzRMove only the brz identifier of the file, because the file has already been moved.rx�autozAutomatically guess renames.r�z+Avoid making changes when guessing renames.�move�renamer{FcCs�|r|�|||�S|r$t�td���|dur0g}t|�dkrJt�td���tj|dd�\}}|dd�D]}|dkrht�td	���qh|�|���|�	||||�dS)
Nz--dry-run requires --auto.r�rFrrrr�zcan not move root of branch)
�run_autorr\rSr[rJr�r�r��_run)r�r r%r&r�rUrr!r#r#r$r�s$�
�z
cmd_mv.runcCsl|dur"t|�dkr"t�td���|r4t�td���tj|dd�\}}|�|���tj	�
|��||�dS)Nrz)Only one path may be specified to --auto.z(--after cannot be specified with --auto.r<)Zdefault_directory)r[rr\rSrJr�r�r�Z
rename_mapZ	RenameMapZ
guess_renamesr`)r�r r%r�rrTr#r#r$r)s���

�zcmd_mv.run_autocCs�t�|d�}|rzt|�dkrz|jsB|d��|d��krBd}n8|�|d�}t�|d�sz|�|�rz|�|�dkrzd}|r�t	|�
|��}|j|dd�|d|d�D]"\}}t�s�|j
�d||f�q��nt|�dkr�t�td	���|�|d�}|�|d�}	t�|	�}
t�|d�}|�|	�}|du�sB|�|�|k�r�|�rz|
�r^t�|j|
�}
n|j}
t�|
t�|
|��}n|}ntj�|	�}t�|
|�}td
||�|j|||d�t��s�|j
�d||f�dS)Nrr�rrFrj)r%�	%s => %s
zBto mv multiple files the destination must be a versioned directoryzattempting to move %s => %s)rOrr[Zcase_sensitive�lowerZget_canonical_path�lexistsr�r�listZget_canonical_pathsr'rr�r�rr\rSr�rZpath2id�pathjoin�basedirZcanonical_relpathr�r�rZ
rename_one)r�rUr rr%r"Z	from_pathr#�destZ
canon_destZdest_parentZ	spec_tailZdest_idZdest_parent_fqZ	dest_tailr#r#r$r*%sV���$

�
�zcmd_mv._runN)FFF)r�r�r�r�r�r
r�r�r�r�r)r*r#r#r#r$r$�s

��

r$c@sheZdZdZgd�Zdddeddd�ed	d
d�eddd�ed
dd�eddd�gZdgZdZ	ddd�Z
dS)�cmd_pulla&Turn this branch into a mirror of another branch.

    By default, this command only works on branches that have not diverged.
    Branches are considered diverged if the destination branch's most recent
    commit is one that has not been merged (directly or indirectly) into the
    parent.

    If branches have diverged, you can use 'brz merge' to integrate the changes
    from one into the other.  Once one branch has merged, the other should
    be able to pull it again.

    If you want to replace your local changes and just want your branch to
    match the remote one, use pull --overwrite. This will work even if the two
    branches have diverged.

    If there is no default location set, the first pull will set it (use
    --no-remember to avoid setting it). After that, you can omit the
    location to use the default.  To change the default, use --remember. The
    value will only be saved if the remote location can be accessed.

    The --verbose option will display the revisions pulled using the log_format
    configuration option. You can use a different format by overriding it with
    -Olog_format=<other_format>.

    Note: The location can be specified either in the form of a branch,
    or in the form of a path to a file containing a merge directive generated
    with brz send.
    )�push�updater~�send�remember�	overwritercrpzShow logs of pulled revisions.rxrjzJBranch to pull into, rather than the one containing the working directory.�localzZPerform a local pull in a bound branch.  Local pulls are not applied to the master branch.�	show-base�%Show base revision text in conflicts.�overwrite-tags�Overwrite tags only.r�r{NFc
Cs�|rddg}n|	rdg}ng}d}
d}|dur2d}z&t�|�d}|j}
|�|���WnDtjy�d}t�|�d}
|�|
���|r�tt	d��Yn0|r�|
�
�s�t���g}|dur�ztj
||d�}Wntjy�d}Yn0|
��}|du�rF|du�rt�t	d���n0t�||jj�}t��sB|j�t	d�|�|}td	|�}|du�r�|du�rrt�t	d
���|�|
j�|�|
j�\}}
}|
}nFtj||d�}|�|���|�s�|du�r�|
��du�r�|
�|j�|du�r�|�|�}
|du�r*t |�}t!j"|j#|d�}|j$|||
|||d�}n|
j$|||
|d
�}|�%|j�|�rr|j&|j'k�rrt(�)|
|j|j*|j&�t+|dd��r�dSdSdS)N�history�tagsr<rz%No working tree, ignoring --show-baserz$No pull location known or specified.z Using saved parent location: %s
�pull�.Cannot use -r with merge directives or bundles�Zunversioned_filterrf)r8�	show_base)r8Z
tag_conflictsr),rJrKr3r��
lock_writerr*r:rrSr �LocalRequiresBoundBranch�_mod_mergeable�read_mergeable_from_url�
NotABundle�
get_parentr\r5�unescape_for_displayr�r�rr�r_Zinstall_revisionsr�Zget_merge_requestr(r��
set_parentrr�rh�delta�_ChangeReporter�
is_ignoredr?�reportZ	old_revidZ	new_revid�logZshow_branch_changeZ	old_revnor�)r�r8r6r7rcrprjr8rB�overwrite_tagsr��	mergeableZtree_toZ	branch_tor�
stored_loc�display_url�base_revision_id�verifiedZbranch_fromrf�change_reporter�resultr#r#r$r��s�
�



�
�


�
���
�


���
�zcmd_pull.run)	NNFNFNFFF)r�r�r�r�r�rr
r�r�r�r�r#r#r#r$r2vs4�������r2c@s�eZdZdZgd�Zddddeddd	�ed
dd	�edd
d	�eddd	�edded�eddd	�eddd	�eddd	�eddd	�g
ZdgZ	dZ
d!dd �ZdS)"�cmd_pushaQUpdate a mirror of this branch.

    The target branch will not have its working tree populated because this
    is both expensive, and is not supported on remote file systems.

    Some smart servers or protocols *may* put the working tree in place in
    the future.

    This command only works on branches that have not diverged.  Branches are
    considered diverged if the destination branch's most recent commit is one
    that has not been merged (directly or indirectly) by the source branch.

    If branches have diverged, you can use 'brz push --overwrite' to replace
    the other branch completely, discarding its unmerged changes.

    If you want to ensure you have the different changes in the other branch,
    do a merge (see brz help merge) from the other branch, and commit that.
    After that you will be able to do a push without '--overwrite'.

    If there is no default push location set, the first push will set it (use
    --no-remember to avoid setting it).  After that, you can omit the
    location to use the default.  To change the default, use --remember. The
    value will only be saved if the remote location can be accessed.

    The --verbose option will display the revisions pushed using the log_format
    configuration option. You can use a different format by overriding it with
    -Olog_format=<other_format>.
    )r?r4r�r6r7rprc�
create-prefix�FCreate the path leading up to the branch if it does not already exist.rxrjzJBranch to push from, rather than the one containing the working directory.�use-existing-dirz�By default push will fail if the target directory exists, but does not already have a control directory.  This flag will allow push to proceed.�stackedzQCreate a stacked branch that references the public location of the parent branch.�
stacked-onz�Create a stacked branch that refers to another branch for the commit history. Only the work not present in the referenced branch is included in the branch created.rr�zdRefuse to push if there are uncommitted changes in the working tree, --no-strict disables the check.�no-treezDDon't populate the working tree, even for protocols that support it.r;r<�lossyzQAllow lossy push, i.e. dropping metadata that can't be represented in the target.r�r{NFcCs�ddlm}ddlm}|r&ddg}n|
r2dg}ng}|durBd}tj�|�\}}}td|�}|durt|�|�j	}nd}|dur�|dur�|j
|dd	d
d�|	dur�||	d�}	t�|	�}	n<|
r�|�
�}|r�t�|�}|��}	|	s�|}	|	s�t�td
���|du�rr|��}|du�rN|�
�}|�r>t�tdt�||jj����nt�td���n$t�||jj�}ttd�|�|}|||||j||||	||||d�dS)Nr��location_to_url)�_show_push_branchr=r>r<r3Zpush_strictz"Use --no-strict to force the push.z'Uncommitted changes will not be pushed.)Z
more_errorZmore_warning�readz'Could not determine branch to refer to.zbNo push location known or specified. To push to the parent branch (at %s), use 'brz push :parent'.z$No push location known or specified.zUsing saved push location: %s)rpr7r6�
stacked_on�
create_prefix�use_existing_dir�no_treer_)r8rar3rbr&r'rir_�
in_historyr�Zcheck_changed_or_out_of_dater5Z
normalize_urlrHr:r(�get_public_branchrr\rSZget_push_locationrIr�r�r)r�r8r6r7rerprcrfrjrdr\r�rgrPr_rarbrU�br_from�_unusedr�Z
parent_url�parentrRZ
parent_locrSr#r#r$r�Js|

�
�

�

������zcmd_push.run)NNFFFNFNNFNFFF)r�r�r�r�r�r
rrr�r�r�r�r#r#r#r$rX	sL��������
��rXc@s�eZdZdZdgZdgZddgZdeddd	�ed
edd�ed
dd	�eddd	�eddd	�eddd	�eddd	�eddd	�eddd	�edde	dd�gZ
d#d!d"�ZdS)$�
cmd_branchaTCreate a new branch that is a copy of an existing branch.

    If the TO_LOCATION is omitted, the last component of the FROM_LOCATION will
    be used.  In other words, "branch ../foo/bar" will attempt to create ./bar.
    If the FROM_LOCATION has no / or path separator embedded, the TO_LOCATION
    is derived from the FROM_LOCATION by stripping a leading scheme or drive
    identifier, if any. For example, "branch lp:foo-bar" will attempt to
    create ./foo-bar.

    To retrieve the branch as of a particular revision, supply the --revision
    parameter, as in "branch foo/bar -r 5".
    �sproutr��
from_location�to_location?rc�hardlink�,Hard-link working tree files where possible.rx�
files-from�!Get file contents from this tree.r�r^z'Create a branch without a working-tree.�switchz?Switch the checkout in the current directory to the new branch.r\z�Create a stacked branch referring to the source branch. The new branch will depend on the availability of the source branch for all operations.�
standalonez2Do not use a shared repository, even if available.r[z�By default branch will fail if the target directory exists, but does not already have a control directory.  This flag will allow branch to proceed.�bindz!Bind new branch to from location.�no-recurse-nested�*Do not recursively check out nested trees.zcolocated-branchr�z#Name of colocated branch to sprout.)rur�rtNFcCs6ddlm}tjj||
d�\}}|r*d}nd}|s:|s:d}|durT||krTt�|�}td|�}|�|�	��|dur�|�
|�}n|��}|dur�t�
|�}tj|dd�}z|�d	�Wn�tj�y@ztj�|�}Wn4tj�y|�st�td
�|��nd}Yn00z|��Wntj�y0Yn0t�|��Yn,tj�yft�td�|��Yn0d}|du�r�z>|jj|j||g|||||||d�
}|j|jj|gd
�}Wn:tj�y�|�d	�td��||�}t�|��Yn0nJz|� �}Wntj!�y|�"�}Yn0|j#|j$|d�|j||d�}|j%�&|j%�zt'td�|�(��Wnjtj)t*j+tj,f�y�}zD|�-�}|du�r�t't.dd|�-��|�nt'td��WYd}~n
d}~00|
�r�t/�|�}|�0|�t'td�|�|	�r2t�1d	�\}}|�|j|�t'td�t�2|jd��dS)Nr�ru�rA�none�downr3r��Zpurposer<z%Target directory "%s" already exists.zParent of "%s" does not exist.)r�accelerator_treerqr\�force_new_repoZcreate_tree_if_local�
source_branch�recurserz#The branch {0} has no revision {1}.�r�z+Created new stacked branch referring to %s.zBranched %d revision.zBranched %d revisions.zCreated new branch.zNew branch bound to %szSwitched to branch: %sr�)3r�rur&r'�open_tree_or_branchrJr(r_r�r�r�r�r5�derive_to_location�	transport�
get_transportr�rZ
FileExists�open_from_transportrr\rSr�AlreadyBranchErrorrrnrrr�Zdelete_treer��open_repositoryZNoRepositoryPresentZcreate_repositoryZfetchr�r>�merge_torZget_stacked_on_urlZ
NotStackedZ_mod_branchZUnstackableBranchFormatZUnstackableRepositoryFormatr��ngettextr:rwrKrI)r�ro�to_locationrcrqr\rvrgrfrurw�
files_from�no_recurse_nestedZcolocated_branchZ_mod_switchrrjr�r��to_transportZto_dirr3r�Zto_repor�r�Z
parent_branchr�r�r#r#r$r��s��



�
�

�
���

���

�
��"

�zcmd_branch.run)NNFFFFFFFNFN)r�r�r�r�Zaliaser�r�r
rr�r�r�r#r#r#r$rm�sR
������������rmc@s0eZdZdZdgZedddd�gZdd	d
�ZdS)
�cmd_branchesz�List the branches available at the current location.

    This command will print the names of all the branches at the current
    location.
    r��	recursive�RzQRecursively scan for branches rather than just looking in the specified location.�rurtr<Fc
Cs\|rftj|dd�}|��s$t�d��tj�|�D]2}|j�	dt
�t
�|j
|j
�|jj��d��q0n�tj�|�d}z|jdd�}Wntjy�d}Yn0i}t|�D].\}}	|dkr�q�|duo�|j|	jk}
|
||<q�tt|���s|du�r|j�	d	td
��t|�D]F}||}
|
�r(d}nd}|j�	d
|t�r@|n|�|jj�f��qdS)Nrcr~z!Can't scan this type of location.�%s
r1rr�r{z* %s
z	(default)�*� �%s %s
)r�r�Zlistablerr\r&r'rBr�r�r5rIrCrr�rErKrrrHrD�anyrrSr�rr�)r�r8r��tr�r��
active_branch�namesrAr3�active�prefixr#r#r$r�@sH���

�
�zcmd_branches.runN)r<F�r�r�r�r�r�r
r�r�r#r#r#r$r�3s��r�c@sVeZdZdZgd�ZddgZdeddd�ed	ed
d�edd
d�gZdgZ	ddd�Z
dS)�cmd_checkouta�Create a new checkout of an existing branch.

    If BRANCH_LOCATION is omitted, checkout will reconstitute a working tree
    for the branch found in '.'. This is useful if you have removed the working
    tree or if it was never created - i.e. if you pushed the branch to its
    current location using SFTP.

    If the TO_LOCATION is omitted, the last component of the BRANCH_LOCATION
    will be used.  In other words, "checkout ../foo/bar" will attempt to create
    ./bar.  If the BRANCH_LOCATION has no / or path separator embedded, the
    TO_LOCATION is derived from the BRANCH_LOCATION by stripping a leading
    scheme or drive identifier, if any. For example, "checkout lp:foo-bar" will
    attempt to create ./foo-bar.

    To retrieve the branch as of a particular revision, supply the --revision
    parameter, as in "checkout foo/bar -r 5". Note that this will be
    immediately out of date [so you cannot commit] but it may be useful (i.e.
    to examine old code.)
    )�	checkoutsr3r�zremove-treezbranch_location?rprc�lightweightz�Perform a lightweight checkout.  Lightweight checkouts depend on access to the branch for every operation.  Normal checkouts can perform common operations like diff and status without such access, and also support local commits.rxrsrtr�rqrr�coNFc
Cs�|durt��}|}tj�|�\}}|s0|s0d}td|�}|durT||krTt�|�}|durh|�|�}	nd}	|dur~t	�
|�}t�|�t�|�kr�z|j��Wn"t
jy�|j�|	�YdS0|�||	|||�dS)Nr�)rO�getcwdr&r'r�r_rJr(r�r5r�rQr)rr*�create_workingtreeZcreate_checkout)
r��branch_locationr�rcr�r�rqr�sourcer�r#r#r$r��s2�



�zcmd_checkout.run)NNNFNF)r�r�r�r�r�r�r
rr�r�r�r#r#r#r$r�es$�����r�c@s2eZdZdZddgZdeddd�gZdd
d�ZdS)
�	cmd_clonezClone a control directory.
    rorprcrxryrxNFc
Cs�tj�|�\}}|rd}nd}td|�}|�|���|durJ|�|�}n|��}|durdt�	|�}|jj
||d�}	ttd��dS)Nr|r}r3r�zCreated new control directory.)
r&r'r�r_r�r�r�r�r5r�ZclonerrS)
r�ror�rcr�rrjr�r�Ztarget_controldirr#r#r$r��s�

z
cmd_clone.run)NNFr�r#r#r#r$r��s��r�c@s*eZdZdZdgZdgZeddd��ZdS)	�cmd_renamesz Show list of renamed files.
    r��dir?r<c	Cs�t�|�d}|�|���|��}|�|���g}|j|dd�}|D]2}|jd|jdkrbqHd|jvrnqH|�|j�qH|��|D]\}}|j	�
d||f�q�dS)NrT)Zinclude_unchangedrr+)rJrKr�r�r`�iter_changesr�r��sortr�r�)	r�r�rU�old_tree�renames�iteratorroZold_name�new_namer#r#r$r��s
zcmd_renames.runN)r<)r�r�r�r�r�r�rr�r#r#r#r$r��s
r�c@s>eZdZdZgd�ZdgZdeddd�gZdgZdd
d�Z	d	S)
�
cmd_updateaoUpdate a working tree to a new revision.

    This will perform a merge of the destination revision (the tip of the
    branch, or the specified revision) into the working tree, and then make
    that revision the basis revision for the working tree.

    You can use this to visit an older revision, or to update a working tree
    that is out of date from its branch.

    If there are any uncommitted changes in the tree, they will be carried
    across and remain as uncommitted changes after the update.  To discard
    these changes, use 'brz revert'.  The uncommitted changes may conflict
    with the changes brought in by the change in basis revision.

    If the tree's branch is bound to a master branch, brz will also update
    the branch from the master.

    You cannot update just a single file or directory, because each Breezy
    working tree has just a single basis revision.  If you want to restore a
    file that has been removed locally, use 'brz revert' instead of 'brz
    update'.  If you want to restore a file to its state in a previous
    revision, use 'brz revert' with a '-r' option, or use 'brz cat' to write
    out the old content of that file to a new location.

    The 'dir' argument, if given, must be the location of the root of a
    working tree to update.  By default, the working tree that contains the
    current working directory is used.
    )r?r�r~r�rcr9r:rxZupNc
Cs2|dur"t|�dkr"t�td���|dur:t�d�d}n t�|�\}}|rZt�td���|j}g}|j|d�}|dur�|j}	|�	|�
��n|jj}	|�	|���t�
|	�d�|jj�}	|��dd�}
|dur�d}n
|�|�}|dur�|d�|�}n|��}|t�|���k�rD|�|�}
ttd��d�tt|
��|	��dSt|�}tj|j |d	�}z|j|||||d
�}Wn<tj!�y�}z t�td�|j"��WYd}~n
d}~00|j�t�|����}
ttd��d�tt|
��|	��|��}|dd��r|dd�|
k�rttd
��|dk�r*dSdSdS)Nrz0brz update --revision takes exactly one revisionr<rzCbrz update can only update a whole tree, not a file or subdirectoryrr1z0Tree is up to date at revision {0} of branch {1}rA)rrc�old_tiprBz_branch has no revision %s
brz update --revision only works for a revision in the branch historyz%Updated to revision {0} of branch {1}zmYour local commits will now show as pending merges with 'brz status', and can be committed with 'brz commit'.)#r[rr\rSrJrKr3Zget_master_branchrr�rCr�r5rIrEr�r��get_parent_idsr4r�r��
_mod_revision�ensure_nullr�rr�r7�mapr�rhrKrLrMr�rc)r�r�rcrBrUrVr3rZmasterr�Zexisting_pending_mergesr�r�r�rfrV�	conflictsr�Z
parent_idsr#r#r$r�s�����


���
���
� 
zcmd_update.run)NNN)
r�r�r�r�r�r�r
r�r�r�r#r#r#r$r��s��r�c@s6eZdZdZgd�ZdgZdgZdZed
dd	��Z	dS)�cmd_infoasShow information about a working tree, branch or repository.

    This command will show all known locations and formats associated to the
    tree, branch or repository.

    In verbose mode, statistical information is included with each report.
    To see extended statistic information, use a verbosity level of 2 or
    higher by specifying the verbose option multiple times, e.g. -vv.

    Branches and working trees will also report any missing revisions.

    :Examples:

      Display information on the format and related locations:

        brz info

      Display the above together with extended format information and
      basic statistics (like the number of files in the working tree and
      number of revisions in the branch and repository):

        brz info -v

      Display the above together with number of committers to the branch:

        brz info -vv
    )r�r��repositoriesr�rpr{NFcCs<|rt�}nd}ddlm}|tj�|�d||jd�dS)Nrr��show_bzrdir_info�rpZoutfile)rr�r�r&r'rKr�)r�r8rpZnoise_levelr�r#r#r$r�|s�zcmd_info.run)NF)
r�r�r�r�r�r�r�r�rr�r#r#r#r$r�[sr�c@sTeZdZdZdgZdeddd�ejddd	d
ddd
dd�gZddgZ	dZ
ddd�ZdS)�
cmd_removea�Remove files or directories.

    This makes Breezy stop tracking changes to the specified files. Breezy will
    delete them if they can easily be recovered using revert otherwise they
    will be backed up (adding an extension of the form .~#~). If no options or
    parameters are given Breezy will scan for files that are being tracked by
    Breezy but missing in your tree and stop tracking them for you.
    rmrp�newz1Only remove files that have never been committed.rxzfile-deletion-strategyz"The file deletion mode to be used.zDeletion StrategyTFzBackup changed files (default).z+Delete from brz but leave the working copy.zDon't backup changed files.)�title�value_switches�enum_switch�safe�keep�	no_backupZrm�delr{r�c	Cs�t�|�\}}|dur$dd�|D�}|�|���|r||j|��|d�j}tdd�|D�dd�}t|�dkr�t	�
td���n\|dur�g}|�|���D]0}|j
d	dur�|jd	dur�|�|j
d	�q�t|dd�}d
}|j|||j|d
k|dkd�dS)
NcSsg|]}|�qSr#r#�r��fr#r#r$r��r�z"cmd_remove.run.<locals>.<listcomp>rcSsg|]}|jd�qS)r)r�r�r#r#r$r��r�T)�reverserzNo matching files.rr��	no-backup)rpr�Z
keep_filesr�)rJr�r�rC�changes_fromr`r�r�r[rr\rSr�r�rr�r�r�)	r�rTrpr�Zfile_deletion_strategyrUr�Zmissingror#r#r$r��s,
��zcmd_remove.runN)FFr�)r�r�r�r�r�r
r�from_kwargsr�r�r�r�r#r#r#r$r��s&���
�r�c@s6eZdZdZdgZdgZedddd�gZd
d
d�ZdS)�
cmd_reconcilea�Reconcile brz metadata in a branch.

    This can correct data mismatches that may have been caused by
    previous ghost operations or brz upgrades. You should only
    need to run this command if 'brz check' or a brz developer
    advises you to run it.

    If a second branch is provided, cross-branch reconciliation is
    also attempted, which will check that data like the tree root
    id which was not present in very early brz versions is represented
    correctly in both branches.

    At the same time it is run it may recompress data resulting in
    a potential saving in disk space or performance gain.

    The branch *MUST* be on a listable system such as local disk or sftp.
    �check�branch?zcanonicalize-chksz:Make sure CHKs are in canonical form (repairs bug 522637).T�rtr�r<FcCs(ddlm}tj�|�}|||d�dS)Nr)�	reconcile)�canonicalize_chks)r�r&r'r()r�r3r�r�r�r#r#r$r��szcmd_reconcile.runN)r<Fr�r#r#r#r$r��s��r�c@s.eZdZdZdgZdgZdZed	dd��ZdS)
�cmd_revision_historyz-Display the list of revision ids on a branch.rOr�Tr<cCsht�|�d}|�|���|j��}t|�|��t	j
g��}t|�D]}|j�
|�|j�
d�qFdS�Nrr�)r:rKr�r�r��	get_graphr.Ziter_lefthand_ancestryr�r��
NULL_REVISION�reversedr�r�)r�r8r3�graphr=r�r#r#r$r��s
�zcmd_revision_history.runN)r<�	r�r�r�r�r�r�r�rr�r#r#r#r$r��sr�c@s0eZdZdZddgZdgZdZed
dd��Zd	S)�cmd_ancestryz+List all revisions merged into this branch.rOzrevision-historyr�Tr<cCs�zt�|�d}Wn&tjy8t�|�}|��}Yn0|j}|��}|�|j	�
��|j	��}dd�|�|g�D�}t
|�D]&}t�|�r�q�|j�|�d�d�q�dS)NrcSsg|]\}}|�qSr#r#)r�r�r�r#r#r$r�	r�z$cmd_ancestry.run.<locals>.<listcomp>r�r�)rJrKrr*r:r(r�r3r�r�r�r�Z
iter_ancestryr�r��is_nullr�r�r�)r�r8r�r�r�r�r^r�r#r#r$r��s 


�
zcmd_ancestry.runN)r<r�r#r#r#r$r��sr�c	@s^eZdZdZgd�ZdgZeddd�eddd	d
d�dd
d�eddd�edd�gZddd�Z	dS)�cmd_inita�Make a directory into a versioned branch.

    Use this to create an empty branch, or before importing an
    existing project.

    If there is a repository in a parent directory of the location, then
    the history of the branch will be stored in the repository.  Otherwise
    init creates a standalone branch which carries its own history
    in the .bzr directory.

    If there is already a branch at the location but it has no working tree,
    the tree can be populated with 'brz checkout'.

    Recipe for importing a tree of files::

        cd ~/project
        brz init
        brz add .
        brz status
        brz commit -m "imported project"
    )zinit-shared-repositoryr3r�r�rYrZrxr�zESpecify a format for this branch. See "help formats" for a full list.�zbreezy.controldir�format_registrycCstj�|�Sr��r&r��make_controldirr{r#r#r$�<lambda>2s�zcmd_init.<lambda>T�
Branch format�rt�
lazy_registryZ	converterr�r�zappend-revisions-onlyzFNever change revnos or the existing log.  Append revisions to it only.r^z'Create a branch without a working tree.NFc	Cs2|durtj�d�}|dur d}tj|dd�}z|��Wn2tjyl|s`t�t	d�|��|�
�Yn0ztj�|�}WnDtj
y�tjj}|r�d}	nd}	||j||g|	d�}
|
j}Yn\0dd	lm}|��r�t||�r�|��s�t�|��t�|��|��}
|�s|���s|��|�rXz|
�d
�Wn$tj�yVt�t	d���Yn0t��s.ddlm}m}
z|jdd
�}Wn tj tj!f�y�d}Yn0|
j"}|||
|��#�}|
|||
|�}|j$�%t	d��&||��|�'��r.|jj(�)�}zt*�+|�}Wnt*j,�yYn0|j$�%t	d�|�dS)N�defaultr<r�r~zoParent directory of %s does not exist.
You may supply --create-prefix to create all leading parent directories.F)r�r�force_new_treer)�LocalTransportTzJThis branch format cannot be set to append-revisions-only.  Try --default.)�describe_layout�describe_format)Zrecommend_upgradezCreated a {0} (format: {1})
zUsing shared repository: %s
)-r&r�r�r�r�Zensure_baserrr\rSrer'r�rZcreate_branch_conveniencerZtransport.localr�Z
has_branch�
isinstance�has_workingtreeZBranchExistsWithoutWorkingTreer��
create_branchr�Zset_append_revisions_only�UpgradeRequiredrr�r�r�r)r*r+r�r,r�r�r�Z	is_sharedrZexternal_urlr5Zlocal_path_from_urlZ
InvalidURL)r�r8r�Zappend_revisions_onlyrergr�Za_controldirr�r�r3r�r�r�rUr�Zlayout�urlr#r#r$r�>sz
���
�


�
zcmd_init.run)NNFFF)
r�r�r�r�r�r�r
rr�r�r#r#r#r$r�s.��	����r�c@sTeZdZdZgd�ZdgZeddddd�d	d
d�edd
d�gZddgZ	ddd�Z
dS)�cmd_init_shared_repositorya'Create a shared repository for branches to share storage space.

    New branches created under the repository directory will store their
    revisions in the repository, not in the branch directory.  For branches
    with shared history, this reduces the amount of storage needed and
    speeds up the creation of new branches.

    If the --no-trees option is given then the branches in the repository
    will not have working trees by default.  They will still exist as
    directories on disk, but they will not have separate copies of the
    files at a certain revision.  This can be useful for repositories that
    store branches which are interacted with through checkouts or remote
    branches, such as on a server.

    :Examples:
        Create a shared repository holding just branches::

            brz init-shared-repo --no-trees repo
            brz init repo/trunk

        Make a lightweight checkout elsewhere::

            brz checkout --lightweight repo/trunk trunk-checkout
            cd trunk-checkout
            (add files here)
    )Zinitr3r�r�r8r�zISpecify a format for this repository. See "brz help formats" for details.r�cCstj�|�Sr�r�r{r#r#r$r��s�z#cmd_init_shared_repository.<lambda>TzRepository formatr�zno-treeszEBranches in the repository will default to not having a working tree.rxzinit-shared-repoz	init-repoNFc	Cs�|durtj�d�}|dur d}tj|dd�}|jr:d}n
|j��}|j|d|ddd|d�\}}}}	t	�s�ddl
m}
|
|d	|jd
�dS)Nr�r<r�r~T)reZmake_working_treesZshared_repor�rf�repo_format_namerr�rr�)
r&r�r�r�r�Zfixed_componentsZrepository_formatZget_format_stringZinitialize_on_transport_exrr�r�r�)r�r8r�Zno_treesr�r�rGZnewdirZrequire_stackingZrepository_policyr�r#r#r$r��s$
��
zcmd_init_shared_repository.run)NF)r�r�r�r�r�r�rr
r�r�r�r#r#r#r$r��s���r�c@s�eZdZdZdgZdgZededd�ededd	d
�edded
�edded
�ddedded
�edddddd�edde	d
�ej
ddddd d!d"d#d$�ed%d&d'�gZd(d)gZd*Z
ed/d-d.��Zd+S)0�cmd_diffa8
Show differences in the working tree, between revisions or branches.

    If no arguments are given, all changes for the current tree are listed.
    If files are given, only the changes in those files are listed.
    Remote and multiple branches can be compared by using the --old and
    --new options. If not provided, the default for both is derived from
    the first argument, if any, or the current tree if no arguments are
    given.

    "brz diff -p1" is equivalent to "brz diff --prefix old/:new/", and
    produces patches suitable for "patch -p1".

    Note that when using the -r argument with a range of revisions, the
    differences are computed between the two specified revisions.  That
    is, the command does not show the changes introduced by the first
    revision in the range.  This differs from the interpretation of
    revision ranges used by "brz log" which includes the first revision
    in the range.

    :Exit values:
        1 - changed
        2 - unrepresentable changes
        3 - error
        0 - no change

    :Examples:
        Shows the difference in the working tree versus the last commit::

            brz diff

        Difference between the working tree and revision 1::

            brz diff -r1

        Difference between revision 3 and revision 1::

            brz diff -r1..3

        Difference between revision 3 and revision 1 for branch xxx::

            brz diff -r1..3 xxx

        The changes introduced by revision 2 (equivalent to -r1..2)::

            brz diff -c2

        To see the changes introduced by revision X::

            brz diff -cX

        Note that in the case of a merge, the -c option shows the changes
        compared to the left hand parent. To see the changes against
        another parent, use::

            brz diff -r<chosen_parent>..X

        The changes between the current revision and the previous revision
        (equivalent to -c-1 and -r-2..-1)

            brz diff -r-2..

        Show just the differences for file NEWS::

            brz diff NEWS

        Show the differences in working tree xxx for file NEWS::

            brz diff xxx/NEWS

        Show the differences from branch xxx to this working tree:

            brz diff --old xxx

        Show the differences between two branches for file NEWS::

            brz diff --old xxx --new yyy NEWS

        Same as 'brz diff' but prefix paths with old/ and new/::

            brz diff --prefix old/:new/

        Show the differences using a custom diff program with options::

            brz diff --using /usr/bin/diff --diff-options -wu
    r�rmzdiff-optionsz0Pass these options to the external diff program.r�r�r�zbSet prefixes added to old and new filenames, as two values separated by a colon. (eg "old/:new/").�r�rurt�oldzBranch/tree to compare from.rr�zBranch/tree to compare to.rcror@z"Use this command to compare files.r��FzDiff format to use.)zbreezy.diffr�zDiff format)rurtr�r��contextz"How many lines of context to show.�colorzColor mode to use.z
Color ModeFTzNever colorize output.zAOnly colorize output if terminal supports it and STDOUT is a TTY.z!Always colorize output (default).)rtr�r�r��neverr&�alwayszcheck-stylezAWarn if trailing whitespace or spurious changes have been  added.rxZdiZdif�exactNr�cCs8ddlm}m}|dkr"d}
d}n@|dks2|dur<d}
d}n&d|vrT|�d�\}
}nt�td	���|r�t|�d
kr�t�td���|dur�|dur�t�td��d
d���||||||j	dd�\}}}}}}t
��}|j}|
dkr�ddl
m}|�r�d}
nd}
d|
k�rddlm}||�}|||||||
|||||	|d�S)Nr)�%get_trees_and_branches_to_diff_locked�show_diff_trees�0r��1zold/znew/�:zA--prefix expects two values separated by a colon (eg "old/:new/")r�z@brz diff --revision takes exactly one or two revision specifiers�"{0} and {1} are mutually exclusivez--usingz--formatT��
apply_viewr&)�has_ansi_colorsr�r�)�
DiffWriter)	r�Zexternal_diff_options�	old_label�	new_labelr
�
path_encodingr@r�Z
format_cls)r|r�r�rrr\rSr[r��_exit_stackrO�get_diff_header_encodingr�ZterminalrZ	colordiffr)r�rcrTZdiff_optionsr�r�r�r@r�r�r�r�r�rrr�Znew_treeZ
old_branchZ
new_branchr�r
rr�rrr#r#r$r�V	sZ�����
�zcmd_diff.run)
NNNNNNNNNr�)r�r�r�r�r�r�r
rr�intr�r�r�r�rr�r#r#r#r$r��slU����������,�r�c@s.eZdZdZddgZddgZeddd	��Zd
S)�cmd_deletedz,List files deleted in the working tree.
    r�rrjrnFr<cCs�t�|�d}|�|���|��}|�|���|�|�}|jD]@}|j�|j	d�|rv|j�d�|j�|j
�|j�d�qBdS)Nrr�r�)rJrKr�r�r`r�Zremovedr�r�r�r
)r�r�rjrUr�rKror#r#r$r��	s

zcmd_deleted.runN)Fr<)r�r�r�r�r�r�rr�r#r#r#r$r	�	s
r	c@s2eZdZdZdZddgZddgZedd	d
��ZdS)
�cmd_modifiedz)List files modified in working tree.
    Tr�rrj�nullFr<cCszt�|�d}|�|���|�|���}|��|jD]<}|rX|j�	|j
dd�q8|j�	t�|j
d�d�q8dS)Nrr�r�)
rJrKr�r�r�r`r�Zmodifiedr�r�r�rO�quotefn)r�rrjrUZtdror#r#r$r��	s
zcmd_modified.runN)Fr<�	r�r�r�r�r�r�r�rr�r#r#r#r$r
�	sr
c@s2eZdZdZdZddgZddgZedd	d
��ZdS)
�	cmd_addedz&List files added in working tree.
    Tr�rrjrFr<cCs�t�|�d}|�|���|��}|�|���|��D]`}|�|�rJq:|dkrTq:t�t	�
|j|�tj�snq:|r�|j
�|d�q:|j
�t	�|�d�q:dS)Nrr�rr�)rJrKr�r�r`Zall_versioned_paths�has_filenamer��accessrOr/r0�F_OKr�r�r
)r�rrjr�Zbasisr�r#r#r$r��	s
z
cmd_added.runN)Fr<rr#r#r#r$r�	src@s$eZdZdZdgZeddd��ZdS)�cmd_rootzlShow the tree root directory.

    The root is the nearest enclosing directory with a control
    directory.�	filename?NcCs$t�|�d}|j�|jd�dS)zPrint the branch root.rr�N)rJrKr�r�r0)r�rXrUr#r#r$r��	szcmd_root.run)N)r�r�r�r�r�rr�r#r#r#r$r�	srcCs4z
t|�WSty.td�}t�|��Yn0dS)Nz&The limit argument must be an integer.�r�
ValueErrorrSrr\)Zlimitstringr�r#r#r$�_parse_limit�	s

rcCs4z
t|�WSty.td�}t�|��Yn0dS)Nz'The levels argument must be an integer.r)�sr�r#r#r$�
_parse_levels�	s

rc@seZdZdZdgZddgZeddd�ded	d
d�dded
ej	j
ddd�deddddd�edddded�edde
dd�ed d!d"ded�ed#d$d%d&�ed'd(d�ed)dd*d+�ed,d-d�ed.d/d�ed0d1d�ed2d3d4e
d5�ed6d7e
d8�ed9d:e
d8�ed;d<e
d8�ed=d>e
d8�gZd?ZedEdCdD��Zd@S)F�cmd_logamShow historical log for a branch or subset of a branch.

    log is brz's default tool for exploring the history of a branch.
    The branch to use is taken from the first parameter. If no parameters
    are given, the branch containing the working directory is logged.
    Here are some simple examples::

      brz log                       log the current branch
      brz log foo.py                log a file in its branch
      brz log http://server/branch  log a branch on a server

    The filtering, ordering and information shown for each revision can
    be controlled as explained below. By default, all revisions are
    shown sorted (topologically) so that newer revisions appear before
    older ones and descendants always appear before ancestors. If displayed,
    merged revisions are shown indented under the revision in which they
    were merged.

    :Output control:

      The log format controls how information about each revision is
      displayed. The standard log formats are called ``long``, ``short``
      and ``line``. The default is long. See ``brz help log-formats``
      for more details on log formats.

      The following options can be used to control what information is
      displayed::

        -l N        display a maximum of N revisions
        -n N        display N levels of revisions (0 for all, 1 for collapsed)
        -v          display a status summary (delta) for each revision
        -p          display a diff (patch) for each revision
        --show-ids  display revision-ids (and file-ids), not just revnos

      Note that the default number of levels to display is a function of the
      log format. If the -n option is not used, the standard log formats show
      just the top level (mainline).

      Status summaries are shown using status flags like A, M, etc. To see
      the changes explained using words like ``added`` and ``modified``
      instead, use the -vv option.

    :Ordering control:

      To display revisions from oldest to newest, use the --forward option.
      In most cases, using this option will have little impact on the total
      time taken to produce a log, though --forward does not incrementally
      display revisions like --reverse does when it can.

    :Revision filtering:

      The -r option can be used to specify what revision or range of revisions
      to filter against. The various forms are shown below::

        -rX      display revision X
        -rX..    display revision X and later
        -r..Y    display up to and including revision Y
        -rX..Y   display from X to Y inclusive

      See ``brz help revisionspec`` for details on how to specify X and Y.
      Some common examples are given below::

        -r-1                show just the tip
        -r-10..             show the last 10 mainline revisions
        -rsubmit:..         show what's new on this branch
        -rancestor:path..   show changes since the common ancestor of this
                            branch and the one at location path
        -rdate:yesterday..  show changes since yesterday

      When logging a range of revisions using -rX..Y, log starts at
      revision Y and searches back in history through the primary
      ("left-hand") parents until it finds X. When logging just the
      top level (using -n1), an error is reported if X is not found
      along the way. If multi-level logging is used (-n0), X may be
      a nested merge revision and the log will be truncated accordingly.

    :Path filtering:

      If parameters are given and the first one is not a branch, the log
      will be filtered to show only those revisions that changed the
      nominated files or directories.

      Filenames are interpreted within their historical context. To log a
      deleted file, specify a revision range so that the file existed at
      the end or start of the range.

      Historical context is also important when interpreting pathnames of
      renamed files/directories. Consider the following example:

      * revision 1: add tutorial.txt
      * revision 2: modify tutorial.txt
      * revision 3: rename tutorial.txt to guide.txt; add tutorial.txt

      In this case:

      * ``brz log guide.txt`` will log the file added in revision 1

      * ``brz log tutorial.txt`` will log the new file added in revision 3

      * ``brz log -r2 -p tutorial.txt`` will show the changes made to
        the original file in revision 2.

      * ``brz log -r2 -p guide.txt`` will display an error message as there
        was no file called guide.txt in revision 2.

      Renames are always followed by log. By design, there is no need to
      explicitly ask for this (and no way to stop logging a file back
      until it was last renamed).

    :Other filtering:

      The --match option can be used for finding revisions that match a
      regular expression in a commit message, committer, author or bug.
      Specifying the option several times will match any of the supplied
      expressions. --match-author, --match-bugs, --match-committer and
      --match-message can be used to only match a specific field.

    :Tips & tricks:

      GUI tools and IDEs are often better at exploring history than command
      line tools: you may prefer qlog or viz from qbzr or bzr-gtk, the
      bzr-explorer shell, or the Loggerhead web interface.  See the Bazaar
      Plugin Guide <http://doc.bazaar.canonical.com/plugins/en/> and
      <http://wiki.bazaar.canonical.com/IDEIntegration>.

      You may find it useful to add the aliases below to ``breezy.conf``::

        [ALIASES]
        tip = log -r-1
        top = log -l10 --line
        show = log -v -p

      ``brz tip`` will then show the latest revision while ``brz top``
      will show the last 10 mainline revisions. To see the details of a
      particular revision X,  ``brz show -rX``.

      If you are interested in looking deeper into a particular merge X,
      use ``brz log -n0 -rX``.

      ``brz log -v`` on a branch with lots of history is currently
      very slow. A fix for this issue is currently under development.
      With or without that fix, it is recommended that a revision range
      be given when using the -v option.

      brz has a generic full-text matching plugin, brz-search, that can be
      used to find revisions matching user names, commit messages, etc.
      Among other features, this plugin can find all revisions containing
      a list of words but not others.

      When exploring non-mainline history on large projects with deep
      history, the performance of log can be greatly improved by installing
      the historycache plugin. This plugin buffers historical information
      trading disk space for faster speed.
    rmzlog-formats�revisionspec�forwardzShow from oldest to newest.rx�timezonerpz$Show files changed in each revision.rnrcro�cz?Show just the specified revision. See also "help revisionspec".r��
log-format�authorsz8What names to list as authors - first, all or committer.ZAuthors)z
breezy.logZauthor_list_registry�r�r��levelsr�z4Number of levels to display - 0 for all, 1 for flat.r�)rurt�argnamer��messagez=Show revisions whose message matches this regular expression.T)rtr�r��limit�lz*Limit the output to the first N revisions.�	show-diffr�z.Show changes made in each revision as a patch.r��include-mergedz+Show merged revisions like --levels 0 does.�include-merges�&Historical alias for --include-merged.�r�rtzomit-mergesz0Do not report commits with more than one parent.zexclude-common-ancestryzQDisplay only the revisions that are not part of both ancestries (require -rX..Y).�
signaturesz Show digital signature validity.�match�mz6Show revisions whose properties match this expression.�rurtr�z
match-messagez5Show revisions whose message matches this expression.rzmatch-committerz7Show revisions whose committer matches this expression.zmatch-authorz3Show revisions whose authors match this expression.z
match-bugsz0Show revisions whose bugs match this expression.r{N�originalFc.Csddlm}m}m}|rdpd}|
dur,d}
|rR|dusDt|�dkrRt�td���|
rz|	durdd}	nt�td	��d
d���|dur�t|�dkr�t�	��|dur�t�td	��dd
���n|}g}d}|�r:||||j
�\}}}} |D]T\}!}"}#|"du�rt�td�|!��|!dk�rg}�q�n
|�|"�|�p4|#dv}q�nr|du�rnt|�dk�rn|d���rn|d��}$nd}$t
j�|$�\}%}!|%��}|�|���t|||���\}} |���d��r�d}|�r�tj���s�t�d��|�s�d}&nd}&|�s�d}'n|�rd}'nd}'|du�rtj�|�}tjjdd�}(|||j |(|t!�|	|	du|d�})|�oZ|j"j#j$}*t|�dk�px|�px|&�px|*}+i},|�r�||,d<|�r�||,d<|�r�||,d<|�r�||,d<|�r�||,d<t|�dk�r�d}||||| ||
|&|'|+||,||d�
}-|||-��%|)�dS)Nr)�Logger�make_log_request_dict�_get_info_for_log_filesrr�Fr�z8--exclude-common-ancestry requires -r with two revisionsrr�z--levelsz--include-mergedz
--revisionz--changez2Path unknown at end or start of revision range: %sr�)rj�tree-referencer<Zvalidate_signatures_in_logTZfull�partialr�)r�)r�r�Z
to_exact_file�
show_timezoneZdelta_formatr"Zshow_adviceZauthor_list_handlerr$Z	committer�author�bugs)
�	directionZspecific_fileids�start_revision�end_revisionr%Zmessage_search�
delta_type�	diff_typeZ_match_using_deltas�exclude_common_ancestryr-Z	signature�omit_merges)&rOr1r2r3r[rr\rSr�ZRangeInChangeOptionrr��
get_branchr&r'rKrr�r��_get_revision_rangerA�get_config_stack�get�gpg�GPGStrategyZverify_signatures_availableZGpgmeNotInstalled�log_formatter_registry�get_default�ui�
ui_factoryZmake_output_streamr�rr�r,Z
supports_chksZshow).r�rTrrpr�rrcro�
log_formatr"r$r%�	show_diff�include_mergedr r>r,r-Z
match_messageZmatch_committerZmatch_authorZ
match_bugsr?r1r2r3r9Zfile_idsZ
filter_by_dirr�Zfile_info_list�rev1�rev2rVr
rr8r�r<r=Zunencoded_output�lfZpartial_historyZmatch_using_deltasZ
match_dictZrqstr#r#r$r��
s��
�������
��

�

�
�

�����zcmd_log.run)Nr0FFFNNNNNNFNNFFNNNNNF)r�r�r�r�r�r�r
rr��optionr
rrrrr	r�r�rr�r#r#r#r$r�	s��������������������H�rc	Cs�|durd}d}n�t|�dkr2|d�|�}}n�t|�dkr�|d}|d}|��|��krpt�td�|��|jdur�t|dd�}n
|�|�}|jdur�|��\}}t|||�}q�|�|�}nt�td�|��||fS)z�Take the input of a revision option and turn it into a revision range.

    It returns RevisionInfo objects which can be used to obtain the rev_id's
    of the desired revisions. It does some user input validations.
    Nrrr�z:brz %s doesn't accept two revisions in different branches.z*brz %s --revision takes one or two values.)	r[rhr@rr\rS�specr�last_revision_info)	Zrevisionspec_listr3r]rMrNZ
start_specZend_spec�
last_revnoZlast_revision_idr#r#r$rA�s6��


��rAcCs<d}d}|ddur|dj}|ddur4|dj}||fS)Nrr)r�)Zrevision_rangeZrev_id1Zrev_id2r#r#r$�_revision_range_to_revid_range�s

rTF�longcCs |}|rd}|rd}|rd}|S)NrUrq�liner#)rUrqrVr�rJr#r#r$�get_log_format�srWc@s&eZdZdZdZdgZedd��ZdS)�cmd_touching_revisionszqReturn revision-ids which affected a particular file.

    A more user-friendly interface is "brz log FILE".
    TrXcCs�t�|�\}}|���Vt�|jj|j��||�}tt	|��D]\}}}|j
�d||f�q>Wd�n1sr0YdS)Nz%6d %s
)rJrKr�rOZfind_touching_revisionsr3r�r�r�r.r�r�)r�rXrUrVZ
touching_revsr�r�Zwhatr#r#r$r��s
�zcmd_touching_revisions.runN)r�r�r�r�r�r�rr�r#r#r#r$rX�s
rXc
@s�eZdZdZddgZdgZddeddd	d
�eddd
�edddd
�edddd�edddd
�eddded�dddgZe	d#d!d"��Z
dS)$�cmd_lszList files in a tree.
    r��cat�path?rprcr�r�zRecurse into subdirectories.r��	from-rootz/Print paths relative to the root of the branch.rx�unknown�uzPrint unknown files.rvzPrint versioned files.rwrsr�r�zPrint ignored files.r�kzLList entries of a particular kind: file, directory, symlink, tree-reference.r/rrnrjNFc
	Cs�|	r|	dvrt�td���|r0|r0t�td���|p:|p:|}
|||d�}|durXd}n|rjt�td���|}t||�\}}}d}|r�|r�|d}n|dkr�|�d�s�|d}|dus�|dur�td||d	�}d
}t|t��r|���r|j	�
�}|�rd}t	�|�}ttd�|�|�
|���|jd
||d
�D�]�\}}}}|
�sT||�sT�q2|	du�rl||	k�rl�q2|�r�z(|�r�t�||�}n|}t	�||�Wnt	j�y�Y�q2Yn0|�r�t�||�}|��}||}tj��|�r4d||f}|
�r"t|dd�du�r"d||j�d�f}|j�|d�n�|�r�|j�|d�|
�r�t|dd�du�rv|j�|j�d��|j�d�|j��nP|
�r�t|dd�du�r�|j�d�}nd}|j�d||f�n|j�|d��q2dS)N)rrjrr4zinvalid kind specifiedz$Cannot set both --verbose and --null)�I�?rwr<z(cannot specify both --from-root and PATHr1r�r3FTrI)rZfrom_dirr�z%-8s %sr
z%-50s %sr�r�rr�r)rr\rSrk�endswithrdr�rJrLrMrNrRrr�r��
list_filesrOr/Zcheck_path_in_viewrPZkind_characterrHrIZ
clear_termr�r
r�r�r��flush)r�rcrpr��	from_rootr]rvr�rrr�r�rj�allZ	selectionZfs_pathrUr3rVr�rrWrY�fp�fc�fkindr�fullpathZkindchZ	outstringZmy_idr#r#r$r��s���


�
z
cmd_ls.run)NFFFFFFFNFNN)r�r�r�r�r�r�r
rr�rr�r#r#r#r$rY�sD��������rYc@s.eZdZdZdZdgZdgZed	dd��ZdS)
�cmd_unknownszList unknown files.
    Trrjr<cCs2t�|�d��D]}|j�t�|�d�qdSr�)rJrKZunknownsr�r�rOr
)r�rjr�r#r#r$r�Oszcmd_unknowns.runN)r<rr#r#r#r$rlGsrlc@s8eZdZdZgd�ZdgZdeddd�gZdd
d�ZdS)
�
cmd_ignorea�	Ignore specified files or patterns.

    See ``brz help patterns`` for details on the syntax of patterns.

    If a .bzrignore file does not exist, the ignore command
    will create one and add the specified files or patterns to the newly
    created file. The ignore command will also automatically add the
    .bzrignore file to be versioned. Creating a .bzrignore file without
    the use of the ignore command will require an explicit add command.

    To remove patterns from the ignore list, edit the .bzrignore file.
    After adding, editing or deleting that file either indirectly by
    using this command or directly by using an editor, be sure to commit
    it.

    Breezy also supports a global ignore file ~/.config/breezy/ignore. On
    Windows the global ignore file can be found in the application data
    directory as
    C:\Documents and Settings\<user>\Application Data\Breezy\3.0\ignore.
    Global ignores are not touched by this command. The global ignore file
    can be edited directly using an editor.

    Patterns prefixed with '!' are exceptions to ignore patterns and take
    precedence over regular ignores.  Such exceptions are used to specify
    files that should be versioned which would otherwise be ignored.

    Patterns prefixed with '!!' act as regular ignore patterns, but have
    precedence over the '!' exception patterns.

    :Notes:

    * Ignore patterns containing shell wildcards must be quoted from
      the shell on Unix.

    * Ignore patterns starting with "#" act as comments in the ignore file.
      To ignore patterns that begin with that character, use the "RE:" prefix.

    :Examples:
        Ignore the top level Makefile::

            brz ignore ./Makefile

        Ignore .class files in all directories...::

            brz ignore "*.class"

        ...but do not ignore "special.class"::

            brz ignore "!special.class"

        Ignore files whose name begins with the "#" character::

            brz ignore "RE:^#"

        Ignore .o files under the lib directory::

            brz ignore "lib/**/*.o"

        Ignore .o files under the lib directory::

            brz ignore "RE:lib/.*\.o"

        Ignore everything but the "debian" toplevel directory::

            brz ignore "RE:(?!debian/).*"

        Ignore everything except the "local" toplevel directory,
        but always ignore autosave files ending in ~, even under local/::

            brz ignore "*"
            brz ignore "!./local"
            brz ignore "!!*~"
    )r�r�Zpatternsz
name_pattern*rjz
default-rulesz/Display the default ignore rules that brz uses.rxNr<cCs�ddlm}|dur4|jD]}|j�d|�qdS|sFt�td���dd�|D�}d}d}|D]$}tj	�
|�s`|d7}|d	|7}q`|r�td
d|�|}	tj
�|	�t�d��|D]6}
|
ddks�t|
�dkr�|
dd
kr�t�td���q�t�|�\}}|�||�t�	|�}
g}|�|���|��D]:\}}}}t|dd�}|du�r*|
�|��r*|�|��q*t|�dk�r�|j�td�d�|�f�dS)Nr)�ignoresr�z=ignore requires at least one NAME_PATTERN or --default-rules.cSsg|]}t�|��qSr#)�globbingZnormalize_pattern)r�r�r#r#r$r��s�z"cmd_ignore.run.<locals>.<listcomp>r�rz
  %sz Invalid ignore pattern found. %sz!Invalid ignore patterns found. %sr1r�z+NAME_PATTERN should not be an absolute pathr
z�Warning: the following files are version controlled and match your ignore pattern:
%s
These files will continue to be version controlled unless you 'brz remove' them.
r�)r�rnZ
USER_DEFAULTSr�r�rr\rSroZGlobsterZis_pattern_validr�rHrIZ
show_errorZ
lazy_regexZInvalidPatternr[rJrKZtree_ignores_add_patternsr�r�rdr�r-r�r7)r�Zname_pattern_listZ
default_rulesrjrn�patternZbad_patternsZbad_patterns_countr�r�Zname_patternrUrVr�ZmatchesrXrirjr�idr#r#r$r��s`
���

�
��


�zcmd_ignore.run)NNr<r�r#r#r#r$rmUsJ���rmc@s0eZdZdZdZddgZdgZed
dd��Zd	S)�cmd_ignoredz�List ignored files and the patterns that matched them.

    List all the ignored files and the ignore pattern that caused the file to
    be ignored.

    Alternatively, to list just the files::

        brz ls --ignored
    r{r�rrjr<cCs^t�|�d}|�|���|��D]4\}}}}|dkr:q$|�|�}|j�d||f�q$dS)Nrr`r)rJrKr�r�rdrMr�r�)r�rjrUr�Z
file_classrrZpatr#r#r$r��s
zcmd_ignored.runN)r<)	r�r�r�r�r�r�r�rr�r#r#r#r$rr�s
rrc@s.eZdZdZdZdgZdgZed	dd��ZdS)
�cmd_lookup_revisionzaLookup the revision-id from a revision-number

    :Examples:
        brz lookup-revision 33
    Tr�rjr<cCsbzt|�}Wn$ty0t�td�|��Yn0t�|�dj�|�}|j	�
d|�d��dS)Nznot a valid revision-number: %rrr�r�)rrrr\rSrJrKr3�
get_rev_idr�r�r�)r�r�rjr�r#r#r$r��s
����zcmd_lookup_revision.runN)r<)	r�r�r�r�r�r�r�rr�r#r#r#r$rs�srsc
@sheZdZdZdZdZddgZdedded�d	ed
dd�ed
edd�eddd�eddd�gZ	ddd�Z
dS)�
cmd_exporta�Export current or past revision to a destination directory or archive.

    If no revision is specified this exports the last committed revision.

    Format may be an "exporter" name, such as tar, tgz, tbz2.  If none is
    given, try to find the format with the extension. If no extension
    is found exports to a directory (equivalent to --format=dir).

    If root is supplied, it will be used as the root directory inside
    container formats (tar, zip, etc). If it is not supplied it will default
    to the exported filename. The root option has no effect for 'dir' format.

    If branch is omitted then the branch containing the current working
    directory will be used.

    Note: Export of tree with non-ASCII filenames to zip is not supported.

      =================       =========================
      Supported formats       Autodetected by extension
      =================       =========================
         dir                         (none)
         tar                          .tar
         tbz2                    .tar.bz2, .tbz2
         tgz                      .tar.gz, .tgz
         zip                          .zip
      =================       =========================
    r�r1zbranch_or_subdir?rjr�zType of file to export to.rrc�filtersz4Apply content filters to export the convenient form.rxr/z4Name of the root directory inside the exported file.r�zper-file-timestampszTSet modification time of files to that of the last revision in which it was changed.�uncommittedzGExport the working tree contents rather than that of the last revision.NFr<c

Cs ddlm}
m}m}|dur |	}tj�|�\}
}}|
durH|�|
���|rh|
durbt�	t
d���|
}ntd|||
d�}|dur�||�}|dur�||�}|s�t��}nd}|r�ddl
m}|||j�}z|
||||||d�Wn<tj�y}z t�	t
d	�|j��WYd}~n
d}~00dS)
Nr)�export�guess_format�
get_root_namez%--uncommitted requires a working treerx�r3rUr��ContentFilterTree)�per_file_timestampszUnsupported export format: %s)rxryrzr&r'rir�r�rr\rSrd�timeZbreezy.filter_treer}�_content_filter_stackZNoSuchExportFormatr�)r�r1Zbranch_or_subdirrcr�r/rvr~rwrjrxryrzrUr��subdirZexport_treeZforce_mtimer}r�r#r#r$r�8
sL�
��
��
�zcmd_export.run)NNNNFFFr<)r�r�r�r�r�r�r�r
rr�r�r#r#r#r$ru
s4�
�����ruc@sReZdZdZdgZdeddd�eddd�d	gZd
gZdZe	ddd��Z
dd�ZdS)�cmd_catz�Write the contents of a file as of a given revision to standard output.

    If no revision is nominated, the last revision is used.

    Note: Take care to redirect standard output when using this command on a
    binary file.
    rrjzname-from-revisionzThe path name in the old tree.rxrvz6Apply content filters to display the convenience form.rcrXr�NFc		CsV|dur"t|�dkr"t�td���t||�\}}}|�|���|�|||||||�S)Nrz7brz cat --revision takes exactly one revision specifier)r[rr\rSrkr�r�r*)	r�rXrc�name_from_revisionrvrjrUr3rVr#r#r$r�{
s��zcmd_cat.runcCsddl}|dur|��}td||d�}	|�|	���|rb|	�|�s\t�td��	||	�
����|}
n^zt�||	|�}
Wntj
y�d}
Yn0|
dur�|	�|�s�t�td��	||	�
����n|}
|r�ddlm}||	|	j�}|�|
�}
n
|	�|
�}
|�|
|j�|��dS)NrrZrbz${0!r} is not present in revision {1}rr|)�shutilr`rdr�r�r�rr\rSr�Zget_revision_idZ	_mod_treeZfind_previous_pathr�filter_treer}r�Zget_fileZcopyfileobjr�r�)r�rUr�rVrXrcr�Zfilteredr�rbZ
rev_tree_pathr}r�Zfileobjr#r#r$r*�
sH
���

���
zcmd_cat._run)NFFN)r�r�r�r�r�r
r�r�r�rr�r*r#r#r#r$r�g
s �
��r�c@s eZdZdZdZedd��ZdS)�cmd_local_time_offsetz2Show the offset in seconds from GMT to local time.TcCs|j�dt���dS�Nr�)r�r�rO�local_time_offset�r�r#r#r$r��
szcmd_local_time_offset.runN�r�r�r�r�r�rr�r#r#r#r$r��
sr�c@s�eZdZdZgd�ZdgZededdd�eded	d
d�dedd
d�ededddd�eddd�ededd�ededd�ededd�ededd�edd d�ed!d"d#d$�ed%d&d�g
Z	d'd(gZ
d)d*�Zd/d-d.�Zd+S)0�
cmd_commita,	Commit changes into a new revision.

    An explanatory message needs to be given for each commit. This is
    often done by using the --message option (getting the message from the
    command line) or by using the --file option (getting the message from
    a file). If neither of these options is given, an editor is opened for
    the user to enter the message. To see the changed files in the
    boilerplate text loaded into the editor, use the --show-diff option.

    By default, the entire tree is committed and the person doing the
    commit is assumed to be the author. These defaults can be overridden
    as explained below.

    :Selective commits:

      If selected files are specified, only changes to those files are
      committed.  If a directory is specified then the directory and
      everything within it is committed.

      When excludes are given, they take precedence over selected files.
      For example, to commit only changes within foo, but not changes
      within foo/bar::

        brz commit foo -x foo/bar

      A selective commit after a merge is not yet supported.

    :Custom authors:

      If the author of the change is not the same person as the committer,
      you can specify the author's name using the --author option. The
      name should be in the same format as a committer-id, e.g.
      "John Doe <jdoe@example.com>". If there is more than one author of
      the change you can specify the option multiple times, once for each
      author.

    :Checks:

      A common mistake is to forget to add a new file or directory before
      running the commit command. The --strict option checks for unknown
      files and aborts the commit if any are found. More advanced pre-commit
      checks can be implemented by defining hooks. See ``brz help hooks``
      for details.

    :Things to note:

      If you accidentally commit the wrong changes or make a spelling
      mistake in the commit message say, you can use the uncommit command
      to undo it. See ``brz help uncommit`` for details.

      Hooks can also be configured to run after a commit. This allows you
      to trigger updates to external systems like bug trackers. The --fixes
      option can be used to record the association between a revision and
      one or more bugs. See ``brz help bugs`` for details.
    )r�r8�hooks�uncommitz	selected*�exclude�xz-Do not consider changes made to a given path.r�r$r.z Description of the new revision.rp�	unchangedz#Commit even if nothing has changed.rxrr�Zmsgfilez#Take commit message from this file.)r�rur#rtr�z@Refuse to commit if there are unknown files in the working tree.zcommit-timezVManually set a commit time using commit date format, e.g. '2009-10-10 08:00:00 +0100'.r�r8z-Link to a related bug. (see "brz help bugs").�fixeszAMark a bug as being fixed by this revision (see "brz help bugs").r7z<Set the author's name, if it's different from the committer.r8z�Perform a local commit in a bound branch.  Local commits are not pushed to the master branch until a normal commit is performed.r'r�z_When no message is supplied, show the diff along with the status summary in the message editor.r�r_zjWhen committing to a foreign version control system do not push data that can not be natively represented.ZciZcheckinccsd}|D]�}|�d�}t|�dkrd|dur<|��}|�d�}|durVt�td�|��|}|d}	n(t|�dkr�t�td�|��n|\}}	zt�|||	�|fVWqtj	y�t�td�|��Yqtj
�y}
z t�td	�|
f��WYd}
~
qd}
~
00qdS)
Nr�r�
bugtrackerz�No tracker specified for bug %s. Use the form 'tracker:id' or specify a default bug tracker using the `bugtracker` option.
See "brz help bugs" for more information on this feature. Commit refused.rr�z~Invalid bug %s. Must be in the form of 'tracker:id'. See "brz help bugs" for more information on this feature.
Commit refused.z$Unrecognized bug %s. Commit refused.z%s
Commit refused.)rr[rBrCrr\rSr�Zget_bug_urlZUnknownBugTrackerAbbreviationZMalformedBugIdentifier)r�r8r3r�Zdefault_bugtrackerZbug�tokensZ
branch_config�tagZbug_idr�r#r#r$�_iter_bug_urls$sL
���
����
��zcmd_commit._iter_bug_urlsNFcs�ddl}ddlm}ddlm}m}ddlm�m�m	�m
�d}}|
dur�zt�|
�\}}Wn:t
y�}z"t�tdt|����WYd}~n
d}~00i}t���\���dgkr�g�|dur�g}|	dur�g}	t�|�|�|	�jtj�|�|�jtj���}|�r||d<|�r(�j���s(t����du�r�zt���}Wnt�yXd	}Yn0|�rxd
d�i}tj �!|�d�v�r���"d
d����"dd����r�t�td������������f	dd�}��s�d�z.�j|�|||d|||
||��#|�|d�
Wn�|�y$t�td���Ynt|�yDt�td���YnT|�ydt�td���Yn4tj$�y�}ztd�|_%�WYd}~n
d}~00dS)Nrr)�PointlessCommit)�ConflictsInTree�StrictCommitFailed)�edit_commit_message_encoded� generate_commit_message_template�$make_commit_message_template_encoded�set_commit_messagezCould not parse --commit-time: r�r8FzfThe commit message is a file name: "%(f)s".
(use --file "%(f)s" to take commit message from that file)r��
z
r�z)please specify either --message or --filecs��rBt�d��"}|���t���}Wd�q�1s60Yn��durP�}nz����t��d�}�|�}|dur��|�}|dur�|�t���}�||d�}|dur�t�td���|dkr�t�td���|S)zCallback to get commit message�rbN)r|Zoutput_encoding)�
start_messagez?please specify a commit message with either --message or --filer�z�Empty commit message specified. Please specify a commit message with either --message or --file or leave a blank message with --message "".)	r(rcr�rOZget_user_encodingr�rr\rS)Z
commit_objr�Z
my_message�textr��	r�rr�r�r$�
selected_listr�rKrUr#r$�get_message�s42����z#cmd_commit.run.<locals>.get_message)
Zmessage_callbackr�Zallow_pointlessr�r8�reporterrpZrevpropsr �	timestamprr�r_zqNo changes to commit. Please 'brz add' the files you want to commit, or use --unchanged to force an empty commit.z`Conflicts detected in working tree.  Use "brz conflicts" to list, "brz resolve FILE" to resolve.zCCommit refused because there are unknown files in the working tree.z~
To commit to master branch, run update and then commit.
You can also pass --local to commit to continue working disconnected.)&�	itertools�commitr�rr�r�Z	msgeditorr�r�r�r�r�Zparse_patch_daterr\rSr�rJr�r�Zencode_fixes_bug_urls�chainr�r3ZRELATEDZFIXEDr rDrOr-�UnicodeErrorrHrIZshow_warningr{Zsafe_relpath_filesZBoundBranchOutOfDateZ
extra_help)r�r$rrpr�r�r�r8r�r8r7rKr�Zcommit_timer_r�r�r�r�Zcommit_stamp�offsetr�Z
propertiesZbug_propertyZfile_existsZwarning_msgr�r#r�r$r�Gs�
�
��

��
�'�

zcmd_commit.run)NNFNFFFNNNFNNF)
r�r�r�r�r�r�r	rr
r�r�r�r�r#r#r#r$r��
sn8�������������,#�r�c@sJeZdZdZdgZdgZdeddd�edd	d�ed
dd�gZddd�ZdS)�	cmd_checkaValidate working tree structure, branch consistency and repository history.

    This command checks various invariants about branch and repository storage
    to detect data corruption or brz bugs.

    The working tree and branch checks will only give output if a problem is
    detected. The output fields of the repository check are:

    revisions
        This is just the number of revisions checked.  It doesn't
        indicate a problem.

    versionedfiles
        This is just the number of versionedfiles checked.  It
        doesn't indicate a problem.

    unreferenced ancestors
        Texts that are ancestors of other texts, but
        are not properly referenced by the revision ancestry.  This is a
        subtle problem that Breezy can work around.

    unique file texts
        This is the total number of unique file contents
        seen in the checked revisions.  It does not indicate a problem.

    repeated file texts
        This is the total number of repeated texts seen
        in the checked revisions.  Texts can be repeated when their file
        entries are modified, but the file contents are not.  It does not
        indicate a problem.

    If no restrictions are specified, all data that is found at the given
    location will be checked.

    :Examples:

        Check the tree and branch at 'foo'::

            brz check --tree --branch foo

        Check only the repository at 'bar'::

            brz check --repo bar

        Check everything at 'baz'::

            brz check baz
    r�r[rpr3z2Check the branch related to the current directory.rxrGz6Check the repository related to the current directory.rUz8Check the working tree related to the current directory.NFcCsFddlm}|durd}|s0|s0|s0d}}}||||||d�dS)Nr)�
check_dwimr<T)Z	do_branchZdo_repoZdo_tree)r�r�)r�r�rpr3rGrUr�r#r#r$r�sz
cmd_check.run)NFFFFr�r#r#r#r$r��s1


��r�c@sVeZdZdZgd�ZdgZeddddd�d	d
d�edd
d�eddd�gZddd�Z	dS)�cmd_upgradeaJUpgrade a repository, branch or working tree to a newer format.

    When the default format has changed after a major new release of
    Bazaar/Breezy, you may be informed during certain operations that you
    should upgrade. Upgrading to a newer format may improve performance
    or make new features available. It may however limit interoperability
    with older repositories or with older versions of Bazaar or Breezy.

    If you wish to upgrade to a particular format rather than the
    current default, that can be specified using the --format option.
    As a consequence, you can use the upgrade command this way to
    "downgrade" to an earlier format, though some conversions are
    a one way process (e.g. changing from the 1.x default to the
    2.x default) so downgrading is not always possible.

    A backup.bzr.~#~ directory is created at the start of the conversion
    process (where # is a number). By default, this is left there on
    completion. If the conversion fails, delete the new .bzr directory
    and rename this one back in its place. Use the --clean option to ask
    for the backup.bzr directory to be removed on successful conversion.
    Alternatively, you can delete it by hand if everything looks good
    afterwards.

    If the location given is a shared repository, dependent branches
    are also converted provided the repository converts successfully.
    If the conversion of a branch fails, remaining branches are still
    tried.

    For more information on upgrades, see the Breezy Upgrade Guide,
    https://www.breezy-vcs.org/doc/en/upgrade-guide/.
    )r�r�Zformatszurl?r�zBUpgrade to a specific format.  See "brz help formats" for details.r�cCstj�|�Sr�r�r{r#r#r$r�As�zcmd_upgrade.<lambda>Tr�r��cleanz.Remove the backup.bzr directory if successful.rxr�r�r<NFcCs>ddlm}|||||d�}|r:t|�dkr6|d�ndSdS)Nr)�upgrade)Zclean_upr�r�)r�r[)r�r�r�r�r�r��
exceptionsr#r#r$r�Js
zcmd_upgrade.run)r<NFF)
r�r�r�r�r�r�rr
r�r�r#r#r#r$r�s" ����r�c@sBeZdZdZdeddd�eddd�gZdgZd	Zeddd
��Z	dS)�
cmd_whoamiz�Show or set brz user id.

    :Examples:
        Show the email of the current user::

            brz whoami --email

        Set the current user::

            brz whoami "Frank Chu <fchu@example.com>"
    rj�emailzDisplay email address only.rxr3z8Set identity for the current branch instead of globally.�name?r{FNcCs*|dur�|durFzt�d�d��}WqTtjyBt��}YqT0nt�|���}|�d�}|rz|j	�
t�|�d�n|j	�
|d�dS|r�t�t
d���zt�|�Wntjy�td|�Yn0|�r|dur�t�d�d��}n t�|�}|�|���|��}nt��}|�d|�dS)Nr<rr�r�z5--email can only be used to display existing identityzV"%s" does not seem to contain an email address.  This is allowed, but not recommended.)r:rKrBrr�_mod_configZGlobalStackr(rCr�r�Zextract_email_addressr\rSZNoEmailInUsernamerr�rC�set)r�r�r3rArjrZidentityr�r#r#r$r�ks<
��


zcmd_whoami.run)FFNN�
r�r�r�r�r
r�r�r�rr�r#r#r#r$r�Us���r�c@s8eZdZdZdgZdgZdgZddd�Zed	d
��Z	dS)�cmd_nickaCPrint or set the branch nickname.

    If unset, the colocated branch name is used for colocated branches, and
    the branch directory name is used for other branches.  To print the
    current nickname, execute with no argument.

    Bound branches use the nickname of its master branch unless it is set
    locally.
    r�z	nickname?rjNr<cCs,t�|�d}|dur"|�|�n||_dS)Nr)r:rK�printme�nick)r�Znicknamerjr3r#r#r$r��szcmd_nick.runcCs|j�d|j�dSr�)r�r�r�)r�r3r#r#r$r��szcmd_nick.printme)Nr<)
r�r�r�r�r�r�r�r�rr�r#r#r#r$r��s

r�c@sVeZdZdZdgZeddd�gZddd	�Zd
d�Ze	dd
��Z
e	dd��Zdd�ZdS)�	cmd_aliasaQSet/unset and display aliases.

    :Examples:
        Show the current aliases::

            brz alias

        Show the alias specified for 'll'::

            brz alias ll

        Set an alias for 'll'::

            brz alias ll="log --line -r-10..-1"

        To remove an alias for 'll'::

            brz alias --remove ll

    r�r�zRemove the alias.rxNFcCsd|r|�|�nP|dur"|��n>|�d�}|dkr@|�|�n |�|d|�||dd��dS)N�=rr)�remove_alias�
print_aliases�find�print_alias�	set_alias)r�rAr�Z	equal_posr#r#r$r��s

z
cmd_alias.runcCs,|durt�td���t��}|�|�dS)Nz.brz alias --remove expects an alias to remove.)rr\rSr��GlobalConfigZunset_alias)r��
alias_namerr#r#r$r��s�zcmd_alias.remove_aliascCs:t����}tt|��D]\}}|j�d||f�qdS)z:Print out the defined aliases in a similar format to bash.�brz alias %s="%s"
N)r�r�Zget_aliasesr�rr�r�)r�r��key�valuer#r#r$r��szcmd_alias.print_aliasescCsLddlm}||�}|dur.|j�d|�n|j�d|d�|�f�dS)Nr)�	get_aliaszbrz alias: %s: not found
r�r�)�commandsr�r�r�r7)r�r�r��aliasr#r#r$r��s�zcmd_alias.print_aliascCst��}|�||�dS)z$Save the alias in the global config.N)r�r�r�)r�r�Z
alias_commandrr#r#r$r��szcmd_alias.set_alias)NF)
r�r�r�r�r�r
r�r�r�rr�r�r�r#r#r#r$r��s
�
	

	r�c@seZdZdZdd�ZdZdgZdeddd	d
�edded
�edddd�eddd�eddd�edddd
�eddd�eddddd�ed e	d!d"d#�e
d$e	d%d&d'd(�ed)d*d�ed+d,d�ed-d.d�ed/e	d0d1d#�e
d2e	d3d4d5�e
d6e	d7d8d9d:d;�ed<d=d�gZd>Zd?d@�Z
dFdBdC�ZdDdE�ZdAS)G�cmd_selftestaRun internal test suite.

    If arguments are given, they are regular expressions that say which tests
    should run.  Tests matching any expression are run, and other tests are
    not run.

    Alternatively if --first is given, matching tests are run first and then
    all other tests are run.  This is useful if you have been working in a
    particular area, but want to make sure nothing else was broken.

    If --exclude is given, tests that match that regular expression are
    excluded, regardless of whether they match --first or not.

    To help catch accidential dependencies between tests, the --randomize
    option is useful. In most cases, the argument used is the word 'now'.
    Note that the seed used for the random number generator is displayed
    when this option is used. The seed can be explicitly passed as the
    argument to this option if required. This enables reproduction of the
    actual ordering used if and when an order sensitive problem is encountered.

    If --list-only is given, the tests that would be run are listed. This is
    useful when combined with --first, --exclude and/or --randomize to
    understand their impact. The test harness reports "Listed nn tests in ..."
    instead of "Ran nn tests in ..." when list mode is enabled.

    If the global option '--no-plugins' is given, plugins are not loaded
    before running the selftests.  This has two effects: features provided or
    modified by plugins will not be tested, and tests provided by plugins will
    not be run.

    Tests that need working space on disk use a common temporary directory,
    typically inside $TMPDIR or /tmp.

    If you set BRZ_TEST_PDB=1 when running selftest, failing tests will drop
    into a pdb postmortem session.

    The --coverage=DIRNAME global option produces a report with covered code
    indicated.

    :Examples:
        Run only tests relating to 'ignore'::

            brz selftest ignore

        Disable plugins and list tests as they're run::

            brz --no-plugins selftest -v
    cCsd|dkrddlm}|jS|dkr4ddlm}tjS|dkrNddlm}|jSd|}t�|��dS)	z'Parse and return a transport specifier.Zsftpr)�	stub_sftp�memory)�test_serverZfakenfsz6No known transport type %s. Supported types are: sftp
N)	�testsr�ZSFTPAbsoluteServerr�r�ZMemoryServerZ
FakeNFSServerrr\)�
typestringr�r�r�r#r#r$�get_transport_type+s�zcmd_selftest.get_transport_typeTz
testspecs*rp�onezStop when one test fails.r�rsr�z?Use a different transport by default throughout the test suite.r�	benchmarkz)Run the benchmarks rather than selftests.r�zlsprof-timedz8Generate lsprof output for benchmarked sections of code.rxzlsprof-testsz%Generate lsprof output for each test.�firstz-Run all tests, but run specified tests first.r�z	list-onlyz'List the tests instead of running them.�parallelzRun the test suite in parallel.)zbreezy.testsZparallel_registryF�rtr�r��	randomizeZSEEDzPRandomize the order of tests using the given seed or "now" for the current time.�r�r#rtr�ZPATTERNr�z1Exclude tests that match this regular expression.�r�r#rurt�subunit1z$Output test progress via subunit v1.�subunit2z$Output test progress via subunit v2.r�z/Fail on missing dependencies or known failures.z	load-listZTESTLISTFILEz%Load a test id list from a text file.�	debugflag�EzTurn on a selftest debug flag.r�z
starting-withZTESTID�
starting_withrz)Load only the tests starting with TESTID.)r�r#Z
param_namerurt�synczGBy default we disable fsync and fdatasync while running the test suite.r{cCst�|�i|_dSr�)r�__init__�additional_selftest_argsr�r#r#r$r�ss
zcmd_selftest.__init__NcCs�tjddkrt��zddlm}WntyBt�d��Yn0|durXd�	|�}nd}|r�zddlm
}Wn ty�t�td	���Yn0||jd
<tj
dkr�ttjdd�dur�ddl}|�tj��tj�|�rzdd
lm}Wn"t�yt�td���Yn0||jd
<|�r2|j�dg��|�|�rFt�td���d}|
�sVd}ndd�	|
�d}|�sv|��||||||||||	||||
|d�}|�|j�tjdd�}z|jfi|��}W|�n|�0t|�S)Nrr�r)r�zYtests not available. Install the python-breezy.tests package to run the breezy testsuite.�|z.*)�SubUnitBzrRunnerv1zFsubunit not available. subunit needs to be installed to use --subunit.Zrunner_classZwin32�fileno)�SubUnitBzrRunnerv2zGsubunit not available. subunit needs to be installed to use --subunit2.Zsuite_decoratorszI--benchmark is no longer supported from brz 2.2; use bzr-usertest instead�(�))rprpZstop_on_failurer��test_suite_factory�lsprof_timed�lsprof_testsZmatching_tests_first�	list_onlyZrandom_seed�exclude_patternr��	load_listZdebug_flagsr�F)�override)�sys�version_inforZdisallow_proxyingr�r��ImportErrorrr\r7r�rSr��platformr��stdout�msvcrtZsetmoder�r�ZO_BINARYr��
setdefaultr��_disable_fsyncr4Zsymbol_versioningZactivate_deprecation_warningsZselftestr)r�Ztestspecs_listrpr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rpr�r�r�r�r�Zselftest_kwargsZcleanuprWr#r#r$r�ws��

��
�����zcmd_selftest.runcCsHttdd�|_|jdur"dd�t_ttdd�|_|jdurDdd�t_dS)z1Change the 'os' functionality to not synchronize.�fsyncNcSsdSr�r#�Zfiledesr#r#r$r��r�z-cmd_selftest._disable_fsync.<locals>.<lambda>�	fdatasynccSsdSr�r#r�r#r#r$r��r�)r�r�Z_orig_fsyncr�Z_orig_fdatasyncr�r�r#r#r$r��s


zcmd_selftest._disable_fsync)NFFNNNFFNNFNNNFFNFF)r�r�r�r�r�r�r�r
rrr	r�r�r�r�r�r#r#r#r$r��s�3������������
�����5�
ar�c@s0eZdZdZdZeddd�gZed
dd��Zd	S)�cmd_versionzShow version of brz.r{rqzPrint just the version number.rxFcCs4ddlm}|r$|j�tjd�n||jd�dS)Nr)�show_versionr�)r�)�versionr�r�r�r�Zversion_string)r�rqr�r#r#r$r��szcmd_version.runN)F)	r�r�r�r�r�r
r�rr�r#r#r#r$r��s
�r�c@s eZdZdZdZedd��ZdS)�	cmd_rockszStatement of optimism.TcCs|j�td��dS)NzIt sure does!
)r�r�rSr�r#r#r$r��sz
cmd_rocks.runNr�r#r#r#r$r��sr�c@s(eZdZdZddgZdZedd��ZdS)�cmd_find_merge_basez8Find and print a base revision for merging two branches.r3�otherTc
Cs�ddlm}t�|�d}t�|�d}|�|���|�|���||���}||���}|j�|j�}|�	||�}	|j
�td�|	�
d��dS)Nr)r�rzmerge base is revision %s
r�)rcr�r:rKr�r�r�r�r�Zfind_unique_lcar�r�rSr�)
r�r3r�r�Zbranch1Zbranch2Zlast1Zlast2r��base_rev_idr#r#r$r�s�zcmd_find_merge_base.runNrr#r#r#r$r��s
r�c@s�eZdZdZdZgd�ZdgZddeddd	�d
dded
dd	�eddd	�eddd	�eddd	�eddd	�edddd�gZ	d1dd�Z
dd �Zd!d"�Zd#d$�Z
d%d&�Zd'd(�Zd)d*�Zd+d,�Zd2d-d.�Zd/d0�ZdS)3�	cmd_mergeaAPerform a three-way merge.

    The source of the merge can be specified either in the form of a branch,
    or in the form of a path to a file containing a merge directive generated
    with brz send. If neither is specified, the default is the upstream branch
    or the branch most recently merged using --remember.  The source of the
    merge may also be specified in the form of a path to a file in another
    branch:  in this case, only the modifications to that file are merged into
    the current working tree.

    When merging from a branch, by default brz will try to merge in all new
    work from the other branch, automatically determining an appropriate base
    revision.  If this fails, you may need to give an explicit base.

    To pick a different ending revision, pass "--revision OTHER".  brz will
    try to merge in all new work up to and including revision OTHER.

    If you specify two values, "--revision BASE..OTHER", only revisions BASE
    through OTHER, excluding BASE but including OTHER, will be merged.  If this
    causes some revisions to be skipped, i.e. if the destination branch does
    not already contain revision BASE, such a merge is commonly referred to as
    a "cherrypick". Unlike a normal merge, Breezy does not currently track
    cherrypicks. The changes look like a normal commit, and the history of the
    changes from the other branch is not stored in the commit.

    Revision numbers are always relative to the source branch.

    Merge will do its best to combine the changes in two branches, but there
    are some kinds of problems only a human can fix.  When it encounters those,
    it will mark a conflict.  A conflict means that you need to fix something,
    before you can commit.

    Use brz resolve when you have fixed a problem.  See also brz conflicts.

    If there is no default branch set, the first merge will set it (use
    --no-remember to avoid setting it). After that, you can omit the branch
    to use the default.  To change the default, use --remember. The value will
    only be saved if the remote location can be accessed.

    The results of the merge are placed into the destination working
    directory, where they can be reviewed (with brz diff), tested, and then
    committed to record the result of the merge.

    merge refuses to run if there are any uncommitted changes, unless
    --force is given.  If --force is given, then the changes from the source
    will be merged with the current working tree, including any uncommitted
    changes in the tree.  The --force option can also be used to create a
    merge revision which has more than two parents.

    If one would like to merge changes from the working tree of the other
    branch without merging any committed revisions, the --uncommitted option
    can be given.

    To select only some changes to merge, use "merge -i", which will prompt
    you to apply each diff hunk and file change, similar to "shelve".

    :Examples:
        To merge all new revisions from brz.dev::

            brz merge ../brz.dev

        To merge changes up to and including revision 82 from brz.dev::

            brz merge -r 82 ../brz.dev

        To merge the changes introduced by 82, without previous changes::

            brz merge -r 81..82 ../brz.dev

        To apply a merge directive contained in /tmp/merge::

            brz merge /tmp/merge

        To create a merge revision with three parents from two branches
        feature1a and feature1b:

            brz merge ../feature1a
            brz merge ../feature1b --force
            brz commit -m 'revision with three parents'
    r�)r4Zremerger~r5r�rorcr�z;Merge even if the destination tree has uncommitted changes.rx�
merge-type�	reprocessr6r9r:rwzIApply uncommitted changes from a working copy, instead of branch changes.r?z�If the destination is already completely merged into the source, pull from the source rather than merging.  When this happens, you do not need to commit the result.rjzKBranch to merge into, rather than the one containing the working directory.�previewz-Instead of merging, show a diff of the merge.�interactivezSelect changes interactively.r�rsNFc
Cs�|durtj}|
durd}
g}
d}d}d}t�|
�d}|j��tjkrVt�	t
d���|sl|��rlt�|��t
|�}tj|j|d�}tj��}|�|�|�|���|du�rztj||
d�}Wntjy�d}Yn>0|r�t�	t
d���|du�rt�	t
d	���tj�||�\}}|du�r`|�r`|du�rNt|�dk�rNt�	t
d
���|�||d�}d}|du�r�|�|||||
d�\}}||_||_||_ |�!|�|j"|j#k�r|j#du�r|j$�r�|j%�&|j$d��s�t't
d�t(|��t�)|g��t't
d
��dS|	�r\|�s\|j$du�r*t�	t
d���|j"|��k�r\|�*|j+d|j#�}|�,|j-�dS|j.du�rvt�	t
d���|�r�|�/|�S|�r�|�0|�S|�1||||�SdS)Nr<TZinapplicablerz_Merging into empty branches not currently supported, https://bugs.launchpad.net/bzr/+bug/308562rArz:Cannot use --uncommitted with bundles or merge directives.r@z9Cannot use --uncommitted and --revision at the same time.Fzmerger: zNothing to do.zCannot pull individual fileszAThis branch has no commits. (perhaps you would prefer 'brz pull'))2�
_mod_merge�Merge3MergerrJrKr3r�r�r�rr\rSr�r�rhrKrLrMrHrIZnested_progress_barr�rCrErFrG�MergerZfrom_mergeabler[�get_merger_from_uncommitted�_get_merger_from_branch�
merge_typerrB�sanity_check_mergerr�Zother_rev_id�interesting_files�
other_treerrr�ZPathsDoNotExistr?�other_branchrNr�Z
this_basis�_do_preview�_do_interactive�	_do_merge)r�r8rcr�r
rBrr6rwr?rjrrr�merger�
allow_pendingrUrUrfrV�pbrQrWr#r#r$r��s�
�


�


��

�
���
��


�z
cmd_merge.runcCs&|��}|��}|�|�|��}|Sr�)Zmake_mergerZmake_preview_transformr�Zget_preview_tree)r�rZtree_mergerZtt�result_treer#r#r$�_get_preview�s

zcmd_merge._get_previewcCs:ddlm}|�|�}t��}||j||jdd|d�dS)Nr)r�r�)rrr)r|r�rrOr�	this_treer�)r�rr�rrr#r#r$r�s
�zcmd_merge._do_previewcCs>||_|��}|r|��|dkr*td�|dkr6dSdSdS)N�failedz$Preview patch does not match changesrr)rV�do_mergeZset_pendingr)r�rrVrrUZconflict_countr#r#r$r�szcmd_merge._do_mergecCsfddlm}|�|�}tjj��}|j|j|d|�	�||j
�d�}z|��W|��n
|��0dS)z�Perform an interactive merge.

        This works by generating a preview tree of the merge, then using
        Shelver to selectively remove the differences between the working tree
        and the preview tree.
        r)�shelf_uiT)�destroyr�Zdiff_writerN)
r�rrr�rP�diff_writer_registryrC�ShelverrZ
ApplyReporterr�r��finalize)r�rrr�writer�shelverr#r#r$rs
�
zcmd_merge._do_interactivecCs�|jr&|jtjur&t�td�|j��|jdurH|jr>d|_n
|jj|_|jrj|jjsjt�td�|j��|jr�|jr�t�td���|jj	r�t
|jdd�r�t
|jdd�r�|j
dur�t
|j
dd�s�t�td���dS)Nz2Show-base is not supported for this merge type. %sFz6Conflict reduction is not supported for merge type %s.z+Cannot do conflict reduction and show base.Zplan_file_mergezGPlan file merge unsupported: Merge type incompatible with tree formats.)rBr
rrrr\rSrZsupports_reprocessZrequires_file_merge_planr�rr
r�)r�rr#r#r$rs8
�
�


������zcmd_merge.sanity_check_mergercCsF|�|||d�\}}|dur>t|�dkr>|�|||d�\}	}
n|}	t�||�\}}|	|kr`|}
nt�|	|�\}
}d}d}|dur�t|�dkr�|d�|�}t|�dkr�|d�|
�}|dur�t�|���}|dur�|s�|dur�|j�	�dur�|j�
|j�|jj
|jjdd�tj�|||||
�}|dk�r:d	}|g|_nd}||fS)
zAProduce a merger from a location, assuming it refers to a branch.rNr�rrT)Z
ignore_masterr�F)�_select_branch_locationr[r:rKr�r�r�r�r3�get_submit_branch�set_submit_branchrr>r�rr�from_revision_idsr)r�rUr8rcr6rrZ	other_loc�
user_locationZbase_locrkr�
other_pathr�r�Zother_revision_idrTrrr#r#r$r	.sX��
�������

z!cmd_merge._get_merger_from_branchcCsB|�||�d}t�|�\}}tj�|||�}|dkr>|g|_|S)z�Get a merger for uncommitted changes.

        :param tree: The tree the merger should apply to.
        :param location: The location containing uncommitted changes.
        :param pb: The progress bar to use for showing progress.
        rr�)r!rJrKrrZfrom_uncommittedr)r�rUr8rr
r&rr#r#r$rbsz%cmd_merge.get_merger_from_uncommittedcCsZ|dur8|dur8||dur8||��}|dur8||fS|durN|�|d�}n|}||fS)aSelect a branch location, according to possible inputs.

        If provided, branches from ``revision`` are preferred.  (Both
        ``revision`` and ``index`` must be supplied.)

        Otherwise, the ``location`` parameter is used.  If it is None, then the
        ``submit`` or ``parent`` location is used, and a note is printed.

        :param tree: The working tree to select a branch for merging into
        :param location: The location entered by the user
        :param revision: The revision parameter to the command
        :param index: The index to use for the revision parameter.  Negative
            indices are permitted.
        :return: (selected_location, user_location).  The default location
            will be the user-entered location.
        NzMerging from)r@�_get_remembered)r�rUr%rc�indexr3r8r#r#r$r!ps
�z!cmd_merge._select_branch_locationcCsj|j��}d}|dur$|j��}d}td|�|durDt�td���t�|d�}t	td��
|||��|S)zlUse tree.branch's parent if none was supplied.

        Report if the remembered location was used.
        ZsubmitNrlz%sz#No location specified or rememberedr�z{0} remembered {1} location {2})r3r"rHrrr\rSr5rIrr�)r�rUZverb_stringZstored_locationZstored_location_typerSr#r#r$r'�s


��zcmd_merge._get_remembered)NNFNFNNFFNFF)NN)r�r�r�r�r�r�r�r
rr�r�rrrrrr	rr!r'r#r#r#r$rsRQ�


�
���
a4�
rc@s2eZdZdZdgZddeddd�gZdd
d�ZdS)
�cmd_remergeaSRedo a merge.

    Use this if you want to try a different merge technique while resolving
    conflicts.  Some merge techniques are better than others, and remerge
    lets you try different ones on different files.

    The options for remerge have the same meaning and defaults as the ones for
    merge.  The difference is that remerge can (only) be run when there is a
    pending merge, and it lets you specify particular files.

    :Examples:
        Re-do the merge of all conflicted files, and show the base text in
        conflict regions, in addition to the usual THIS and OTHER texts::

            brz remerge --show-base

        Re-do the merge of "foobar", using the weave merge algorithm, with
        additional processing to reduce the size of conflict regions::

            brz remerge --merge-type weave --reprocess foobar
    rmrrr9r:rxNFc	s�ddlm}|durtj}t�|�\}}|�|���|��}t	|�dkrXt
�td���d}g}	|��}
|dur�t
�}|D]T}|�|�s�t
�|��|�|�|�|�dkr�qz|j|gd�D]\}}
|�|�q�qz|
�||�d}	nd��fd	d
�|
D�}t�||��|�|�t|	��|du�r&|}|D]0}z||�|��Wnt
j�yVYn0�q*|�|dd��z@tj�||d�}||_||_||_||_ |�!�}
W|�|�n|�|�0|
dk�r�dSdSdS)Nr)�restorer�zRSorry, remerge only works after normal merges.  Not cherrypicking or multi-merges.rjrr)z
text conflictzcontents conflictcsg|]}|j�vr|j�qSr#)r�r�)r�r�Zallowed_conflictsr#r$r��s
�z#cmd_remerge.run.<locals>.<listcomp>)"r�r*rrrJr�r�rCr�r[rr\rSr�r��NotVersionedErrorr�rr	Zselect_conflictsZtransform_treer`Z
set_conflictsZConflictListrQZ
NotConflicted�set_parent_idsrr$rr
rBrr)r�rTr
rBrr*rUr�rZ
new_conflictsr�rXr�ZieZ
restore_filesrr#r+r$r��sb�


�



zcmd_remerge.run)NNFFr�r#r#r#r$r)�s���r)c@sJeZdZdZgd�Zdedd�edd�gZdgZddd�Ze	d
d��Z
d	S)�
cmd_reverta�    Set files in the working tree back to the contents of a previous revision.

    Giving a list of files will revert only those files.  Otherwise, all files
    will be reverted.  If the revision is not specified with '--revision', the
    working tree basis revision is used. A revert operation affects only the
    working tree, not any revision history like the branch and repository or
    the working tree basis revision.

    To remove only some changes, without reverting to a prior version, use
    merge instead.  For example, "merge . -r -2..-3" (don't forget the ".")
    will remove the changes introduced by the second last commit (-2), without
    affecting the changes introduced by the last commit (-1).  To remove
    certain changes on a hunk-by-hunk basis, see the shelve command.
    To update the branch to a specific revision or the latest revision and
    update the working tree accordingly while preserving local changes, see the
    update command.

    Uncommitted changes to files that are reverted will be discarded.
    However, by default, any files that have been manually changed will be
    backed up first.  (Files changed only by merge are not backed up.)  Backup
    files have '.~#~' appended to their name, where # is a number.

    When you provide files, you can use their current pathname or the pathname
    from the target revision.  So you can use revert to "undelete" a file by
    name.  If you name a directory, all the contents of that directory will be
    reverted.

    If you have newly added files since the target revision, they will be
    removed.  If the files to be removed have been changed, backups will be
    created as above.  Directories containing unknown files will not be
    deleted.

    The working tree contains a list of revisions that have been merged but
    not yet committed. These revisions will be included as additional parents
    of the next commit.  Normally, using revert clears that list as well as
    reverting the files.  If any files are specified, revert leaves the list
    of uncommitted merges alone and reverts only the files.  Use ``brz revert
    .`` in the tree root to revert all files but keep the recorded merges,
    and ``brz revert --forget-merges`` to clear the pending merge list without
    reverting any files.

    Using "brz revert --forget-merges", it is possible to apply all of the
    changes from a branch in a single revision.  To do this, perform the merge
    as desired.  Then doing revert with the "--forget-merges" option will keep
    the content of the tree as it was, but it will clear the list of pending
    merges.  The next commit will then contain all of the changes that are
    present in the other branch, but without any other parent revisions.
    Because this technique forgets where these changes originated, it may
    cause additional conflicts on later merges involving the same source and
    target branches.
    )rZrx�merge�shelvercr�z&Do not save backups of reverted files.z
forget-mergesz8Remove pending merge marker, without changing any files.rmNFcCsLt�|�\}}|�|���|r8|�|��dd��n|�||||�dS)Nr)rJr�r�r�r-r��_revert_tree_to_revision)r�rcr�rTZ
forget_mergesrUr#r#r$r�=s
zcmd_revert.runcCs(td||d�}|j|||ddd�dS)Nr}r�T)Zreport_changes)rdr})rUrcrTr�rbr#r#r$r1Fs�z#cmd_revert._revert_tree_to_revision)NFNN)r�r�r�r�r�r
r�r�r��staticmethodr1r#r#r#r$r.�s5���
	r.c@seZdZdZdZdd�ZdS)�cmd_assert_failz$Test reporting of assertion failuresTcCstd��dS)Nzalways fails)�AssertionErrorr�r#r#r$r�Sszcmd_assert_fail.runN�r�r�r�r�r�r�r#r#r#r$r3Msr3c@s>eZdZdZdgZedd�gZdgZgd�Ze	dd	d
��Z
dS)�cmd_helpz+Show help on a command or other topic.
    ZtopicsrUzShow help on all commands.ztopic?)raz--helpz-?z-hNFcCs(ddl}|dur|rd}|j�|�dS)Nrr�)Zbreezy.helprt)r�ZtopicrUr�r#r#r$r�bszcmd_help.run)NF)r�r�r�r�r�r
r�r�r�rr�r#r#r#r$r6Ws�r6c@s.eZdZdZdgZdgZdZeddd��ZdS)	�cmd_shell_completezsShow appropriate completions for context.

    For a list of all available commands, say 'brz shell-complete'.
    zcontext?zs-cTNcCsddlm}|�|�dS)Nr)�
shellcomplete)r�r8)r�r�r8r#r#r$r�sszcmd_shell_complete.run)N)	r�r�r�r�r�r�r�rr�r#r#r#r$r7jsr7c@s�eZdZdZddgZdgZdedd�edd	�ed
d�edd
�edd�dddeddd�ededd�edd�edddd�g
Z	dZ
ed%d#d$��Zd S)&�cmd_missinga�Show unmerged/unpulled revisions between two branches.

    OTHER_BRANCH may be local or remote.

    To filter on a range of revisions, you can use the command -r begin..end
    -r revision requests a specific revision, -r ..end or -r begin.. are
    also valid.

    :Exit values:
        1 - some missing revisions
        0 - no missing revisions

    :Examples:

        Determine the missing revisions between this and the branch at the
        remembered pull location::

            brz missing

        Determine the missing revisions between this and another branch::

            brz missing http://server/branch

        Determine the missing revisions up to a specific revision on the other
        branch::

            brz missing -r ..-10

        Determine the missing revisions up to a specific revision on this
        branch::

            brz missing --my-revision ..-10
    r/r?z
other_branch?rjr�zReverse the order of revisions.z	mine-onlyz)Display changes in the local branch only.�thiszSame as --mine-only.ztheirs-onlyz*Display changes in the remote branch only.r�zSame as --theirs-only.rrnrprczRFilter on other branch revisions (inclusive). See "help revisionspec" for details.rxzmy-revisionzRFilter on local branch revisions (inclusive). See "help revisionspec" for details.r�r(z4Show all revisions in addition to the mainline ones.r)Tr*r+r{NFr<c"	s�ddlm}m}�fdd�}|
dur(d}
|r0|}|r8|}d}|rFd}n|rNd}t�|�d}��|���|��}|dur�|}|dur�t�	t
d	���t�|�j
j�}|t
d
��|��t�|�}|j|jkr�|}n��|���tt||�����}tt||�����}||||||
||d�\}}|du�r>tj}|�|�}|�j
|	dd
�}d}|�r�|�s�|tddt|��t|��i} |���r�|j��} |||j|
| �D]}|�|��q�d}!d}nd}!|�r6|�s6|!du�r�|d�|tddt|��t|��|���r|j��} |||j|
| �D]}|�|��q d}|�rP|�sP|t
d��n>|�rj|�sj|t
d��n$|�s�|�s�|�s�|�s�|t
d�����|�s�|du�r�|du�r؈�|� ��|��du�r�|�!|j�|S)Nr)�
find_unmerged�iter_log_revisionscst�s�j�|�dSr�)rr�r�)rr�r#r$r$�sz cmd_missing.run.<locals>.messageFrgr8Zremotez$No peer location known or specified.z!Using saved parent location: {0}
)ZbackwardrL�local_revid_range�remote_revid_ranger0)r�r�r6zYou have %d extra revision:
zYou have %d extra revisions:
Trz


zYou are missing %d revision:
zYou are missing %d revisions:
z"This branch has no new revisions.
z#Other branch has no new revisions.
zBranches are up to date.
)"Zbreezy.missingr;r<r:rKr�r�rHrr\rSr5rIr�r�r�r(rrTrArArOrFrGr�r[Z
supports_tagsr>�get_reverse_tag_dictr�Zlog_revisionr�rCrJ)"r�rr�Z	mine_onlyZtheirs_onlyrJrUrqrVr�rpr:r�rLrcZmy_revisionrjr;r<r$ZrestrictZlocal_branchrlrSZ
remote_branchr=r>Zlocal_extraZremote_extra�registryrOZstatus_codeZrev_tag_dictZ
printed_localr#r�r$r��s��
�
�����


���

�
��

��zcmd_missing.run)NFFFNFFFFFFFNNNr<)
r�r�r�r�r�r�r
rr
r�r�rr�r#r#r#r$r9ysN"��������r9c@s2eZdZdZdgZdgZedd�gZddd	�Zd
S)�cmd_packa+Compress the data within a repository.

    This operation compresses the data within a bazaar repository. As
    bazaar supports automatic packing of repository, this operation is
    normally not required to be done manually.

    During the pack operation, bazaar takes a backup of existing repository
    data, i.e. pack files. This backup is eventually removed by bazaar
    automatically when it is safe to do so. To save disk space by removing
    the backed up pack files, the --clean-obsolete-packs option may be
    used.

    Warning: If you use --clean-obsolete-packs and your machine crashes
    during or immediately after repacking, you may be left with a state
    where the deletion has been written to disk but the new packs have not
    been. In this case the repository may be unusable.
    r�zbranch_or_repo?zclean-obsolete-packsz)Delete obsolete packs to save disk space.r<FcCsPtj�|�d}z|��}|j}Wntjy>|��}Yn0|j|d�dS)Nr)�clean_obsolete_packs)	r&r'rKrr�rrr�Zpack)r�Zbranch_or_reporBr�r3r�r#r#r$r�Os
zcmd_pack.runN)r<Fr�r#r#r#r$rA5s��rAc@s$eZdZdZdgZeddd��ZdS)�cmd_pluginsa!List the installed plugins.

    This command displays the list of installed plugins including
    version of plugin and a short description of each.

    --verbose shows the path where each plugin is located.

    A plugin is an external component for Breezy that extends the
    revision control system, by adding or replacing code in Breezy.
    Plugins can do a variety of things, including overriding commands,
    adding new commands, providing additional network transports and
    customizing log output.

    See the Bazaar Plugin Guide <http://doc.bazaar.canonical.com/plugins/en/>
    for further information on plugins including where to find them and how to
    install them. Instructions are also provided there on how to write new
    plugins using the Python programming language.
    rpFcCs(ddlm}|j�t|j|d���dS)Nr)�plugin)Z
show_paths)r�rDr��
writelinesr.Zdescribe_plugins)r�rprDr#r#r$r�ns�zcmd_plugins.runN)F)r�r�r�r�r�rr�r#r#r#r$rCYsrCc@sBeZdZdZdeddd�eddd�gZdgZd	Zedd
d��Z	dS)�
cmd_testamentz,Show testament (signing-form) of a revision.rcrUzProduce long-format testament.rxr�z"Produce a strict-format testament.r�r�r<NFcCs�ddlm}m}|dur|}n|}|dkr:t�|�d}n
t�|�}|�|���|durd|��}	n|d�	|�}	|�
|j|	�}
|r�|j�
|
���n|j�|
���dS)Nr)�	Testament�StrictTestamentTr<r)Z
bzr.testamentrGrHr:rKr(r�r�r�r�Z
from_revisionr�r�rEZ
as_text_linesr�Z
as_short_text)r�r3rcrUr�rGrHZtestament_classr�r�r�r#r#r$r��s

zcmd_testament.run)r<NFFr�r#r#r#r$rFvs
��rFc@sNeZdZdZgd�ZdgZeddd�eddd�d	d
dgZdZe	ddd��Z
dS)�cmd_annotatea<Show the origin of each line in a file.

    This prints out the given file with an annotation on the left side
    indicating which revision, author and date introduced the change.

    If the origin is the same for a run of consecutive lines, it is
    shown only at the top, unless the --all option is given.
    )�annZblameZpraiserXrgzShow annotations on all lines.rxrUz Show commit date in annotations.rcrnrjr�FNc	Cs�ddlm}t||�\}}	}
|dur4|�|���n|�|	���td||	d�}|�|���|dur�|dur�|�|
�s�t�|
��|||
|j	|||d�n,|�|
�s�t�|
��|||
|j	||||	d�dS)Nr)�annotate_file_tree�annotaterb)r�)r�r3)
rLrKrkr�r�rdr�rr,r�)r�rXrgrUrcr�rjrKr�r3rVrUr#r#r$r��s&�

�

�zcmd_annotate.run)FFNFN)r�r�r�r�r�r�r
r�r�rr�r#r#r#r$rI�s

��rIc@s4eZdZdZdZdgZddgZddd	�Zd
d�ZdS)
�cmd_re_signz4Create a digital signature for an existing revision.Tzrevision_id*rjrcNr<cCsh|dur|durt�td���|dur<|dur<t�td���t�|�dj}|�|���|�|||�S)Nr�r�r)	rr\rSrJrKr3r�rCr*)r��revision_id_listrcrjr�r#r#r$r��s��zcmd_re_sign.runc
Cs�ddlm}t�|���}|durr||j��2|D]}t�|�}|j�||�q2Wd�n1sd0Y�n.|du�r�t|�dkr�|d�	|�\}}||j��|j�||�Wd�n1s�0Yn�t|�dk�r�|d�	|�\}	}
|d�	|�\}}|du�r|�
�}|	du�s,|du�r:t�t
d���||j��:t|	|d�D]}|j�|�|�|��qTWd�n1�s�0Ynt�t
d���dS)Nr)�
WriteGrouprr�z5Cannot sign a range of non-revision-history revisionsz.Please supply either one revision, or a range.)r�rOrDrErBr�r�Z
sign_revisionr[rhr�rr\rS�rangert)
r�r�rNrcrOZgpg_strategyr�r�r�Z
from_revnoZ
from_revidZto_revnoZto_revidr#r#r$r*�s:
2
.
��*�zcmd_re_sign._run)NNr<)	r�r�r�r�r�r�r�r�r*r#r#r#r$rM�s
rMc@s.eZdZdZddgZdgZdgZd
dd	�ZdS)�cmd_binda�Convert the current branch into a checkout of the supplied branch.
    If no branch is supplied, rebind to the last bound location.

    Once converted into a checkout, commits must succeed on the master branch
    before they will be applied to the local branch.

    Bound branches use the nickname of its master branch unless it is set
    locally, in which case binding will update the local nickname to be
    that of the master.
    r��unbindr�rjNr<cCs�t�|�\}}|durxz|��}Wn"tjyDt�td���Yn40|durx|��durjt�td���nt�td���t�|�}z|�	|�Wn"tj
y�t�td���Yn0|����r�|j
|_
dS)NzCNo location supplied.  This format does not remember old locations.zBranch is already boundz3No location supplied and no previous location knownz?These branches have diverged. Try merging, and then bind again.)r:rKZget_old_bound_locationrr�r\rSr r(rwZDivergedBranches�
get_config�has_explicit_nicknamer�)r�r8rjr�rVZb_otherr#r#r$r�
s2�
��
�
zcmd_bind.run)Nr<�r�r�r�r�r�r�r�r�r#r#r#r$rQ�s
rQc@s,eZdZdZddgZgZdgZd	dd�ZdS)
�
cmd_unbindz�Convert the current checkout into a regular branch.

    After unbinding, the local branch is considered independent and subsequent
    commits will be local only.
    r�rwrjr<cCs(t�|�\}}|��s$t�td���dS)NzLocal branch is not bound)r:rKrRrr\rS)r�rjr�rVr#r#r$r�5szcmd_unbind.runN)r<rUr#r#r#r$rV*s
rVc	@sfeZdZdZdgZddeddd�edd	d�ed
dd�edd
d�gZdgZgZdZ	ddd�Z
dd�ZdS)�cmd_uncommitaRemove the last committed revision.

    --verbose will print out what is being removed.
    --dry-run will go through all the motions, but not actually
    remove anything.

    If --revision is specified, uncommit revisions to leave the branch at the
    specified revision.  For example, "brz uncommit -r 15" will leave the
    branch at revision 15.

    Uncommit leaves the working tree ready for a new commit.  The only change
    it may make is to restore any pending merges that were present before
    the commit.
    r�rprcr�zDon't actually make changes.rxr�zSay yes to all questions.z	keep-tagsz*Keep tags that point to removed revisions.r8zAOnly remove the commits from the local branch when in a checkout.r�r{NFcCs�|durd}tj�|�\}}	z|��}
|
j}Wn&tjtjfyTd}
|��}Yn0|
durn|�	|
�
��n|�	|�
��|�||
|||||||�	S)Nr<)r&r'rKr)r3rr*r+rr�rCr*)r�r8r�rprcr�r8�	keep_tags�controlrVrUr�r#r#r$r�^s
�zcmd_uncommit.runc
	Cspddlm}
m}ddlm}|��\}
}d}|dur>|
}|}n&|d�|�jd}||
krd|�|�}|dusvt�	|�r�|j
�td��dS|
d|j
dd�}|||d	d
||
d�|r�|j
�td��n|j
�td
��|�st
j�td�di��s|j
�td��dStd||�||||||||d�|	dk�rR|j
�td�|	|	|�d�f�n|j
�td�|�d��dS)Nr)�
log_formatter�show_log)r�rzNo revisions to uncommit.
rqr0)r�r6Fr)rpr9r:r;z3Dry-run, pretending to remove the above revisions.
z'The above revision(s) will be removed.
zUncommit these revisionszbreezy.builtins.uncommitz	Canceled
zUncommitting from {%s} to {%s})rUr�rpr�r8rXr<zHYou can restore the old tip by running:
  brz pull -d %s %s -r revid:%s
r�zAYou can restore the old tip by running:
  brz pull . -r revid:%s
)rOrZr[r�rRrhr�rtr�r�r�r�rSrHrIZconfirm_actionrr�)r�r�rUr�rprcr�r8rXr8rZr[r�rSZlast_rev_idr�r�rOr#r#r$r*qsl
�����
�
����zcmd_uncommit._run)NFFNFFF)r�r�r�r�r�r
r�r�r�r�r�r*r#r#r#r$rW;s&

���
�
rWc@s8eZdZdZdgZeddd�eddd�gZdd
d�ZdS)
�cmd_break_locka�Break a dead lock.

    This command breaks a lock on a repository, branch, working directory or
    config file.

    CAUTION: Locks should only be broken when you are sure that the process
    holding the lock has been stopped.

    You can get information on what locks are open via the 'brz info
    [location]' command.

    :Examples:
        brz break-lock
        brz break-lock brz+ssh://example.com/brz/foo
        brz break-lock --conf ~/.config/breezy
    r��configz3LOCATION is the directory where the config lock is.rxr�z5Do not ask for confirmation before breaking the lock.NFcCst|durd}|r&t�tjdddi�t_|r@tj|d�}|��n0tj�|�\}}z|��Wnt	ynYn0dS)Nr<zbreezy.lockdir.breakT)r!)
rHZConfirmationUserInterfacePolicyrIr�ZLockableConfigZ
break_lockr&r'rK�NotImplementedError)r�r8r]r�ZconfrYrVr#r#r$r��s�
zcmd_break_lock.run)NFFr�r#r#r#r$r\�s���r\c@seZdZdZdZdd�ZdS)�cmd_wait_until_signalledz�Test helper for test_start_and_stop_brz_subprocess_send_signal.

    This just prints a line to signal when it is ready, then blocks on stdin.
    TcCs$|j�d�|j��tj��dS)Nzrunning
)r�r�rer��stdin�readliner�r#r#r$r��s
zcmd_wait_until_signalled.runNr5r#r#r#r$r_�sr_c@steZdZdZdgZeddd�edddd	d
�edded
�edded
�e	ddd�eddd�ede
dd�gZddd�ZdS)�	cmd_servezRun the brz server.Zserver�inetz.Serve on stdin/out for use from inetd or sshd.rx�protocolzProtocol to serve.)zbreezy.transport�transport_server_registryTr��listenz,Listen for connections on nominated address.r�portz�Listen for connections on nominated port.  Passing 0 as the port number will result in a dynamically allocated port.  The default port depends on the protocol.rjz!Serve contents of this directory.zallow-writesaWBy default the server is a readonly server.  Supplying --allow-writes enables write access to the contents of the served directory and below.  Note that ``brz serve`` does not perform authentication, so unless some form of external authentication is arranged supplying this option leads to global uncontrolled write access to your file system.zclient-timeoutz0Override the default idle client timeout (5min).r�NFcCsfddlm}m}	|dur t��}|dur2|	j��}|�|�}
|sHd|
}
|	�|
�}||||||�dS)Nr)r8r�z	readonly+)	r�r8r�rOr�rerCraZget_transport_from_url)r�rfrgrcrjZallow_writesrdZclient_timeoutr8r�r�r�r#r#r$r�s


z
cmd_serve.run)NNFNFNN)
r�r�r�r�r�r
rrrr�floatr�r�r#r#r#r$rb�s>������	���rbc@s6eZdZdZdgZdgZedddd�gZdd	d
�ZdS)
�cmd_joinaCombine a tree into its containing tree.

    This command requires the target tree to be in a rich-root format.

    The TREE argument should be an independent tree, inside another tree, but
    not part of it.  (Such trees can be produced by "brz split", but also by
    running "brz branch" with the target inside a tree.)

    The result is a combined tree, with the subtree no longer an independent
    part.  This is marked as a merge of the subtree into the containing tree,
    and all history is preserved.
    rrUrFzJoin by reference.Tr�Fc	
Cs�ddlm}t�|�}t�|j�}t�|�d}|jj	}|�
�sTt�t
d�|f��|r�z|�|�Wq�|y�}z$t�t
d��||j���WYd}~q�d}~00nNz|�|�Wn>tjy�}z$t�t
d��||j���WYd}~n
d}~00dS)Nr)�BadReferenceTargetzfCan't join trees because %s doesn't support rich root data.
You can use brz upgrade on the repository.zCannot join {0}.  {1})Zbreezy.mutabletreerjrJr(rOr�r0rKr3r�Zsupports_rich_rootrr\rSZ
add_referencer��reasonZsubsumeZBadSubsumeSource)	r�rUrFrjZsub_treeZ
parent_dir�containing_treerGr�r#r#r$r�4s0
����zcmd_join.runN)Fr�r#r#r#r$ri s
�ric@s$eZdZdZdgZdgZdd�ZdS)�	cmd_splita�Split a subdirectory of a tree into a separate tree.

    This command will produce a target tree in a format that supports
    rich roots, like 'rich-root' or 'rich-root-pack'.  These formats cannot be
    converted into earlier formats like 'dirstate-tags'.

    The TREE argument should be a subdirectory of a working tree.  That
    subdirectory will be converted into an independent tree, with its own
    branch.  Commits in the top-level tree will not apply to the new subtree.
    r7rUcCsXt�|�\}}|�|�s"t�|��z|�|�Wn"tjyRt�|jj	��Yn0dSr�)
rJrKr�rr,�extractZRootNotRichZRichRootUpgradeRequiredr3r)r�rUrlr�r#r#r$r�^s

z
cmd_split.runN)r�r�r�r�r�r�r�r#r#r#r$rmOsrmc@steZdZdZddgZdZdgZdejddd	dd
ddd
d�e	ddd�de	de
dd�e	de
ddd�gZdZd dd�Z
dS)!�cmd_merge_directivea�Generate a merge directive for auto-merge tools.

    A directive requests a merge to be performed, and also provides all the
    information necessary to do so.  This means it must either include a
    revision bundle, or the location of a branch containing the desired
    revision.

    A submit branch (the location to merge into) must be supplied the first
    time the command is issued.  After it has been supplied once, it will
    be remembered as the default.

    A public branch is optional if a revision bundle is supplied, but required
    if --diff or --plain is specified.  It will be remembered as the default
    after the first use.
    �submit_branch?�public_branch?Tr5rjz
patch-typez.The type of patch to include in the directive.z
Patch typeFz!Bazaar revision bundle (default).zNormal unified diff.zNo patch, just directive.)r�r�r��bundler|�plain�signzGPG-sign the directive.rxrc�mail-toz9Instead of printing the directive, email to this address.r�r$r.z*Message to use when committing this merge.r�r�Nrrr<c	Cs�ddlm}	m}
dddd�|\}}t�|�}
|
��}|durD|}n|durV|
�|�|durf|
��}|dur|t�	t
d���|
��}|dur�|}n|dur�|
�|�|s�|dur�t�	t
d���d}|du�rt
|�d	kr�t�	t
d
���|d�|
�}t
|�d	k�r|d�|
�}n|
��}|	|�}||
k�r:t�	t
d
���tjj|
j|t��t��||||||d�
}|du�r�|�r�|j�|�|
��n|j�|���n$|�||
|�}t|
���}|�|�dS)Nr)r�r�)FF)TF)TT)rsr|rrz#No submit branch specified or knownz#No public branch specified or knownr�z>brz merge-directive takes at most two one revision identifiersrrzNo revisions to bundle.)�
public_branch�
include_patch�include_bundler$rT) rcr�r�r:r(r"r#rHrr\rSriZset_public_branchr[r�r�Zmerge_directiveZMergeDirective2Zfrom_objectsr�rrOr�r�r�Z	to_signedrEZto_linesZto_emailZSMTPConnectionrBZ
send_email)r��
submit_branchrvZ
patch_typertrc�mail_tor$rjr�r�rwrxr3Zstored_submit_branchZstored_public_branchrTr�Z	directiverr#r#r$r��sn��

�
�
�
�
zcmd_merge_directive.run)NNrrFNNNr<)r�r�r�r�r�r�r�rr�r
rr�r�r�r#r#r#r$rohs8�	����roc@s�eZdZdZdZddgZddgZeddd	�ed
dd	�edd
d	�eddded�eddded�eddd	�edded�ddedded�e	dd d!d"�gZ
d'd%d&�Zd#S)(�cmd_senda\
Mail or create a merge-directive for submitting changes.

    A merge directive provides many things needed for requesting merges:

    * A machine-readable description of the merge to perform

    * An optional patch that is a preview of the changes requested

    * An optional bundle of revision data, so that the changes can be applied
      directly from the merge directive, without retrieving data from a
      branch.

    `brz send` creates a compact data set that, when applied using brz
    merge, has the same effect as merging from the source branch.

    By default the merge directive is self-contained and can be applied to any
    branch containing submit_branch in its ancestory without needing access to
    the source branch.

    If --no-bundle is specified, then Breezy doesn't send the contents of the
    revisions, but only a structured request to merge from the
    public_location.  In that case the public_branch is needed and it must be
    up-to-date and accessible to the recipient.  The public_branch is always
    included if known, so that people can check it later.

    The submit branch defaults to the parent of the source branch, but can be
    overridden.  Both submit branch and public branch will be remembered in
    branch.conf the first time they are used for a particular branch.  The
    source branch defaults to that containing the working directory, but can
    be changed using --from.

    Both the submit branch and the public branch follow the usual behavior with
    respect to --remember: If there is no default location set, the first send
    will set it (use --no-remember to avoid setting it). After that, you can
    omit the location to use the default.  To change the default, use
    --remember. The value will only be saved if the location can be accessed.

    In order to calculate those changes, brz must analyse the submit branch.
    Therefore it is most efficient for the submit branch to be a local mirror.
    If a public location is known for the submit_branch, that location is used
    in the merge directive.

    The default behaviour is to send the merge directive by mail, unless -o is
    given, in which case it is sent to a file.

    Mail is sent using your preferred mail program.  This should be transparent
    on Windows (it uses MAPI).  On Unix, it requires the xdg-email utility.
    If the preferred client can't be found (or used), your editor will be used.

    To use a specific mail program, set the mail_client configuration option.
    Supported values for specific clients are "claws", "evolution", "kmail",
    "mail.app" (MacOS X's Mail.app), "mutt", and "thunderbird"; generic options
    are "default", "editor", "emacsclient", "mapi", and "xdg-email".  Plugins
    may also add supported clients.

    If mail is being sent, a to address is required.  This can be supplied
    either on the commandline, by setting the submit_to configuration
    option in the branch itself or the child_submit_to configuration option
    in the submit branch.

    The merge directives created by brz send may be applied using brz merge or
    brz pull by specifying a file containing a merge directive as the location.

    brz send makes extensive use of public locations to map local locations into
    URLs that can be used by other people.  See `brz help configuration` to
    set them, and use `brz info` to display them.
    r�r/r?rprq�	no-bundle�/Do not include a bundle in the merge directive.rx�no-patch�6Do not include a preview patch in the merge directive.r6�"Remember submit and public branch.�from�]Branch to generate the submission from, rather than the one containing the working directory.r��rtrur��output�ozBWrite merge directive to this file or directory; use - for stdout.r/r�zdRefuse to send if there are uncommitted changes in the working tree, --no-strict disables the check.ruz!Mail the request to this address.rrcr$�bodyzBody for the email.r�� Use the specified output format.�zbreezy.sendr��rtr�NFc
Ks:ddlm}||||||||||
�dd�|	|
||j|d�S)Nr�r5r�r<�r��r5rCr�)r�ryrv�	no_bundle�no_patchrcr6r�r�rzr$r�r��kwargsr5r#r#r$r�:s
�zcmd_send.run)NNFFNNNNNNNN)r�r�r�r�r�r�r�r
rrr�r�r#r#r#r$r{�sND�
��������r{c@s�eZdZdZeddd�eddd�eddd�ed	d
ded�ed
dded�eddd�dedddd�gZdgZddgZ	dZ
d dd�ZdS)!�cmd_bundle_revisionsa.Create a merge-directive for submitting changes.

    A merge directive provides many things needed for requesting merges:

    * A machine-readable description of the merge to perform

    * An optional patch that is a preview of the changes requested

    * An optional bundle of revision data, so that the changes can be applied
      directly from the merge directive, without retrieving data from a
      branch.

    If --no-bundle is specified, then public_branch is needed (and must be
    up-to-date), so that the receiver can perform the merge using the
    public_branch.  The public_branch is always included if known, so that
    people can check it later.

    The submit branch defaults to the parent, but can be overridden.  Both
    submit branch and public branch will be remembered if supplied.

    If a public_branch is known for the submit_branch, that public submit
    branch is used in the merge instructions.  This means that a local mirror
    can be used as your actual submit branch, once you have set public_branch
    for that mirror.
    r|r}rxr~rr6r�r�r�r�r�r�r�zWrite directive to this file.r/r�zpRefuse to bundle revisions if there are uncommitted changes in the working tree, --no-strict disables the check.rcr�r�r�r�rrr5r/TNFc
KsF|durd}ddlm}||||||||||
�dd�ddd|j|	d�S)N�-rr�r�r<r�r�)r�ryrvr�r�rcr6r�r�r�r�r5r#r#r$r�}s
�zcmd_bundle_revisions.run)	NNFFNFNNN)r�r�r�r�r
rrr�r�r�r�r�r#r#r#r$r�Fs@�
�������r�c@sLeZdZdZddgZdgZeddd�edd	d�ed
dd�dgZddd�Z	d
S)�cmd_tagaqCreate, remove or modify a tag naming a revision.

    Tags give human-meaningful names to revisions.  Commands that take a -r
    (--revision) option can be given -rtag:X, where X is any previously
    created tag.

    Tags are stored in the branch.  Tags are copied from one branch to another
    along when you branch, push, pull or merge.

    It is an error to give a tag name that already exists unless you pass
    --force, in which case the tag is moved to point to the new revision.

    To rename a tag (change the name but keep it on the same revsion), run ``brz
    tag new-name -r tag:old-name`` and then ``brz tag --delete oldname``.

    If no tag name is specified it will be determined through the
    'automatic_tag_name' hook. This can e.g. be used to automatically tag
    upstream releases by reading configure.ac. See ``brz help hooks`` for
    details.
    r�r>z	tag_name?�deletez'Delete this tag rather than placing it.rxrjz!Branch in which to place the tag.r�zReplace existing tags.rcNr<c
CsPt�|�\}}|�|���|rT|dur6t�td���|j�|�t	td�|�n�|r�t
|�dkrrt�td���|d�|�}n|��}|dur�|�
|�}|dur�t�td���z|j�|�}	Wntjy�d}	Yn0|s�|	d|fvr�t�|��|	|k�rt	td�|�n:|j�||�|	du�r<t	td�|�nt	td	�|�dS)
NzNo tag specified to delete.zDeleted tag %s.rz<Tags can only be placed on a single revision, not on a rangerzPlease specify a tag name.z(Tag %s already exists for that revision.zCreated tag %s.zUpdated tag %s.)r:rKr�rCrr\rSr>Z
delete_tagrr[r�r�Zautomatic_tag_nameZ
lookup_tagZ	NoSuchTagZTagAlreadyExistsZset_tag)
r�Ztag_namer�rjr�rcr3rVr�Zexisting_targetr#r#r$r��sD��
�



zcmd_tag.run)NNr<NN)
r�r�r�r�r�r�r
rr�r�r#r#r#r$r��s(�����r�c@sLeZdZdZdgZeddd�edddd	d
�ddgZeddd��Z	dd�Z
dS)�cmd_tagsz^List tags.

    This command shows a table of tag names and the revisions they reference.
    r�rjz&Branch whose tags should be displayed.rxr�z Sort tags by different criteria.ZSorting)z
breezy.tag�tag_sort_methodsr!rnrcr<NFcCsddlm}t�|�\}}tt|j����}|s4dS|�|�	��|rR|�
||�}|durb|��}|||�|s�t|�D]d\}	\}
}z(|�
|�}t|t�r�d�tt|��}Wn"tjtjtjfy�d}Yn0|
|f||	<qxndd�|D�}|��|D]\}
}
|j�d|
|
f�q�dS)Nr)r�r<racSsg|]\}}||�d�f�qS)r�)r�)r�r�r�r#r#r$r�
r�z cmd_tags.run.<locals>.<listcomp>z	%-20s %s
)r�r�r:rKr.rr>Zget_tag_dictr�r��_tags_for_rangerC�	enumerater�r��tupler7r�r�rr�r��UnsupportedOperationr�r�r�)r�rjr�r�rcr�r3rVr>r(r�r�r�Zrevspecr#r#r$r��s6


�

zcmd_tags.runc
s�t|||���\}}|j|j}}|rD||krD|j���||�rDgS|j��}g}|j||dd�D]0�|�	�dd�}	|	rb|�
�fdd�|	D��qb|S)N�include)Zstart_revision_idZstop_revision_idZ	stop_rulercsg|]}|�df�qS)rr#)r�r��r�r#r$r�%r�z,cmd_tags._tags_for_range.<locals>.<listcomp>)rArAr�r�r�Zis_ancestorr>r?Ziter_merge_sorted_revisionsrCr�)
r�r3rcrMrNZrevid1Zrevid2Z
tagged_revids�foundZ
revid_tagsr#r�r$r�s
�
zcmd_tags._tags_for_range)r<NFN)r�r�r�r�r�rrr�rr�r�r#r#r#r$r��s���#r�c@s�eZdZdZgd�ZdgZejdddddd	d
ddd
�	ejdddddddd�ejdddddddd�edde	d�eddd�ed d!e	d�ed"d#d�gZ
d'd%d&�Zd$S)(�cmd_reconfigurea�Reconfigure the type of a brz directory.

    A target configuration must be specified.

    For checkouts, the bind-to location will be auto-detected if not specified.
    The order of preference is
    1. For a lightweight checkout, the current bound location.
    2. For branches that used to be checkouts, the previously-bound location.
    3. The push location.
    4. The parent location.
    If none of these is available, --bind-to must be specified.
    )Zbranchesr�zstandalone-treesr�r��	tree_typez	Tree typez%The relation between branch and tree.TFz9Reconfigure to be an unbound branch with no working tree.z8Reconfigure to be an unbound branch with a working tree.z5Reconfigure to be a bound branch with a working tree.zAReconfigure to be a lightweight checkout (with no local history).)r�rtr�r�r3rUr�Zlightweight_checkout�repository_typezRepository typezLocation fo the repository.zJReconfigure to be a standalone branch (i.e. stop using shared repository).z'Reconfigure to use a shared repository.)r�rtr�r�rvZ
use_shared�repository_treeszTrees in Repositoryz2Whether new branches in the repository have trees.zFReconfigure repository to create working trees on branches by default.zJReconfigure repository to not create working trees on branches by default.)r�rtr�r�Z
with_treesZ
with_no_treeszbind-tozBranch to bind checkout to.rr�z;Perform reconfiguration even if local changes will be lost.rxr]z5Reconfigure a branch to be stacked on another branch.�	unstackedzYReconfigure a branch to be unstacked.  This may require copying substantial data into it.Nc	Cs~tj�|�}	|r$|r$t�td���n,|dur>t���|	|�n|rPt�	��|	�|dur�|dur�|dur�|sp|rtdSt�td���d}
|dkr�tj
�|	�}
nD|dkr�tj
�|	�}
n.|dkr�tj
�
|	|�}
n|dkr�tj
�|	|�}
|
r�|
�|�d}
|dk�r
tj
�|	�}
n|dk�r tj
�|	�}
|
�r4|
�|�d}
|d	k�rNtj
�|	d
�}
n|dk�rftj
�|	d�}
|
�rz|
�|�d}
dS)
Nz+Can't use both --stacked-on and --unstackedz!No target configuration specifiedr3rUr�zlightweight-checkoutz
use-sharedrvz
with-treesTz
with-no-treesF)r&r'r(rr\rS�reconfigureZReconfigureStackedOn�applyZReconfigureUnstackedZReconfigure�	to_branchZto_treeZto_checkoutZto_lightweight_checkoutZ
to_use_sharedZ
to_standaloneZset_repository_trees)r�r8Zbind_tor�r�r�r�rdr�rjZreconfigurationr#r#r$r�fsf�����




�
�
zcmd_reconfigure.run)NNFNNNNN)r�r�r�r�r�r�rr�r
rr�r�r#r#r#r$r�)sZ
��	�
����-�r�c@sHeZdZdZdgZdeddd�dedd	d
d�edd
d�gZddd�ZdS)�
cmd_switcha�Set the branch of a checkout and update.

    For lightweight checkouts, this changes the branch being referenced.
    For heavyweight checkouts, this checks that there are no local commits
    versus the current bound branch, then it makes the local branch a mirror
    of the new location and binds to it.

    In both cases, the working tree is updated and uncommitted changes
    are merged. The user can commit or revert these as they desire.

    Pending merges need to be committed or reverted before using switch.

    The path to the branch to switch to can be specified relative to the parent
    directory of the current branch. For example, if you are currently in a
    checkout of /path/to/branch, specifying 'newbranch' will find a branch at
    /path/to/newbranch.

    Bound branches use the nickname of its master branch unless it is set
    locally, in which case switching will update the local nickname to be
    that of the master.
    rprjr�z*Switch even if local commits will be lost.rxrcz
create-branchr�z>Create the target branch from this one before switching to it.r��storez4Store and restore uncommitted changes in the branch.NFr<cCsddlm}|}td|�}tj�|�d}	|	jg}
|durT|durPt�t	d���|}z|	j
|
d�}|����}Wntj
y�d}d}Yn0|
�|j�|r�|dur�t�t	d���t|	||
d�}|dur�|�|�}|jj||
||d	��
�}
nLztj||
d�}
Wn$tj
�y$t|	||
d�}
Yn0|du�r:|�|
�}|
�|
j�z|j|	|
||||
d
�Wn$tj�y�t�t	d���Yn0|�r�|	�
�}|
j|_|
j�r�|
jj|	jk�r�tt	d�|
jt�|
jd
��ntt	d�|
j�ntt	d�t�|
jd
��dS)Nrrzrurz/You must supply either a revision or a locationrFz*cannot create branch without source branch)rr�r�)r�Zstore_uncommittedrzkswitching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.zSwitched to branch %s at %sr�zSwitched to branch %szSwitched to branch at %s)r�rur_r&r'rKrrr\rSrrSrTrr�Zuser_transportr9r�rnr:r(r;ZBranchReferenceLoopr�rAr-rr5rIr)r�r�r�r�rcrjr�ruZ
tree_locationr!rr3Zhad_explicit_nickr�r#r#r$r��s�
�
��
��
�

�
�
��zcmd_switch.run)NFFNr<Fr�r#r#r#r$r��s"�����r�c@sTeZdZdZgZdgZeddd�eddd�edd	ed
�edded
�gZddd�Z	dS)�cmd_viewaRManage filtered views.

    Views provide a mask over the tree so that users can focus on
    a subset of a tree when doing their work. After creating a view,
    commands that support a list of files - status, diff, commit, etc -
    effectively have that list of files implicitly given each time.
    An explicit list of files can still be given but those files
    must be within the current view.

    In most cases, a view has a short life-span: it is created to make
    a selected change and is deleted once that change is committed.
    At other times, you may wish to create one or more named views
    and switch between them.

    To disable the current view without deleting it, you can switch to
    the pseudo view called ``off``. This can be useful when you need
    to see the whole tree for an operation or two (e.g. merge) but
    want to switch back to your view after that.

    :Examples:
      To define the current view::

        brz view file1 dir1 ...

      To list the current view::

        brz view

      To delete the current view::

        brz view --delete

      To disable the current view without deleting it::

        brz view --switch off

      To define a named view and switch to it::

        brz view --name view-name file1 dir1 ...

      To list a named view::

        brz view --name view-name

      To delete a named view::

        brz view --name view-name --delete

      To switch to a named view::

        brz view --switch view-name

      To list all views defined::

        brz view --all

      To delete all views::

        brz view --delete --all
    rmrgz)Apply list or delete action to all views.rxr�zDelete the view.rAz+Name of the view to define, list or delete.rruzName of the view to switch to.FNcCs�tj|dd�\}}|j��\}}|dur,|}|r�|rDt�td���np|rXt�td���n\|r||j�di�|j�	td��n8|dur�t�td���n |j�
|�|j�	td�|��n�|�rf|r�t�td���n�|r�t�td	���n||d
k�r,|du�rt�td���|j�d|�|j�	td�|�n6|j�||�t�|j���}	|j�	td
��
||	���n(|�r�|�r�|j�	td��t|�D]>}
|
|k�r�d}nd}t�||
�}	|j�	d||
|	f��q�n|j�	td��n�|�rH|du�r�d}n|d
k�rt�td���|j�|t|��t�|j���}	|j�	td
��
||	��nF|du�rd|j�	td��n*t�|j�|��}	|j�	td��
||	��dS)NFr�z'Both --delete and a file list specifiedz$Both --delete and --switch specifiedzDeleted all views.
zNo current view to deletezDeleted '%s' view.
z'Both --switch and a file list specifiedz!Both --switch and --all specifiedZoffzNo current view to disablezDisabled '%s' view.
zUsing '{0}' view: {1}
zViews defined:
z=>z  z%s %-20s %s
zNo views defined.
Zmyz#Cannot change the 'off' pseudo viewzNo current view.
z'{0}' view is: {1}
)rJr�rMrerr\rSZ
set_view_infor�r�Zdelete_viewrRrNr�r�Zset_view)r�rTrgr�rArurUrgZ	view_dictrYZviewr�r#r#r$r�Vs��
�����

���


��
�zcmd_view.run)FFNN)
r�r�r�r�r�r�r
rr�r�r#r#r#r$r�s.=������r�c@seZdZdZdZdd�ZdS)�	cmd_hookszShow hooks.Tc	Cs�ttj���D]�}t�|�}|j�dt|�j�t|�	��D]Z\}}|j�d|f�t
|�}|r�|D]}|j�d|�|�f�qhq>|j�td��q>qdS)Nz%s:
z  %s:
z    %s
z    <no hooks installed>
)
r�r�Zknown_hooks�keysZknown_hooks_key_to_objectr�r�r�r��itemsr.Z
get_hook_namerS)r�Zhook_keyZ
some_hooksZ	hook_nameZ
hook_pointZfound_hooks�hookr#r#r$r��s

�
z
cmd_hooks.runNr5r#r#r#r$r��sr�c@s6eZdZdZdgZdeddd�gZdgZdd
d�ZdS)
�cmd_remove_branchz�Remove a branch.

    This will remove the branch from the specified location but
    will keep any working tree or repository in place.

    :Examples:

      Remove the branch at repo/trunk::

        brz remove-branch repo/trunk

    r�rjr�z.Remove branch even if it is the active branch.rxZrmbranchNFcCszt||d�}|sh|j��rhz|jjdd�}WntjyDd}Yn0|durh|j|jkrht�td���|j�	|j
�dS)N)r=r8r�r{z+Branch is active. Use --force to remove it.)r?r&r�rrrr-r\rSZdestroy_branchrA)r�rjr8r��brr�r#r#r$r��s

��zcmd_remove_branch.run)NNF)	r�r�r�r�r�r
r�r�r�r#r#r#r$r��s

�r�c@sneZdZdZdgZddeddd�ded	d
ejj	ddd
�eddd�eddd�gZ
ddgZddd�Zddd�Z
dS)�
cmd_shelveaYTemporarily set aside some changes from the current tree.

    Shelve allows you to temporarily put changes you've made "on the shelf",
    ie. out of the way, until a later time when you can bring them back from
    the shelf with the 'unshelve' command.  The changes are stored alongside
    your working tree, and so they aren't propagated along with your branch nor
    will they survive its deletion.

    If shelve --list is specified, previously-shelved changes are listed.

    Shelve is intended to help separate several sets of changes that have
    been inappropriately mingled.  If you just want to get rid of all changes
    and you don't need to restore them later, use revert.  If you want to
    shelve all text changes at once, use shelve --all.

    If filenames are specified, only the changes to those files will be
    shelved. Other files will be left untouched.

    If a revision is specified, changes since that revision will be shelved.

    You can put multiple items on the shelf, and by default, 'unshelve' will
    restore the most recently shelved changes.

    For complicated changes, it is possible to edit the changes in a separate
    editor program to decide what the file remaining in the working copy
    should look like.  To do this, add the configuration option

        change_editor = PROGRAM {new_path} {old_path}

    where {new_path} is replaced with the path of the new version of the
    file and {old_path} is replaced with the path of the old version of
    the file.  The PROGRAM should save the new file with the desired
    contents of the file in the working tree.

    rmrjrcrgzShelve all changes.rxr$rz Method to use for writing diffs.TF)r�r�r.zList shelved changes.rz1Destroy removed changes instead of shelving them.ZunshelveZ
configurationNc		Cs�|r|j|d�Sddlm}	|dur0tjj��}zB|	j||j�||||||d�}
z|
�	�W|
�
�n
|
�
�0Wntjy�YdS0dS)N�rjr)r)rrjr)
�run_for_listrrr�rPrrC�	from_argsr�r�rrZ	UserAbort)r�rcrgrTr$rr.rrjrr r#r#r$r�s�
zcmd_shelve.runcCs�|durd}t�|�d}|�|���|��}|��}t|�dkrTttd��dSt	|�D]4}|�
|��d�}|dur|d}|j�
d||f�q\dS)Nr<rzNo shelved changes.smessagez<no message>z%3d: %s
r)rJrKr�r�r�Zactive_shelvesr[rrSr�Zget_metadatarCr�r�)r�rjrUZmanagerZshelves�shelf_idr$r#r#r$r�$szcmd_shelve.run_for_list)NFNNNFFN)N)r�r�r�r�r�r
rr�rPrr�r�r�r�r#r#r#r$r��s($
�
��
�
r�c@sFeZdZdZdgZdejdddddd	d
ddd
�	gZdgZddd�Z	dS)�cmd_unshelvez�Restore shelved changes.

    By default, the most recently shelved changes are restored. However if you
    specify a shelf by id those changes will be restored instead.  This works
    best when the changes don't depend on each other.
    z	shelf_id?rjr�zThe action to perform.FTz(Apply changes and remove from the shelf.z.Show changes, but do not apply or remove them.zSInstead of unshelving the changes, show the diff that would result from unshelving.z%Delete changes without applying them.z$Apply changes but don't delete them.)rtr�r�r�r�rZdelete_onlyr�r0Nr�r<cCsDddlm}|j|||d�}z|��W|j��n|j��0dS)Nr)�	Unshelverr�)rr�r�r�rUZunlock)r�r�r�rjr�Z	unshelverr#r#r$r�Ns

zcmd_unshelve.run)Nr�r<)
r�r�r�r�r�rr�r�r�r�r#r#r#r$r�6s��
r�c	@sReZdZdZdeddd�eddd�edd	d�ed
dd�edd
d�gZddd�ZdS)�cmd_clean_treea�Remove unwanted files from working tree.

    By default, only unknown files, not ignored files, are deleted.  Versioned
    files are never deleted.

    Another class is 'detritus', which includes files emitted by brz during
    normal operations and selftests.  (The value of these files decreases with
    time.)

    If no options are specified, unknown files are deleted.  Otherwise, option
    flags are respected, and may be combined.

    To check what clean-tree will do, use --dry-run.
    rjr�zDelete all ignored files.rx�detrituszJDelete conflict files, merge and revert backups, and failed selftest dirs.r]z&Delete files unknown to brz (default).r�z.Show files to delete instead of deleting them.r�zDo not prompt before deleting.Fr<cCs<ddlm}|s|s|sd}|r$d}|||||||d�dS)Nr��
clean_treeT)r]r�r�r�Z	no_promptr�)r�r]r�r�r�r�rjr�r#r#r$r�ps�zcmd_clean_tree.runN)FFFFFr<)r�r�r�r�r
r�r�r#r#r#r$r�Ws

�

�
�r�c@s>eZdZdZdZddgZdeddd�gZddd
�Zdd�Z	d	S)�
cmd_referencea list, view and set branch locations for nested trees.

    If no arguments are provided, lists the branch locations for nested trees.
    If one argument is provided, display the branch location for that tree.
    If two arguments are provided, set the branch location for that tree.
    Tr[r�rjzforce-unversionedz,Set reference even if path is not versioned.rxNr<Fcs�tj�|�\��}�dur"����|durz����6��fdd����D�}|���|�Wd�q�1sn0YnN��|�s�|s�t�	|��|dur�|��
|��fg}|���|�n��||�dS)Ncsg|]}|��|��f�qSr#)�get_reference_info)r�r�r{r#r$r��s�z%cmd_reference.run.<locals>.<listcomp>)r&r'rir`r�Ziter_references�_display_reference_infor�rr,r�Zset_reference_info)r�r�rjr8Zforce_unversionedrVr�r#r{r$r��s 
�
�.
zcmd_reference.runcCsJg}|D]\}}|�||f�qt|�D]\}}|j�d||f�q(dS)Nr�)r�r�r�r�)r�rUr3r�Zref_listr�r8r#r#r$r��s
z%cmd_reference._display_reference_info)Nr<NF)
r�r�r�r�r�r�r
r�r�r�r#r#r#r$r�{s��
r�c@s8eZdZdZdZedded�eddd�gZd
dd�Zd	S)�cmd_export_potz5Export command helps and error messages in po format.TrDzHExport help text from named command (defaults to all built in commands).rzinclude-duplicateszMOutput multiple copies of the same msgid string if it appears more than once.rxNFcCsddlm}||j||�dS)Nr)�
export_pot)r�r�)r�rDZinclude_duplicatesr�r#r#r$r��szcmd_export_pot.run)NF)	r�r�r�r�r�r
rr�r�r#r#r#r$r��s���	r�c@s"eZdZdZddgZddd�ZdS)�
cmd_importaImport sources from a directory, tarball or zip file

    This command will import a directory, tarball or zip file into a bzr
    tree, replacing any versioned files already present.  If a directory is
    specified, it is used as the target.  If the directory does not exist, or
    is not versioned, it is created.

    Tarballs may be gzip or bzip2 compressed.  This is autodetected.

    If the tarball or zip has a single root directory, that directory is
    stripped when extracting the tarball.  This is not done for directories.
    r�ztree?NcCsddlm}|||�dS)Nr)�	do_import)Zupstream_importr�)r�r�rUr�r#r#r$r��szcmd_import.run)N�r�r�r�r�r�r�r#r#r#r$r��s
r�c@seZdZdZdgZdd�ZdS)�
cmd_link_treeztHardlink matching files to another tree.

    Only files with identical content and execute bit will be linked.
    r8c	Cs�ddlm}t�d�d}t�|�}|���B|���|||�Wd�n1sV0YWd�n1st0YdS)Nr)�	link_treer<r)Z	transformr�rJrKr(rCr�)r�r8r�Ztarget_treeZsource_treer#r#r$r��s

zcmd_link_tree.runNr�r#r#r#r$r��sr�c@s8eZdZdZdZdgZdgZeddd�gZdd
d�Z	dS)
�cmd_fetch_ghostsz~Attempt to retrieve ghosts from another branch.

    If the other branch is not supplied, the last-pulled branch is used.
    Tz
fetch-missingr�zno-fixzSkip additional synchonization.rxNFcCs�ddlm}|�|���\}}t|�dkrV|j�d�|D]}|j�|�d�d�q:t|�dkr�|j�d�|D]}|j�|�d�d�qr|s�t|�dkr�t��d�dS)	Nr)�GhostFetcherrzInstalled:
r�r�zStill missing:
r<)	Zfetch_ghostsr�Zfrom_cmdliner�r[r�r�r�r�)r�r3Zno_fixr�Z	installedrr�r#r#r$r��szcmd_fetch_ghosts.run)NF)
r�r�r�r�r�r�r�r
r�r�r#r#r#r$r��sr�c@s�eZdZdZdZddgZddededd	d
�eddd
d�ededddd�ededddd�edddd�edddd�edddd�ed d!d"�ed#d$d%d�ed&d'd(e	d)�ed*d+d,d�ed-d.d"�ed/d0d1d�gZ
ed6d4d5��Zd3S)7�cmd_grepa�Print lines matching PATTERN for specified files and revisions.

    This command searches the specified files and revisions for a given
    pattern.  The pattern is specified as a Python regular expressions[1].

    If the file name is not specified, the revisions starting with the
    current directory are searched recursively. If the revision number is
    not specified, the working copy is searched. To search the last committed
    revision, use the '-r -1' or '-r last:1' option.

    Unversioned files are not searched unless explicitly specified on the
    command line. Unversioned directores are not searched.

    When searching a pattern, the output is shown in the 'filepath:string'
    format. If a revision is explicitly searched, the output is shown as
    'filepath~N:string', where N is the revision number.

    --include and --exclude options can be used to search only (or exclude
    from search) files with base name matches the specified Unix style GLOB
    pattern.  The GLOB pattern an use *, ?, and [...] as wildcards, and \
    to quote wildcard or backslash character literally. Note that the glob
    pattern is not a regular expression.

    [1] http://docs.python.org/library/re.html#regular-expression-syntax
    r{rpzpath*rprcr�Zwhenz3Show match in color. WHEN is never, always or auto.r�r|r�z0Grep for pattern in changeset for each revision.r�r�r��Xz(Skip files whose base name matches GLOB.r�r�r`z/Search only files whose base name matches GLOB.zfiles-with-matchesr&zAPrint only the name of each input file in which PATTERN is found.zfiles-without-match�LzEPrint only the name of each input file in which PATTERN is not found.zfixed-stringr�z7Interpret PATTERN is a single fixed string (not regex).r\zNSearch for pattern starting from the root of the branch. (implies --recursive)rxzignore-caser�z(Ignore case distinctions while matching.r"zHNumber of levels to display - 0 for all, 1 for collapsed (1 is default).r�)rtr#r�zline-numberr�zShow 1-based line number.zno-recursivez;Don't recurse into subdirectories. (default is --recursive)r�ZzMWrite an ASCII NUL (\0) separator between output lines rather than a newline.FNcCsddlm}ddlm}ddl}|dur0dg}n|r>t�d��|rP|rPt�d��t��}|durj|�	d�}|durvd	}|d
vr�t�d��|dur�d}d}|	dus�|dkr�d
}d}|r�d}|s�|�
|
�r�d
}
n|r�|
r�d}
|�|
�}
d}|j}|r�||j
O}|
�s|�|
�|j�|�}|dk�r$d
}n"|d	k�r4d}n|dk�rF|��}|��}||_||_||_||_||_||_||_||_|	|_|
|_||_||_|
|_||_ ||_!||_"d|_#||_$||_%||_&||_'|
|_|j(|_(||_)|�r�|�*|�n |	du�r
|�+|�n
|�,|�dS)Nr)�
_termcolorr)�grepr<z)cannot specify both --from-root and PATH.zKcannot specify both -l/--files-with-matches and -L/--files-without-matches.Z
grep_colorr�)r�r�r&z9Valid values for --color are "always", "never" or "auto".FTr�rr�r&)-r�r�r�r��rerr\r�r�Zget_user_optionZis_fixed_stringr6�	MULTILINE�
IGNORECASEZcompile_patternr�Z_user_encodingZallow_colorZGrepOptionsrp�ignore_case�no_recursiverfrr"�line_number�	path_listrcrpr�r��fixed_string�files_with_matches�files_without_matchr�r|�
eol_marker�print_revno�patterncr�r��
show_colorZ	grep_diffZworkingtree_grepZversioned_grep)r�rpr�r�rfrr"r�r�rcrpr�r�r�r�r�r�r|r�r�r�Z
global_configr�r�r�Zre_flagsr�Zoptsr#r#r$r�<s���



�



zcmd_grep.run)FFFFFNFNNNNNFFFNF)
r�r�r�r�r�r�r
rr	rr�rr�r#r#r#r$r��sl��
�
�����������&�r�c@s<eZdZdZdgZededdd�eddd	�gZddd
�Zd
S)�	cmd_patchz.Apply a named patch to the current tree.

    r�stripr�zHStrip the smallest prefix containing num leading slashes from filenames.r��silentzSuppress chatter.rxNFcCsnddlm}t�d�d}|dur&d}d}|durDttjdtj�}n
t|d�}|��g}||||t	�|j
d�S)Nr)�
patch_treer<r�bufferr�)�quiet�out)Zpatchr�rJrKr�r�r`r(rcrr�)r�rXr�r�r�r�Zmy_fileZpatchesr#r#r$r��s

z
cmd_patch.run)NNF)	r�r�r�r�r�r
rr�r�r#r#r#r$r��s�
�r�c@s"eZdZdZdgZdZdd�ZdS)�cmd_resolve_locationzExpand a location to a full URL.

    :Examples:
        Look up a Launchpad URL.

            brz resolve-location lp:brz
    r8TcCs8ddlm}||�}t�||jj�}|j�d|�dS)Nrr`r�)r8rar5rIr�r�r�)r�r8rar�rSr#r#r$r��szcmd_resolve_location.runN)r�r�r�r�r�r�r�r#r#r#r$r��sr�cCs�dgdfdgdfdgdfdgdfd	gdfd
gdfdgdfd
dgdfdgdfdgdfdgdfdgdfdgdff
D]\}}}t�|||�qndS)NZ
cmd_bisectz
breezy.bisectZcmd_bundle_infozbreezy.bzr.bundle.commandsZ
cmd_configz
breezy.configZcmd_dump_btreezbreezy.bzr.debug_commandsZcmd_file_idZ
cmd_file_pathZcmd_version_infozbreezy.cmd_version_infoZcmd_resolveZresolvedzbreezy.conflictsZ
cmd_conflictsZcmd_pingzbreezy.bzr.smart.pingZcmd_sign_my_commitsz breezy.commit_signature_commandsZcmd_verify_signaturesZcmd_test_scriptzbreezy.cmd_test_script)rZ
register_lazy)rAr�Zmodule_namer#r#r$�_register_lazy_builtins�s
�r�)N)N)N)N)NNN)N)NN)FFFrU)�r�Z
__future__rr�r�r�Z
breezy.bzrr�Z
breezy.gitr�rr�globalsr�rrrrPr	r
rrr
rrrZsixishrrrrZtracerrrrrr%r0r9r;r?rHrZr_rdrhrkrlr�r�r�r�r�r�r�r�rrr$r2rXrmr�r�r�r�r�r�r�r�r�r�r�r�r�r	r
rrrrrrArTrWrXrYrlrmrrrsrur�r�r�r�r�r�r�r�r�r�r�r�rr)r.r3r6r7r9rArCrFrIrMrQrVrWr\r_rbrirmror{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r#r#r#r$�<module>s(





!

f:.6/9f/BO2I q,7"yE@'

x`K	F<AFl
]O
=$!24-y,2/jtCPPsi"#Y!$-3