
    	^c^                    N
   d dl Zd dlZd dlZd dlZddlmZ ddlmZm	Z	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZm Z!m"Z"m#Z#m$Z$m%Z%m&Z&mZm'Z'm(Z(m)Z)m*Z*m+Z,m-Z-m.Z.m/Z/m0Z0m1Z2 ddl3m4Z4m5Z5 dd	l6m7Z8 ej9        rd d
l:m;Z;m<Z< e;e<fD ]Z=e=sJ e0j>        Z>ddd ed          fgZ?ddd ed          fgZ@ddd ed           ed          fddd ed           ed          fddd ed          fgZAddg  ed           ed          fddg  ed           ed          fgZBd d!d ed"           ed#          fd$d%d ed&           ed'          fgZCd(d)d ed*           ed+          fd,d-d ed.           ed/          fgZDd0d1d ed2          fd3d4d ed5          fgZEd6d7d ed8           ed9          fgZFdd:d ed;           ed<          fd6d7d ed8           ed9          fgZGd=d>d ed?          fd@dAd edB          fd$dCd edD           edE          fdFdGd edH          fddId edJ          fdKdLd edM          fgeGz   ZHdNdOd edP          fd@dAd edQ          fddRd edS          fddTd edU          fgZIdVdWd edX          fdYdZd ed[          fd\d]d ed^          fd_d`d eda          fgZJddbd edc          fd=ddd ede          fddfd edg          fgeJz   d3dhd edi           edE          fddId edJ          fddjd edk           edl          fgz   ZKdmdnd edo           edp          fgZLdqdrd eds           edt          fgZMdudvd edw          fgZNdxdydz ed{          fd d|dz ed}          fdd~d ed          fgZOdZPd ZQd ZRd ZSd ZTd ZUd ZVd ZWd ZXd ZYddZZddZ[d Z\ G d d          Z]d Z^d Z_ ej`        d           G d d                      Zad ZbddZcddZdd Zed ZfddZgd Zhd Zi	 ddZjd Zkd ZlddZmddZnddZod Zpd Zq G d d          ZrddZsddZtd ZuddZ g Zvg Zwi Zxi Zyd Zzg Z{i Z|d Z}d Z~d Zd Z	 	 	 	 ddZddZddZd Zd Zd Zd Zd Z	 ddZd Zd Zd Zd Zd Zd ZddZ	 	 	 	 ddZdÄ ZdĄ Zdń ZddƄZdǄ ZdȄ Z	 	 ddɄZ e0j                    Z e0j                    Z e0j                    ZddʄZd˄ Zd̄ Zd̈́ Zd΄ Zdτ ZdЄ Zdф Zd҄ ZdS )    N   )_)hexnullrevshort)getattropensetattr)attr)	bookmarks	changelogcopiescrecorddirstateguardencodingerror	formatter
logcmdutilmatchmerge
mergestate	mergeutilobsoletepatchpathutilphasespycompatrepairrevlogrewriteutilscmutilstatesubrepoutil
templatekw	templaterutilvfs)dateutil
stringutil)	constants)AnyDict   ns   dry-runs)   do not perform actions, just print output    s   confirms   ask before applying actions   es   sshs   specify ssh command to uses   CMDs	   remotecmds,   specify hg command to run on the remote sides   insecures>   do not verify server certificate (ignoring web.cacerts config)   Is   includes)   include names matching the given patternss   PATTERN   Xs   excludes)   exclude names matching the given patterns   m   messages   use text as commit messages   TEXT   l   logfiles   read commit message from files   FILE   d   dates(   record the specified date as commit dates   DATE   u   users&   record the specified user as committers   USER   Ds   currentdates&   record the current date as commit date   Us   currentusers$   record the current user as committer   Ts   templates   display with templates   TEMPLATEs   styles,   display using template map file (DEPRECATED)s   STYLE   ps   patchs
   show patch   gs   gits   use git extended diff formats   limits!   limit number of changes displayeds   NUM   Ms	   no-mergess   do not show mergess   stats(   output diffstat-style summary of changes   Gs   graphs   show the revision DAG   as   texts   treat all files as texts0   use git extended diff format (DEFAULT: diff.git)s   binarys+   generate binary diffs in git mode (default)s   nodatess   omit dates from diff headers   ws   ignore-all-spaces'   ignore white space when comparing lines   bs   ignore-space-changes+   ignore changes in the amount of white space   Bs   ignore-blank-liness(   ignore changes whose lines are all blank   Zs   ignore-space-at-eols#   ignore changes in whitespace at EOLs   noprefixs&   omit a/ and b/ prefixes from filenamess   show-functions>   show which function each change is in (DEFAULT: diff.showfunc)s   reverses&   produce a diff that undoes the changess   unifieds"   number of lines of context to shows   roots&   produce diffs relative to subdirectorys   DIR   ts   tools   specify merge tools   TOOL   s
   similaritys-   guess renamed files by similarity (0<=s<=100)s
   SIMILARITY   S   subreposs   recurse into subrepositories   c	   changelogFs   open changelog   manifests   open manifest   dirs   open directory manifests:   ^HG: ------------------------ >8 ------------------------$c                     d }d}|D ]S}|                      |          r<|r8t          j        t          d           ||           ||          fz            |}T|S )zabort if more than one of the arguments are in opts

    Returns the unique argument or None if none of them were specified.
    c                 R    t          j        |                               dd          S )N   _   -)r   sysbytesreplacenames    3/usr/lib/python3/dist-packages/mercurial/cmdutil.py
to_displayz)check_at_most_one_arg.<locals>.to_display  s#     &&..tT:::r.   Ns!   cannot specify both --%s and --%s)getr   
InputErrorr   )optsargsrX   previousxs        rW   check_at_most_one_argr_     s    ; ; ; H  88A;; 	 &:;;!z(++ZZ]];<   HOr.   c                 2    |D ]}t          | ||           dS )zabort if the first argument is given along with any of the others

    Unlike check_at_most_one_arg(), `others` are not mutually exclusive
    among themselves, and they're passed as a single collection.
    N)r_   )r[   firstothersothers       rW   check_incompatible_argumentsrd   %  s2      2 2dE511112 2r.   c                    t          |dd           t          |dd           d}|                    d          rdt          j                    z  |d<   n[|                    d          sF|                     dd          r0|                    d          dt          j                    z  |d<   d
}|                    d          r|                                 |d<   |S )zmodify commit options dict to handle related options

    The return value indicates that ``rewrite.update-timestamp`` is the reason
    the ``date`` option is set.
    datecurrentdateusercurrentuserFs   %d %d   rewrites   update-timestampNT)r_   rY   r(   makedate
configboolusername)uir[   datemaydiffers      rW   resolve_commit_optionsrp   /  s     $666$666Mxx ("3"5"55VHHVMM*&9:: HH]##+("3"5"55Vxx %{{}}Vr.   c                     |                      d          }|sdS t          |          dk    r!t          j        t	          d                    d|v r!t          j        t	          d                    dS )z!make sure note is of valid formatnoteN   s*   cannot store a note of more than 255 bytes   
s   note cannot contain a newline)rY   lenr   rZ   r   )r[   rr   s     rW   check_note_sizerv   J  su     88FD 
4yy3q!NOOPPP}}q!ABBCCC }r.   c                 R    t           j        t          j        f}t	          | |          S N)
crecordmoduihunkr   
recordhunk
isinstance)r^   hunkclassess     rW   ishunkr~   W  s"    $e&67Ka%%%r.   c                 R    t           j        t          j        f}t	          | |          S rx   )ry   uiheaderr   headerr|   )r^   headerclassess     rW   isheaderr   \  s!    (%,7Ma'''r.   c                 t   t                      }t                      }| D ]}t          |          r|                                rq|                    |                                           |                    t          |                                          |                                hz
             ||fS rx   )setr   	isnewfileaddfilenameupdatefiles)chunksnewlyaddedandmodifiedfilesalsorestorechunks       rW   newandmodifiedr   a  s    !$%%K H HE?? 	Hu00 	H&**5>>+;+;<<<s5;;==11U^^5E5E4FFGGG%{22r.   c                    |                      d          }t          |          }g }|D ]J}d|v rD|                    dd          }||vr*|                    |           |                    |           K|                    |           |S )N   |rR   r.   )splitr   rT   r   appendextend)cmdbase_aliasesall_aliasesextra_aliasesaliasfolded_aliass         rW   parsealiasesr   k  s    99T??Ll##KM 3 35== ==s33L;..---$$\222&&&r.   c                 L    d | j         fd}t          | d|           S )Nc                     |                     dd          }t          j        fd          D ]\  }} | |||z              d S )Nlabelr.   c                       S rx    )r\   s   rW   <lambda>z8setupwrapcolorwrite.<locals>.wrapwrite.<locals>.<lambda>}  s     r.   r   )popr   	difflabel)origr\   kwr   r   ls    `    rW   	wrapwritez&setupwrapcolorwrite.<locals>.wrapwrite{  s_    w$$55 	) 	)HE1Deai(((((	) 	)r.   c                       g| R i |S rx   r   )r\   kwargsoldwriter   s     rW   wrapz!setupwrapcolorwrite.<locals>.wrap  s#    y3D333F333r.   write)r   r
   )rn   r   r   r   s     @@rW   setupwrapcolorwriter   y  sS    ) ) )
 xH4 4 4 4 4 4 BOr.   c                 n   	 |rE|r t          j        |t           j                  }nt           j        }t          j        | |||          S nV# t           j        $ rD}|                     d|z             |                     t          d                     Y d }~nd }~ww xY wt          j        | |||          S )N   %s
s   falling back to text mode
)	ry   testdecoratortestchunkselectorchunkselectorfilterpatchfallbackerrorwarnr   r   )rn   originalhunks	usecursestestfiler   	operationrecordfnes           rW   filterchunksr     s    3 
	 4%3j:  &3)M8Y  
	 # 3 3 3
!
011222222223 RyAAAs   AA
 
B:BBc                     t          j        |           }|                     dd          }t          |           }	 t	          | |||||          \  }}|| _        n# || _        w xY w||fS )a  Prompts the user to filter the originalhunks and return a list of
    selected hunks.
    *operation* is used for to build ui messages to indicate the user what
    kind of filtering they are doing: reverting, committing, shelving, etc.
    (see patch.filterpatch).
       experimentals   crecordtest)ry   checkcursesconfigr   r   r   )	rn   r   r   r   r   r   r   	newchunksnewoptss	            rW   recordfilterr     s     &r**Iyy.99H"2&&H)y(E9
 
	7 8gs   A 	A#c                 ^  
 t          j        |          }|                                 s8|rt          d          |z  }nt          d          }t	          j        |          |                    d          s|                                  fd

fd}	t          | ||	|          S )Ns)   running non-interactively, use %s insteads   running non-interactivelyr9   c                   *+, |                     d          st          d           d         }t          |                                          dk    }|r!t	          j        t          d                    d }|                     d          }|st          j        ||          }	                    |	          }	d
di}
j
                            |
d          5  t          j	        t          j        |	j                  t          j        |	j                  t          j        |	j                  t          j        |	j                  t          j        |	j                  t          j        |	j                  t          j        |	j                            }t-          j        j
        |||d          \  }}}|D ]B}||v r<|                    |                              d          }t	          j        |          C	 ddd           n# 1 swxY w Y   |s                    |||	|           t9          j        | |ddd          }d|_        d|_        d|_         t9          j!        |	|          }t9          j"        |          }t          j#        d         0          }	  /| ||          \  }}nq# t          j$        $ r)}t	          j        t          d          |z            d}~wt          j%        $ r)}t	          j&        t          d          |z            d}~ww xY w|'                    |           tQ          |          \  ,}tS                      *|D ]E}tU          |          r4*'                    tS          |+                                                     F|	j        |	j        z   |	j        z   }*fd|D             }|s$| 	                    t          d                     dS tS          |	j                  +-r|}n+,fd|D             }i }|r@j,        -                    d          }	 t]          j/        |           n# t`          $ r Y nw xY w	 |D ]}tc          j2        t\          j3        4                    |          dz   |          \  }} t]          j5        |           | 6                    d|| fz             to          j8        9                    |          | d           | ||<   tu                      }!|D ]/}"|";                                }#|#|v r|"<                    |!           0|!=                                }$|!>                    d           |                     dd          rt~          j@        t~          jA        z   |!B                                z   }%| C                    |%ddj3                   }&|!D                    d           |!<                    |&           |!>                    d           fd!,D              |rSt          jE        tS          |F                                          |z            }'t          jH        d         |'"           |$r	 | 6                    d#           | 6                    |!I                                           t9          jJ        | |!dd$           nu# t          j$        $ r+}t	          j        tc          jK        |                    d}~wt          j%        $ r+}t	          j&        tc          jK        |                    d}~ww xY w~!fd%|D             } .| g|R i tc          jL        |          	 jM        }(|N                                D ]\  })} | 6                    d&| |)fz             |(O                    |)          jP        rE|(Q                                5  |(R                    |)ddd'           ddd           n# 1 swxY w Y   to          j8        | 9                    |)          d           t]          jS        |            |rt]          jT        |           S S # t          $ r Y S w xY w# 	 jM        }(|N                                D ]\  })} | 6                    d&| |)fz             |(O                    |)          jP        rE|(Q                                5  |(R                    |)ddd'           ddd           n# 1 swxY w Y   to          j8        | 9                    |)          d           t]          jS        |            |rt]          jT        |           w w # t          $ r Y w w xY wxY w)(a%  This is generic record driver.

        Its job is to interactively filter local changes, and
        accordingly prepare working directory into a state in which the
        job can be delegated to a non-interactive commit command such as
        'commit' or 'qrefresh'.

        After the actual job is done by non-interactive command, the
        working directory is restored to its original state.

        In the end we'll record interesting changes, and everything else
        will be left in place, so the user can continue working.
        s   interactive-unshelveT)commitNr   s9   cannot partially commit a merge (use "hg commit" instead)c                 4    t          j        d| |fz            )Ns   %s: %s)r   rZ   )fmsgs     rW   failz*dorecord.<locals>.recordfunc.<locals>.fail  s    "93x#7888r.      forcer   )   uis   commitsubreposs   record)force   commandss   commit.interactive.)r[   
whitespacesectionconfigprefix)changesr[      error parsing patch: %s   error applying patch: %sc                     g | ]}|v |	S r   r   ).0r   
contenderss     rW   
<listcomp>z0dorecord.<locals>.recordfunc.<locals>.<listcomp>  s    :::!!z//A///r.   s   no changes to record
r   c                 $    g | ]}|v s|v 
|S r   r   )r   r   modifiedr   s     rW   r   z0dorecord.<locals>.recordfunc.<locals>.<listcomp>*  s7       ==A)C$C$C $C$C$Cr.   s   record-backups   .)prefixdirs   backup %r as %r
copystats   reviewFr.   s   diff)actionrepopathc                 ^    g | ])}t          j                            |                    *S r   )osunlinkwjoinr   crepos     rW   r   z0dorecord.<locals>.recordfunc.<locals>.<listcomp>W  s-    JJJ!RYtzz!}}%%JJJr.   )matchers   applying patch
eolmodec                 :    g | ]}                     |          S r   )r   )r   nfr   s     rW   r   z0dorecord.<locals>.recordfunc.<locals>.<listcomp>n  s#    :::2

2:::r.   s   restoring %r to %r

p1_tracked
wc_trackedpossibly_dirty)VrY   checkunfinishedru   parentsr   rZ   r   matchmodbadmatchstatusrn   configoverrider!   copymodcopyr   addedremoveddeletedunknownignoredcleanr#   	precommitsubdirtyreasonAbortcheckcommitpatternsr   difffeatureoptsnodatesgitshowfuncdiff
parsepatchr   PatchParseErrorPatchApplicationError
StateErrorr   r   r   r   r   r'   joinr   mkdirFileExistsErrorr   mkstemppathbasenameclosedebugr&   copyfiler   stringior   r   tellseekry   diffhelptextpatchhelptextreadedittruncate
matchfileskeysmergemod	revert_togetvalueinternalpatchbytestr	strkwargsdirstateitems	get_entrymaybe_cleanparentchangeupdate_filer   rmdirOSError)1rn   r   messager   r[   wctxr   r   r   r   	overrides	tmpstatussubs
commitsubsnewstatesr  diffoptsoriginaldifforiginal_headersr   r   errr   hchangednewfilestobackupbackups	backupdirr   fdtmpnamefpr   fnamedopatch	patchtextreviewedpatchmr)  realnamer   r   r   	backupall
commitfuncfilterfnpatss1    `                                        @@@rW   
recordfunczdorecord.<locals>.recordfunc  s
    xx/00 	/D....DzDLLNN##a' 	"1   	9 	9 	9 "" 	3%eT22E5))/6	W##Iy99 	3 	3V_--V\**V^,,V^,,V^,,V^,,V\** I *5)>y%t* * *&D*h  3 3
??"&((1++"9"9$"?"?K+k222 #3!	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3*  	@$$T5&$???(/
 
 
   z$XFFF +L99d4j$//	I&hr+;UCCOFGG$ 	H 	H 	H"1%?#@#@3#FGGG* 	I 	I 	I"1%@#A#AC#GHHH	IG 3A2H2H/"KUU
 	2 	2A{{ 2!!#aggii..111/FL06>A::::w::: 	IIa1223331v''  	HH    !  H
  	&788I####"   ]	 % %&.7++A..59  G -G<===djjmmWtDDDD$

B    

G##GGBKKKggiiGGGAJJJ xx	5)) + ./ggii  
 !#s7TY !( ! ! A'''


JJJJ/IJJJJ :&tS-@-@;-NOO"4:q9999  BBHH0111HHR[[]]+++'D"aFFFFF, B B B*8+;C+@+@AAA2 B B B*8+;C+@+@AAAB ;::::::H:b$NNNNX5G5M5MNN!=)0 ' '%HgHH47JJKKK))(33?  &2244  $00 (+/+//3	 1                  M'4::h+?+?$OOOOIg&&&& (HY''''(   A!=)0 ' '%HgHH47JJKKK))(33?  &2244  $00 (+/+//3	 1                  M'4::h+?+?$OOOOIg&&&& (HY''''(   s	   D#HHH*J; ;L)
$K..L) $L$$L);Q 
QQ!H
a% ,A[ a% \4&[77\4	&\//\440a% %A(a_3'a3_77a:_7;Aa
a"!a"%e''A(ec5	)e5c99e<c9=Aee'
e$!e'#e$$e'c                 ~    |                                 5   | ||||          cd d d            S # 1 swxY w Y   d S rx   )wlock)rn   r   r1  r   r[   rP  s        rW   recordinwlockzdorecord.<locals>.recordinwlock  s    ZZ\\ 	> 	>:b$==	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   266)	r   byteskwargsinteractiver   r   rZ   rY   rm   r   )rn   r   rM  
cmdsuggestrL  rN  rO  r[   r   rS  rP  s     ` ```   @rW   dorecordrW    s     %%D>> $ 	2@AAJNCC011Cs### 88G 
T T T T T T T Tl> > > > > "dM4666r.   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )dirnodea  
    Represent a directory in user working copy with information required for
    the purpose of tersing its status.

    path is the path to the directory, without a trailing '/'

    statuses is a set of statuses of all files in this directory (this includes
    all the files in all the subdirectories too)

    files is a list of files which are direct child of this directory

    subdirs is a dictionary of sub-directory name as the key and it's own
    dirnode object as the value
    c                 V    || _         t                      | _        g | _        i | _        d S rx   )r  r   statusesr   subdirs)selfdirpaths     rW   __init__zdirnode.__init__  s&    	
r.   c                 >    | j                             ||f           dS )z/Add a file in this directory as a direct child.N)r   r   )r]  r   r   s      rW   _addfileindirzdirnode._addfileindir  s#    
8V,-----r.   c                 n   d|v ru|                     dd          \  }}|| j        vr1t          j        | j        |          }t          |          | j        |<   | j        |                             ||           n|                     ||           || j        vr| j        	                    |           dS dS )z
        Add a file to this directory or to its direct parent directory.

        If the file is not direct child of this directory, we traverse to the
        directory of which this file is a direct child of and add the file
        there.
           /r   N)
r   r\  r   r  r  rY  addfilera  r[  r   )r]  r   r   subdirfilep
subdirpaths         rW   rd  zdirnode.addfile  s     8$NN433MFE T\))%]49f==
'.z':':V$ L ((7777 x000&&Mf%%%%% '&r.   c              #   `   K   | j         D ]#\  }}|t          j        | j        |          fV  $dS )z=Yield (status, path) for files directly under this directory.N)r   r   r  r  )r]  r   sts      rW   iterfilepathszdirnode.iterfilepaths  sG      Z 	2 	2EArhmDIq1111111	2 	2r.   c              #   N  K   t          | j                  dk    r-| j                                        }||v r|| j        dz   fV  dS |                                 D ]\  }}||fV  | j                                        D ]#}|                    |          D ]\  }}||fV  $dS )a  
        Yield (status, path) obtained by processing the status of this
        dirnode.

        terseargs is the string of arguments passed by the user with `--terse`
        flag.

        Following are the cases which can happen:

        1) All the files in the directory (including all the files in its
        subdirectories) share the same status and the user has asked us to terse
        that status. -> yield (status, dirpath).  dirpath will end in '/'.

        2) Otherwise, we do following:

                a) Yield (status, filepath)  for all the files which are in this
                    directory (only the ones in this directory, not the subdirs)

                b) Recurse the function on all the subdirectories of this
                   directory
        r   rc  N)ru   r[  r   r  rj  r\  values	tersewalk)r]  	terseargsonlystri  fpathdirobjs         rW   rm  zdirnode.tersewalk  s      . t}""]&&((F ""di$..... ++-- 	 	IBe)OOOO l))++ 	  	 F#--i88    	E%i 	  	 r.   N)	__name__
__module____qualname____doc__r_  ra  rd  rj  rm  r   r.   rW   rY  rY    si           . . .& & &82 2 2
'  '  '  '  ' r.   rY  c                    d}t          j        |          D ]*}||vr$t          j        t	          d          |z            +t          d          }d}i }|D ]:}|dd         }t          | |          D ]}	|                    |	|           g ||<   ;|                                D ] \  }
}||
         	                    |           !|j
                                        D ]8}|                    |          D ] \  }
}	||
         	                    |	           !9g }|D ]7}
||
                                          |	                    ||
                    8t          j        | S )a  
    Terse the status if all the files in a directory shares the same status.

    statuslist is scmutil.status() object which contains a list of files for
    each status.
    terseargs is string which is passed by the user as the argument to `--terse`
    flag.

    The function makes a tree of objects of dirnode class, and at each node it
    stores the information required to know whether we can terse a certain
    directory or not.
    )r2   rA      rr6   r8      irK   s   '%s' not recognizedr.   )s   modifieds   addeds   deleteds   clean   unknowns   ignoreds   removedr   r   )r   r'  r   rZ   r   rY  r   rd  rj  r   r\  rl  rm  sortr!   r   )
statuslistrn  allstr8  rootobjpstatus	tersedictattrname
statuscharr   ri  rp  re  
tersedlists                 rW   tersedirr    s    7E i(( B BE>>"1%;#<#<q#@AAA  cllGG I # #ac]
X.. 	+ 	+AOOAz**** "	* **,, $ $	E"U#### /((** $ $%%i00 	$ 	$EBbM  ####	$ J ) )")B-((((>:&&r.   c                 r    |                                  }d |D             }d                    |          dz   S )z0Surround lineswith a comment char and a new linec                     g | ]}d |z  S )s   # %sr   )r   lines     rW   r   z!_commentlines.<locals>.<listcomp>=  s    777gn777r.   rt   )
splitlinesr  )rawlinescommentedliness      rW   _commentlinesr  :  s;    NNE77777N::n%%--r.   T)frozenc                       e Zd Z ej                    Z ej                    Z ej                    Z ej                    Z ej                    Z	 ej        d e
                      ZdZd Zd Zd ZdS )
morestatusF)initdefaults   status.morestatusc                     | j                             |           | j        r!|| j        v r|                    d           d S d S d S )NT)
unresolved)_formattedpathsr   activemergeunresolvedpathsdata)r]  r  fms      rW   
formatfilezmorestatus.formatfileK  s[      &&& 	%(< < <GGtG$$$$$	% 	% < <r.   c                 "   | j         s| j        r*|                                 |                    d           | j         r^|                    | j                    t	          d          | j         z  }|                    dt          |          z  | j                   | j        r|                    | j                   |                     |           | j        r3|                    dt          | j                  z  | j                   d S d S )Ns
   morestatus)itemtype)
unfinisheds.   The repository is in an unfinished *%s* state.r   r   )unfinishedmsg)	unfinishedopr  	startitemr  r   plainr  _label_formatconflicts)r]  r  statemsgs      rW   formatfooterzmorestatus.formatfooterP  s'    	, 2 	,LLNNNGG]G+++ 	KGGt0G111CDD#$  HHW}X666dkHJJJ 	6GG$"4G555 	b!!! 	HH-(:;;;4;      	 	r.   c                      j         sd S  j        rd                     fd j        D                       }t          d          |z  } j        D ]S}| j        v r|                                 |                     j                   |                    d|d           Tnt          d          }|	                    d	t          |          z   j        
           d S )Nrt   c                 x    g | ]6}d t          j        j        j        t	          j                    |          z  7S )s       %s)r&   pathtor   rootr   getcwd)r   r  r]  s     rW   r   z/morestatus._formatconflicts.<locals>.<listcomp>m  sN         k$).(/2C2CTJJK  r.   sS   Unresolved merge conflicts:

%s

To mark files as resolved:  hg resolve --mark FILE)r   s   fileT)r  r  r  s   No unresolved merge conflicts.r   r   )r  r  r  r   r  r  contextr   r  r  r  r  )r]  r  mergeliststrr   r   s   `    rW   r  zmorestatus._formatconflictsg  s'    	F !	7 ::    !% 4   L 6    ) 	C 	C,,,

	
*** qTBBBB	C 566C
=---T[AAAAAr.   N)rr  rs  rt  r   ibr   r  r  r  r  r   r  r  r  r  r  r   r.   rW   r  r  A  s        4799D4799LDGIIM$'))KdgiiOdg5##%%888O!F% % %
  .'B 'B 'B 'B 'Br.   r  c                 "   t          j        |           }t          j                            |           }|                                }|s|sdS dx}x}}|r|\  }}|r!t          |                                          }t          | ||||          S )z=Returns a morestatus object if the repo has unfinished state.N)	statemodgetrepostatemergestatemodr   r  activesortedr  r  )r   
statetupler   r  r  r  r  s          rW   readmorestatusr    s    &t,,J)..t44J##%%K k t044L4=: 1&0#m 5J113344
lM;
  r.   c                    i }i }| |v r| g}n|                                 }g }|D ]}t          |          }|                    |           d}	| |v r| }	n |s|D ]}
|
                    |           r|
}	 n|	K|d                             d          s|	                    d          r|||         f||	<   |||         f||	<   |s|r|}||fS )z
    Return cmd -> (aliases, command table entry)
    for each matching command.
    Return debug commands (or their aliases) only if no normal command matches.
    Nr   s   debug)r"  r   r   
startswith)r   tablestrictchoicedebugchoicer"  allcmdsr   aliasesfoundas              rW   findpossibler    s+    FK
e||uzz||G 4 4q//w'>>EE 	  <<$$ EE qz$$X.. 4%2B2B82L2L 4&-uQx%8E""!(%( 3u k 7?r.   c                 ,   t          | ||          \  }}| |v r||          S t          |          dk    r$t          |          }t          j        | |          |r't          |                                          d         S t          j        | |          )z9Return (aliases, command table entry) for command string.r   r   )r  ru   r  r   AmbiguousCommandlistrl  UnknownCommand)r   r  r  r  r  clists         rW   findcmdr    s    "3v66OFG
f}}c{
6{{Qv$S%000 (FMMOO$$Q''

sG
,
,,r.   c                 	   |                                 5  |                                5  |                    d          5  t          |           t	          j        ||          }|st          j        d          |                    d|          }t          |          dk    r!t          j        t          d                    t          j        ||d           ||                                         }d |                                D             }|                    d          s;||vr7||                                v r!t          j        t          d	                    |                    d
|          r!t          j        t          d                    i }ddlm}	 |D ]}
||
                                         }||k    r&fd}|                     dt+                                                    ||fz                                             }t+                                                    |d<                                                                   }                                                                }||v r||         d         }||v r||         d         }|	                    |||f                                                                |                                                                ||	  	        }|                    |          }|f|                                <   |                     dt+          |          z             tA          j!        ||dd           |d         }t          |                                          dk    r_|                    |                                                                          }|$ddlm"} |#                    ||d         d           | $                    t          d          t          |          z             ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z-Change the branch name of given revs to labels   branchess   empty revision set
   roots(%ld)r   s,   cannot change branch of non-linear revisionss   change branch ofc                 6    h | ]}|                                 S r   )branch)r   parents     rW   	<setcomp>zchangebranch.<locals>.<setcomp>  s     <<<6v}}<<<r.   r   s(   a branch of the same name already existss   heads(%ld) - head()s)   cannot change branch in middle of a stackr  c                 B    	 |         S # t           j        $ r Y d S w xY wrx   )r   ManifestLookupError)r   newctxr  ctxs      rW   	filectxfnzchangebranch.<locals>.filectxfn  s7     t9$0      44 s    s*   changing branch of '%s' from '%s' to '%s'
s   branch_changer   )rh   rf   extrar  s   new node id is %s
s   branch-changeTfixphaseN)hg)
quietemptys    changed branch on %d changesets
)%rR  locktransactionbailifchangedr   revranger   rZ   revsru   r   r    precheckra   r   rY   	branchmap r  r  r  r   noder  p1p2memctxdescriptionr   rh   rf   	commitctxr!   cleanupnodesr  r   r   )rn   r   r  r   r[   rootsr  rpbreplacementsr  rev	oldbranchr  r  r  r  mcnewnoder2  newidr  r  s                        @rW   changebranchr    s    
 aO aOtyy{{ aO aOD$4$4[$A$A aO aOd"4.. 	:"#8999		-..u::>>"ABB   	T4)<===EKKMM"<<T\\^^<<<""	S  ))))"=>>  
 99+T22 	">??    	 +	< +	<Cs)C

IE!!          HH>sxxzz??Iu56   IIKKE&)#((**ooE"# BB\!!!"%a(\!!!"%a(R!!		XXZZXXZZ   
 
B nnR((G(/zL$HH+c'll:;;;; 	, 04	
 	
 	
 	

 Dzt||~~!## $$TWWYY^^%5%566E  !     		$aT	:::
		!899C<M<MMNNNCaO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aO aOsY   Q?Q'PQQ'QQ'QQ'Q?'Q+	+Q?.Q+	/Q??RRc                 L   t           j                            t           j                            | d                    sf| t           j                            |           } }| |k    rd S t           j                            t           j                            | d                    f| S )Ns   .hg)r   r  isdirr  dirname)poldps     rW   findrepor  B  s|    gmmBGLLF3344 RW__Q''a994 gmmBGLLF3344 
 Hr.   c                    |rE| j                                         | j        k    r#t          j        t          d          |          |                                 }|j        s|j        s|j	        s|j
        r#t          j        t          d          |          | d         }t          |j                  D ]+}|                    |                              |           ,dS )zenforce the precondition that working directory must be clean.

    'merge' can be set to false if a pending uncommitted merge should be
    ignored (such as when 'update --check' runs).

    'hint' is the usual hint given to Abort exception.
    s   outstanding uncommitted mergehints   uncommitted changesN)r)  r  nullidr   r  r   r   r   r   r   r   r  substater  r  )r   r   r  ri  r  r8  s         rW   r  r  K  s      O!!##t{22q!ABBNNNN	B	{ Ebh E"* E
 Eq!788tDDDD
t*CCL!! , ,

  d ++++, ,r.   c                    t          |dd           |                    d          }|                    d          }|s|r	 t          |          r| j                                        }n9d                    t          j        |                                                    }nO# t          $ rB}t          j        t          d          |t          j        |j                  fz            d}~ww xY w|S )z1get the log message according to -m and -l optionr3   r5   rt   s"   can't read commit message '%s': %sN)r_   rY   isstdiofilenamefinr  r  r&   readfiler  IOErrorr   r  r   r   
strtolocalstrerror)rn   r[   r1  logfileinsts        rW   
logmessager  ^  s     $
J777hhz""Ghhz""G 
w 
		w'' J&++--**T]7%;%;%F%F%H%HII 	 	 	+788H/>>?@  	
 Ns   A"B$ $
C0.=C++C0c                     t          | t                    r| r|dz   S n*t          |                                           dk    r|dz   S |dz   S )a  return appropriate editform name (referencing a committemplate)

    'ctxorbool' is either a ctx to be committed, or a bool indicating whether
    merging is committed.

    This returns baseformname with '.merge' appended if it is a merge,
    otherwise '.normal' is appended.
    s   .merger   s   .normal)r|   boolru   r   )	ctxorboolbaseformnames     rW   mergeeditformr  t  sc     )T"" ( 	,)++	,	Y  	!	!A	%	%i''*$$r.   c                 >    | ssrfdS rfdS t           S )a&  get appropriate commit message editor according to '--edit' option

    'finishdesc' is a function to be called with edited commit message
    (= 'description' of the new changeset) just after editing, but
    before checking empty-ness. It should return actual text to be
    stored into history. This allows to change description before
    storing.

    'extramsg' is a extra message to be shown in the editor instead of
    'Leave message empty to abort commit' line. 'HG: ' prefix and EOL
    is automatically added.

    'editform' is a dot-separated list of names, to distinguish
    the purpose of commit text editing.

    'getcommiteditor' returns 'commitforceeditor' regardless of
    'edit', if one of 'finishdesc' or 'extramsg' is specified, because
    they are specific for usage in MQ.
    c                 .    t          | ||          S )N)
finishdescextramsgeditform)commitforceeditor)rr   r8  r  r  r
  s      rW   r   z!getcommiteditor.<locals>.<lambda>  s$    0q!
X 
  
  
 r.   c                 *    t          | ||          S )Nr  commiteditor)r  r   r8  r  s      rW   r   z!getcommiteditor.<locals>.<lambda>  s    |Aq!hGGG r.   r  )r  r
  r  r  r[   s    ``` rW   getcommiteditorr    s_    ,  z X 
 
 
 
 
 
 	
 
 GGGGGr.   c                    g }t          j        | d          D ]Y\  }}}|dk    r0|                    t          j        | ||                              <|                    | ||                    Zd                    |          S )NTr     stringr.   )r%   scantemplater   r)   	escapestrr  )tmplpartstypstartends        rW   _escapecommandtemplater    s    E$1$DAAA * *UC)LL-d59o>>????LLeCi))))88E??r.   c                 x    |s|S t          j        | t          |                    }|                    |          S )a  Expand a literal template 'tmpl' in a way suitable for command line

    '\' in outermost string is not taken as an escape character because it
    is a directory separator on Windows.

    >>> from . import ui as uimod
    >>> ui = uimod.ui()
    >>> rendercommandtemplate(ui, b'c:\\{path}', {b'path': b'foo'})
    'c:\\foo'
    >>> rendercommandtemplate(ui, b'{"c:\\{path}"}', {'path': b'foo'})
    'c:{path}'
    )r   maketemplaterr  renderdefault)rn   r  propsts       rW   rendercommandtemplater$    s>      $:4$@$@AAA??5!!!r.   c                    |                                  }t          j        |j        |          }t          j        |j        |t
          j        |          }d| i}|r|                    |           |                    |          S )zExpand a literal template 'tmpl' byte-string against one changeset

    Each props item must be a stringify-able value or a callable returning
    such value, i.e. no bare list nor dict should be passed.
    )defaults	resourcess   ctx)	r   r   templateresourcesrn   r   r$   keywordsr   r!  )r  r  r"  r   tresr#  mappings          rW   rendertemplater,    s     88::D&tw55D
 3t	 	 	A smG u??7###r.   c                     d}|r|                      dd|z  d          }|s|                      dd          }|s|}|sd}t          ||          }|                    d          d         S )z&Format a changeset summary (one line).Ns   command-templatess   oneline-summary.%ss   oneline-summarys  {separate(" ", label("oneline-summary.changeset", "{rev}:{node|short}"), join(filter(namespaces % "{ifeq(namespace, "branches", "", join(names % "{label("oneline-summary.{namespace}", name)}", " "))}"), " "))} "{label("oneline-summary.desc", desc|firstline)}"rt   r   )r   r,  r   )rn   r  commanddefault_specspectexts         rW   format_changeset_summaryr2    s    D 
yy "7'"A4
 
  Cyy-/ABB  
A 	 #t$$D::eQr.   c                 N   dddddddd}|d
|d<   |d|d<   ||d|d<   |d|d<   d|d<   d|d<   g }t          j        | d          D ]E\  }}}	|dk    r|                    | ||	                    +|}
|
|	k     r|                     d|
|	          }|dk     r0|                    t	          j        | |
|	                              n|                    t	          j        | |
|                              |dz   |	k    r!t          j        t          d                    | |dz   |dz            }|dz   }
	 |                    ||                    n2# t          $ r% t          j        t          d          |z            w xY w|
|	k     Gd
                    |          S )a  Convert old-style filename format string to template string

    >>> _buildfntemplate(b'foo-%b-%n.patch', seqno=0)
    'foo-{reporoot|basename}-{seqno}.patch'
    >>> _buildfntemplate(b'%R{tags % "{tag}"}%H')
    '{rev}{tags % "{tag}"}{node}'

    '\' in outermost strings has to be escaped because it is a directory
    separator on Windows:

    >>> _buildfntemplate(b'c:\\tmp\\%R\\%n.patch', seqno=0)
    'c:\\\\tmp\\\\{rev}\\\\{seqno}.patch'
    >>> _buildfntemplate(b'\\\\foo\\bar.patch')
    '\\\\\\\\foo\\\\bar.patch'
    >>> _buildfntemplate(b'\\{tags % "{tag}"}')
    '\\\\{tags % "{tag}"}'

    but inner strings follow the template rules (i.e. '\' is taken as an
    escape character):

    >>> _buildfntemplate(br'{"c:\tmp"}', seqno=0)
    '{"c:\\tmp"}'
    s   {node}s   {rev}s   {node|short}s$   {sub(r"[^\w]", "_", desc|firstline)}s7   {if(revwidth, pad(rev, revwidth, "0", left=True), rev)}   %s   {reporoot|basename})   H   R   hr2   rw  r4  rC   Ns   {total}   Ns   {seqno}r-   s3   {pad(seqno, total|stringify|count, "0", left=True)}s   {pathname|basename}rG   s-   {if(pathname|dirname, pathname|dirname, ".")}r6   s
   {pathname}r=   Tr  r  r      s)   incomplete format spec in output filenamer   s-   invalid format spec '%%%s' in output filenamer.   )r%   r  r   findr)   r  r   r  r   KeyErrorr  )pattotalseqnorevwidthpathnameexpandernewnamer  r  r  inr   s                rW   _buildfntemplaterE    s   2 6H$ H ##U.O/I&G$1#4@@@  UC)NN3uSy>***#ggq#&&A1uuz3C#J??@@@NN:/AaC99:::1us{{kBCC   AEAEM"AAAx{++++   kFGG!K   #gg$ 88Gs   ;E/Fc                 j    |s|S t          |fi |}t          | |t          j        |                    S rx   )rE  r,  r   rT  )r  r<  r"  r  s       rW   makefilenamerG  3  sC     
C))5))D #tX%9%%@%@AAAr.   c                     |  p| dk    S )zATrue if the given pat looks like a filename denoting stdin/stdoutrR   r   )r<  s    rW   r  r  =  s    7!cTk!r.   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )_unclosablefilec                     || _         d S rx   )_fp)r]  rE  s     rW   r_  z_unclosablefile.__init__C  s    r.   c                     d S rx   r   r]  s    rW   r  z_unclosablefile.closeF      r.   c                 *    t          | j                  S rx   )iterrL  rN  s    rW   __iter__z_unclosablefile.__iter__I  s    DH~~r.   c                 ,    t          | j        |          S rx   )r   rL  )r]  r   s     rW   __getattr__z_unclosablefile.__getattr__L  s    tx&&&r.   c                     | S rx   r   rN  s    rW   	__enter__z_unclosablefile.__enter__O  s    r.   c                     d S rx   r   )r]  exc_type	exc_valueexc_tbs       rW   __exit__z_unclosablefile.__exit__R  rO  r.   N)	rr  rs  rt  r_  r  rR  rT  rV  r[  r   r.   rW   rJ  rJ  B  sn              ' ' '      r.   rJ     wbc                     |dv}t          |          r>|                                 }|r|j        j        }n|j        j        }t          |          S t          | |fi |}t          ||          S )N)rw  s   rb)r  r   rn   foutr  rJ  rG  r	   )r  r<  moder"  writabler   rE  fns           rW   makefileobjrb  V  sx    =(Hs #xxzz 	BBBr"""	c3	(	(%	(	(BD>>r.   c                 P   |d         }|d         }|d         }d}|r|rt          d          }n=|r|rt          d          }n)|s|s|r#|rt          d          }n| st          d          }|rt          j        |          d}	| r>|r|                                 j        }	n|r{t          j        |           s!t          j        t          d	                    |                    d
          s|d
z   }| j        	                    |          }
t          |
          r|
}	nE|r| j        	                    d          }	n(|r&|                     |          }t          |          r|}	|r^t          |	t          j                  rnCt          j        |	d          r|	j        }	n&|	$t          j        t          d          |	z            |	s|s!t          j        t          d                    |s"t          j        |t          d                    t$          j                            |          s$t          j        t          d          |z            t*          j        d|z  f}t          j        t/          j        t3          j                    d          ||dd                   }	|	S )z:opens the changelog, manifest, a filelog or a given revlogrL   rM   rN   Ns:   cannot specify --changelog and --manifest at the same times5   cannot specify --changelog and --dir at the same times6   cannot specify filename with --changelog or --manifestsF   cannot specify --changelog or --manifest or --dir without a repositorys9   --dir can only be used on repos with treemanifest enabledrc  r.   s   _revlogs!   %r does not appear to be a revlogs   cannot give path to non-revlogs   invalid argumentss   revlog '%s' not founds   free-form:%sF)audit)targetradix)r   r   rZ   
unfilteredr   r!   istreemanifestendswithmanifestlog
getstorageru   filer|   r   r&   safehasattr_revlogCommandErrorr   r  isfilerevlog_constants
KIND_OTHERvfsmodr'   r   r  )r   r   file_r[   returnrevlogclmfr   r   r  dirlogfilelogrf  s                rW   openstorager{  d  s   	l	B	k	B
v,C
C	 b MNN	 	 	HII	 r S  	MNNCC 	( C  $s###A ! 	!!+AA 	)$// &0    <<%% !Dj%0055F6{{  	 ++C00AA 	ii&&G7||   	!V]++ !!Z00 I&:;;a?    
 	I"1%F#G#GHHH 	C$S!,@*A*ABBBw~~e$$ 	H"1%=#>#>#FGGG"-/FGMJx((666*
 
 

 Hr.   c                 *    t          | |||d          S )ap  Obtain a revlog backing storage of an item.

    This is similar to ``openstorage()`` except it always returns a revlog.

    In most cases, a caller cares about the main storage object - not the
    revlog backing it. Therefore, this function should only be used by code
    that needs to examine low-level revlog implementation details. e.g. debug
    commands.
    T)rv  )r{  )r   r   ru  r[   s       rW   
openrevlogr}    s     tS%DAAAAr.   c           
         !"#$%&'( t          ddg                                           #i '                    d          }                    d          !                    d          %                    d          }|r|s#!s!t          j        t          d                    t          j        |          "t          "	                                          dk    r!t          j        t          d                    nd          ""
                                &t          j        d	          (|rԉ"                                "}nt          "	                                          dk    r!t          j        t          d
                    ddlm} t!          j        "                                gd           |                              }|                    "
                                           t)          j        "|           t          j        "|          }	"                                }
|
                    "                                           t          j                  ("                    |	          D ]e}||
v r||                             d            "|	                    |          r.                     t          d           (|          z             f"                                                                5  |                    "          }|                                 }j!        
                                ""                                k    rLj!        #                                5  t          j$        |                    d d d            n# 1 swxY w Y   ""                                |gi}t          j%        |dd           d d d            n# 1 swxY w Y   d S t          j&        |          }|s!t          j        t          d                    t          |          dk    r!t          j        t          d                    |'                                }!"& (fd}"                                t!          j        "                                gd           tQ          j)        j*        #|          }"+                    |          r-t          j        t          d           (|          z            |"vr/t          j        t          d           (|          "fz            ddlm} g }|D ].} ||          }|s|D ]\  }}}|,                    |           /|s!t          j        t          d                    t          |          dk    r!t          j        t          d                    |                              }|                    "
                                           t)          j        "|           |                    ||d                                                    5  |                    "          }|                                 }j!        
                                ""                                k    rLj!        #                                5  t          j$        |                    d d d            n# 1 swxY w Y   ""                                |gi}t          j%        |dd           d d d            n# 1 swxY w Y   d S !"#%&' f
d}#$fd}#$fd}tZ          j.        /                    |          otZ          j.        0                    |           $$st          |          dk    stc          j2        |d                   r!t          j        t          d                    tg          j4        |          r$t          j        t          d          |z            |}!r|}g }|D ]2} ||          }|s|,                     ||||          |f           3|s6d }rt          d          }t          j        t          d          |          d}|D ]*\  }}|D ]"\  }} } |||  ||          |          r|dz  }#+|dk    S ) N   forget   dry_runs   afters   at_revs   --at-rev requires --afterr   s'   cannot mark/unmark copy in merge commitTlegacyrelativevalues"   cannot unmark copy in merge commitr  s   uncopy)r2  s9   %s: not unmarking as copy - file is not marked as copied
r  s"   no source or destination specifieds   no destination specifiedc                    g }                                 n
}t          j        || g	d          }|                    |          D ]} |          }|                    |          }|vrW|
v r+s(|r%                    t          d          |z             Tn(|r%                    t          d          |z             }|                    |||f           |S )NT)globbeds2   %s: not copying - file has been marked for remove
s&   %s: not copying - file is not managed
)r  r!   r   walkexactr   r   r   )r<  srcsctx_to_walkrJ  absrelr  afterr  r[   pctxrn   uipathfns          rW   walkpatzcopy.<locals>.walkpat  s*    !WWYY.ccDM+udDAAA##A&& 	+ 	+C(3--CGGCLLE#~~$;;  	!  GG !%4!" !" #&	!&   !	!  HIICO    KKc5)****r.   s8   %s: --at-rev does not support a directory as destinations)   %s: copy destination does not exist in %ss   no files to copys!   --at-rev requires a single sourcer   s   copyc           	      
  
  t          j        j        |          dv r9                    dd          \  }}j                            |          dz   |z                                 }                              }                               }j                                      }	|	j	        o|	j
         }
t          j        !                                          }|R!                    t          d          |                                                   |          fz             dS t           j                            |          }d}|ri k    rcj                                       j                                      k    r-s'!                    t          d          |z             dS d}d}s|sr|
rd         s|
rt          d          }v o-t'           fd	                                D                       }|r"rt          d
          }not          d          }n_rd}nd}rt          d          |z  }nCt          d          |z  }n0t          d          }rt          d          }nt          d          }!                    ||z             !                    |           dS rW|sSr(!                    t          d          ||fz             n'!                    t          d          ||fz             dS nRsO	 |rt!          j        |           t           j                            |          pd}t           j                            |          st!          j        |           |r0|dz   }t!          j        ||           t!          j        ||           nt5          j        ||           d}n# t8          $ r}|j        t:          j        k    r(!                    t          d          |z             d}nD!                    t          d          |t?          j         |j!                  fz             Y d }~dS Y d }~nd }~ww xY w!j"        s|sQr(!#                    t          d          ||fz             n'!#                    t          d          ||fz               <   t          j$        !            rWsWs;|r9|s7j%        &                    dd          }j'        (                     |           )                     g           d S d S d S ) Nrc  r   s*   %s: not overwriting - %s collides with %s
TFs   %s: can't copy - same file
r   s-   %s: not overwriting - file already committed
c              3   (   K   | ]}|v o|vV  d S rx   r   )r   gpctxabssrc	abstargets     rW   	<genexpr>z)copy.<locals>.copyfile.<locals>.<genexpr>  sM       H H! %BIU,BH H H H H Hr.   sP   ('hg rename --at-rev .' to record the rename in the parent of the working copy)
sL   ('hg copy --at-rev .' to record the copy in the parent of the working copy)
s   --after --forces   --forces;   ('hg rename %s' to replace the file by recording a rename)
s7   ('hg copy %s' to replace the file by recording a copy)
s"   %s: not overwriting - file exists
s+   ('hg rename --after' to record the rename)
s'   ('hg copy --after' to record the copy)
s+   %s: not recording move - %s does not exist
s+   %s: not recording copy - %s does not exist
r   s	   ~hgrenamer   s!   %s: deleted in working directory
s   %s: cannot copy - %s
s   moving %s to %s
s   copying %s to %s
)dryruncwdr      removeemptydirsr/  )*r   	canonpathr  rsplitr)  	normalizer  r   r+  trackedr   r!   checkportablerY   r   r   r   r  lexistsanyr   r   r  r  makedirsrenamer&   r  r  errnoENOENTr   r  r  verboser   dirstatecopyrn   rl   wvfs
unlinkpathforget)"r  relsrcotargetr  abspathabsname	reltargetrf  srcentryalready_commitedprevsrcexistssamefiler   looks_like_copy_in_pctxr  flags	targetdirtmp	srcexistsr  r/  r  r  r  r  r  r[   r  r  r   targetsrn   s"   `                      @rW   r  zcopy.<locals>.copyfilef  s   &ty#w??	9  )//a88GW//884?'IIKK	3//	I&&jj  ''	22 =<_b),,, ++i((GG@AAKK,,KK--   4 (( 	 f	))}&&v..$-2I2I3 3     GGA=>>JKKK4 4	 4	5 4	-= 4	> 3# /NMNNC /84.? /C H H H H H%)\\^^H H H E E+ / ! 	#$!H$ $DD
 $%!E$ $DD
 ! /$6EE$.E!  !%=!" !" #(	!( !D !"%;!" !" #(	!( !D BCCC N K     !!LMMi(((t &	   	GGIJJ!9-.   
 GGIJJ!9-.   t  	   &If%%%GOOF33;t	w}}Y// +K	*** @ </CIc3'''Ic6**** M#v???? 		 	  	  	 :--GGACDDvMNNN %IIGG344!8#6t}#E#EFG    44444 IIII	  : 	JU 	J J		!011VY4GGHHHH		!122fi5HHIII#	 	c69V	
 	
 	
 	
  	!& 	! :Y :x :**?<NOO	$$V5$999JJx     		! 	! 	! 	!s   1B5O' '
Q<1A;Q77Q<c                    t           j                            |           rt          j        j        |           }t          j        |          }r3t          t           j        	                    |          d                   nt          |          rt          t          j                  z  fd}nrfd}nfd}|S )Nr   c                 x    t           j                            t          j        |           d                    S rx   r   r  r  r&   	localpathr  deststriplens    rW   r   z,copy.<locals>.targetpathfn.<locals>.<lambda>  s*    BGLLt~a/@/@/KLL r.   c                     t           j                            t           j                            t	          j        |                               S rx   r   r  r  r  r&   r  r  r  s    rW   r   z,copy.<locals>.targetpathfn.<locals>.<lambda>  6    BGLLbg&&t~a'8'899  r.   c                     S rx   r   r  s    rW   r   z,copy.<locals>.targetpathfn.<locals>.<lambda>  s    D r.   )r   r  r  r   r  r  r&   r  ru   r   r   ossep)	r<  r  r  abspfxresr  r  destdirexistsr   s	    `   @rW   targetpathfnzcopy.<locals>.targetpathfn  s    7== 	!'	3<<F^F++F 'rw}}V44Q788v;; 0C///LLLLLCC 	!   CC !...C
r.   c                 "   t          j        |           rfd}not          j        j        	|           }t          |          t          d         d                   k     rfd}t          j        |          }t          |          rt          t          j	                  z  t          j                            t          j                            t          j                            |          d                             rl |          }t          t          j                            |          d                   }|r|t          t          j	                  z  } ||          |k    r|fd}n
rfd}nfd}|S )Nc                     t           j                            t           j                            t	          j        |                               S rx   r  r  s    rW   r   z1copy.<locals>.targetpathafterfn.<locals>.<lambda>  r  r.   r   c                     d}D ]f}t           j                            t          j        |d                   | d                    }t           j                            |          r|dz  }g|S )Nr   r   )r   r  r  r&   r  r  )r  scorer8  r#  r  r  s       rW   evalpathz1copy.<locals>.targetpathafterfn.<locals>.evalpath&  sh    E! ' 'GLLt~ad/C/CHII/NOO7??1-- '!QJE Lr.   r   c                 x    t           j                            t          j        |           d                    S rx   r  r  s    rW   r   z1copy.<locals>.targetpathafterfn.<locals>.<lambda>9  s*    T4>!3D3DXYY3O P P r.   c                     t           j                            t           j                            t	          j        |                               S rx   r  r  s    rW   r   z1copy.<locals>.targetpathafterfn.<locals>.<lambda>=  s6    BGLLbg..t~a/@/@AA% % r.   c                     S rx   r   r  s    rW   r   z1copy.<locals>.targetpathafterfn.<locals>.<lambda>A  s    D r.   )r   patkindr   r  r  ru   r&   r  r   r  r   r  r  r  r   )r<  r  r  r  r  r  r  	striplen1r  r  r  r   s    ``     @rW   targetpathafterfnzcopy.<locals>.targetpathafterfn  s   C   %	)   CC '	3<<F6{{Sa__,,! ! ! ! ! ! //v;; 4HN 3 33H7==dBGMM&4I4I!4L!M!MNN -$HX..E #BGMM&$9$9!$< = =I  9!S%8%88	x	**U22#,PPPPP ! )   CC )...C
r.   s@   with multiple sources, destination must be an existing directorys!   destination %s is not a directorys)   maybe you meant to use --after --at-rev=.r  )5rd   r  rY   r   rZ   r   r   	revsingleru   r   r  r!   getuipathfnr  r  r  r    r  overlayworkingctxsetbaser#  graftr   p1copiesr   p2copiesr  
markcopiedr  r   r  tomemctx_for_amendr   r)  r  r-  movedirstater  
expandpatsr   r   r  r  hasdirr   r   r  r  islinkr   r  r&   endswithsep))rn   r   rO  r[   r  r  r  new_ctxr  r   current_copiesr   mem_ctxnew_noder  r  r  absdestcopylistr<  r  r  r  r  r  r  r  tfnr  errors
targetpathr  r  r  r  r  r  r  r  r  r  s)   `` ``                            @@@@@@@@rW   r   r     s
    y:,??? ++--CGXXi  FHHXEXXj!!F
((9

C
  	De 	D "1%A#B#BCCC"4--s{{}}!!"<==   "
 4j6688D"4TBBBH ,7799GG3;;==!!A%%&q)N'O'OPPP!!!!!! 		{I>>>//55GOOCFFHH%%%N473333c4..cllnn---&t,,% 		 		AN""
%%d++++Q U  hqkk"   7799  
 
!44S99">>++=##%%333355 C C,T4>BBBC C C C C C C C C C C C C C C #

XJ7$,	D   
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 	d##D Iq!FGGHHH
4yyA~~q!<==>>>88::D         B wwyyTCGGII;	:::$TYT::::g 	"MNN(7##$   #">??8G$$c*+   	 	% 	%C73<<D #' % %S%$$$$%  	;"1%8#9#9::: x==A"1%I#J#JKKK++D11!!!tSw////7HQK000YY[[ 	M 	M0055G~~''H}!!SXXZZ//]//11 ? ?(tH~>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ?HHJJ
3L |WtLLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	
X! X! X! X! X! X! X! X! X! X! X! X! X! X!|      .' ' ' ' ' ' 'R GMM$''Dt0D0D,DM t99q==H,T!W55="*    D!! 	"677$>   C  H 6 6ws|| 	S$--t45555 B 	CABBDq!455DAAAAF$  
D%) 	 	!FFEx

6(:(:EBB !	 Q;sn   (A2PO6PO	P	O	
2PPP?A2]1\]\	] \	!2]]#&]#c                    ddl m} |                    d          }|                    d          }	|                    d          p|                    d          }
|                    d          p|                    d          }|                    d          }|                    d          }|                    d	          }|                    d
          }|                    d          }|                    d          }|                    d           }|d         }|d         }t          |                    d          pd          }|sdS d}t	          | |          }|r|}	n|	r|	                                }	nd}	|                     d|	pdz             t          |          dk    r |                    |t                              |                    d          r=|r|s!t          j        t          d                    ||         }||pt                   }n|r	 ||         }||         }||d         k    r|d         }|t                   }n# t          j        $ r |\  }}Y nw xY w|                                t          k    r"|                     t          d                     n|\  }}d}|r||d         k    r |||                                           ||d         k    r:|                    |                                |                                           |                    d          s|r|j                            |pd           |                    dd          }t)                      }	 t+          j        | |||||d|dz             n# t          j        $ r:}t          j        t/          j        |          t          d                    d}~wt          j        $ r6}|s&t          j        t/          j        |                    |rd }Y d}~nd}~ww xY wt7          |          }|r|	r|                    |	           n.|                    d          s|rd}nt9          j        ||pg           }t=          |d         d!          }|                    d          rd}n t?          d0d"|it/          j         |          }i }tB          D ]} tE          |          ||||           i }!|rd |!d#<   |                    d$          rd$|!d%<   |j#        $                    |!d&          5  |%                    |	|
||||'          }tL          D ]} tO          |          ||                    	 ddd           n# 1 swxY w Y   n|                    d          s|r|pd}n|(                                }t+          j)                    }"	 t)                      }	 t+          j*        | |||"||||d(	  	         n# t          j        $ r:}t          j        tW          j,        |          t          d                    d}~wt          j        $ r+}t          j        tW          j,        |                    d}~ww xY w|                    d          rd}nt?          d)*          }|-                    ||                                |                                f|	||"|
|||+	  	        }#i }!|                    d$          rd$|!d%<   |j#        $                    |!d&          5  |#%                                }ddd           n# 1 swxY w Y   |".                                 n# |".                                 w xY w|                    d          r%|r#|                     t          d,                     nK|                    d          r6|rt_          |          |k    r!t          j0        t          d-                    t          d.          }$|rt          d/          tc          |          z  }$|$||fS )1a  Utility function used by commands.import to import a single patch

    This function is explicitly defined here to help the evolve extension to
    wrap this part of the import logic.

    The API is currently a bit ugly because it a simple code translation from
    the import command. Feel free to make it better.

    :patchdata: a dictionary containing parsed patch data (such as from
                ``patch.extract()``)
    :parents: nodes that will be parent of the created commit
    :opts: the full dict of option passed to the import command
    :msgs: list to save commit message to.
           (used in case we need to save it when failing)
    :updatefunc: a function that update a repo to a given node
                 updatefunc(<repo>, <node>)
    r   r  s   filenamer3   r9   r7      branchs   nodeids   p1s   p2s	   no_commits   import_branchs   bypasss   strips   prefixrH   r   )NNFFNs   message:
%s
r.   s   exacts   not a Mercurial patchs\   warning: import the patch as a normal revision
(use --exact to import the patch as a merge)
   defaults   partialg      Y@)stripr   r   r   
similaritys7   check that whitespace in the patch has not been mangledr  Ts   import.normalr  )r   s   allowemptycommit   secret)s   phasess
   new-commits   import)r   editorr  r   s   import.bypassr  )r   r  rh   rf   r  r  s3   warning: can't check exact import with --no-commit
s%   patch is damaged or loses informations   applied to working directorys
   created %sr   )2r  r  rY   floatr  r  r  ru   r   r   r   rZ   r   	RepoErrorr  r   r  
setparentsr)  	setbranchr   r   r  r   r'  r  r  r  r!   r!  r  r  r(  extrapreimportextrapreimportmaprn   r   r   extrapostimportextrapostimportmapr  	filestore	patchrepor)   forcebytestrr  r  r   r  r   )%rn   r   	patchdatar   r[   msgs
updatefuncr  rD  r1  rh   rf   r  nodeidr  r  nocommitimportbranchr   r  r   simrejectscmdline_messagerD  partialr   r   rJ  r  r  r  idfuncr3  storer  r   s%                                        rW   tryimportoner    s	   & mmK((GmmJ''G88G6	g 6 6D88G6	g 6 6D]]9%%F]]9%%F	u		B	u		Bxx%%H88,--L)$$$FNE)_F
'',1
-
-C !  G T**O !	 --// HH'.S1222
7||qtG}%%%xx  	@R 	@"1%=#>#>???"X"- 	 
	bBbB WQZQZ'] 	 	 	FB	6688wGGF    BA wJtRWWYY'''OOBGGIIrwwyy11188H 	: 	:M##F$8j999((:u--	K;	 	 	 	 	 $ 	 	 	" ##N     * 	 	 	 <&x'7':':;;; 		 U 	8 %G$$$xx!! :R : &tU[b99$T$Z1ABBHxx!! (  %)1);D)A)A  E( H H!&)$	5$GGGGI ?:>	67xx	"" B8A	45''	9== 8 8KKT4qu     . 8 8F&v.tAw77778	8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 88H 	! 	!)zFFYY[[F!!-	EEEC 
 
 
 
 
 (   &+A..R     . C C C&z'>q'A'ABBBCxx!! D(2BCCC^^BGGII& $ 
 
F Ixx	"" B8A	45''	9== $ $MMOO$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ KKMMMMEKKMMMMxx Gh G 	IJJKKKK	(		 GQ G#a&&F*:*:k!DEEFFF
+
,
,C *q)7?s   #1I I,+I,N! !P-05O%%P-7,P((P-;AV		VV]/ )X ]/ Z5YZ&ZZB&]/ .]]/ ]]/ ]]/ /^c                 Z   t          j        |          }d |                                D             }|                                }	|r|                                 |r	|d         }
n| j        }
|                    |           |                    d           |                    dd|	                                           |                    d|
                                z             |                    dd	|                    |
                                                     |                    |	o|	d
k    dd|	           |                    ddt          |                     |                    dt          |
          z             t          |          dk    r+|                    dt          |d                   z             |                    |                    t#          j        t          |          d                     t&          D ]2}t)          |         ||          }||                    d|z             3|                    dd|                                                                           |                    d           |                                r:t1          j        | |
|||          }|D ]\  }}|                    ||           d S t1          j        | |
|||          }|                    d                    |                     d S )Nc                 :    g | ]}||                                 S r   r  )r   r  s     rW   r   z!_exportsingle.<locals>.<listcomp>d  s%    444A!4qvvxx444r.   r   r  s   # HG changeset patch
r9   s
   # User %s
s   # Date %d %d
r7   s
   #      %s
r  r  s   # Branch %s
   nodes   # Node ID %s
s   # Parent  %s
r   rU   )r   s   # %s
s   descr   rt   r[   r   r.   )r  )r!   binnoder   r  reverser  r  r  r   rh   rf   
formatdate	condwriter   ru   r  
formatlistr   maplistextraexportextraexportmapr  rstripisplainr   diffuir  r  )r   r  r  r   switch_parentr>  r9  r  r   r  prevheaderidr   	chunkiterr   r   s                   rW   _exportsingler!  b  s   ?3D44444GZZ\\F  qz{JJ3JHH&'''HHWnchhjj111HH+,,,HHWnbmmCHHJJ&?&?@@@LL'6Z'4Df   HHW'T333HHT*+++
7||a
"S__4555GGBMM("23"@"@wMOOGPPP   ) ))%55HHY'(((HHWgs007799:::HHUOOO	zz|| *LtT5xHHH	% 	) 	)LE5HHU%H((((	) 	) JtT4XFFF	
SXXi(()))))r.   c           
          t          |d          D ]h\  }}| |         }	|                    d          s| j                            d|z             |                                 t          | |	|||||           idS )z,Export changesets to stdout or a single filer      <r   N)	enumerater  rn   rr   r  r!  )
r   r  r  r  r  r9  r   r>  r  r  s
             rW   _exportfiler%    s    a(( L L
s3it$$ 	)GLL4(((
dCUM5(KKKKL Lr.   c                 T   t          |          }t          d |D                       }t          j                    }	t	          |d          D ]L\  }
}| |         }t          ||||
|          }|	                    |g                               |
|f           M|	D ]}t          j	        ||          5 }| j
                            d|z             |	|         D ]6\  }
}|                                 | |         }t          | |||||
|           7	 ddd           n# 1 swxY w Y   dS )z,Export changesets to possibly multiple filesc              3   N   K   | ] }t          t          |                    V  !d S rx   )ru   str)r   r  s     rW   r  z$_exportfntemplate.<locals>.<genexpr>  s.      11S3s3xx==111111r.   r   )r=  r>  r?  r   N)ru   maxr&   sortdictr$  rG  
setdefaultr   r   maybereopenrn   rr   r  r!  )r   r  basefm
fntemplater  r9  r   r=  r?  filemapr>  r  r  r  r  s                  rW   _exportfntemplater0    s    IIE11D11111HmooGa(( : :
s3i5
 
 
 	4$$++UCL9999  "6400 	BGLL4(((%dm  
s3i#r5-   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 s   2ADD 	#D 	c                    t                      }|D ]A}| |                                         D ]$}r |          r|                    |           %Bt          j        | |          fd|D             }t          j        | |           d S )Nc                     g | ]}|fS r   r   )r   r  r   s     rW   r   z)_prefetchchangedfiles.<locals>.<listcomp>  s    ///33,///r.   )r   r   r   r!   r!  prefetchfiles)r   r  r   allfilesr  rm  
revmatchess     `    rW   _prefetchchangedfilesr6    s    uuH # #IOO%% 	# 	#D #EE$KK #T"""	# tX..E////$///J$
+++++r.      hg-%h.patchc           	          t          | ||           |st          | ||d|||           dS t          | ||||||           dS )a  export changesets as hg patches

    Args:
      repo: The repository from which we're exporting revisions.
      revs: A list of revisions to export as revision numbers.
      basefm: A formatter to which patches should be written.
      fntemplate: An optional string to use for generating patch file names.
      switch_parent: If True, show diffs against second parent when not nullid.
                     Default is false, which always shows diff against p1.
      opts: diff options to use for generating the patch.
      match: If specified, only export changes to files matching this matcher.

    Returns:
      Nothing.

    Side Effect:
      "HG Changeset Patch" data is emitted to one of the following
      destinations:
        fntemplate specified: Each rev is written to a unique file named using
                            the given template.
        Otherwise: All revs will be written to basefm.
    	   <unnamed>N)r6  r%  r0  )r   r  r-  r.  r  r[   r   s          rW   exportr:    sv    > $e,,, 
$mT5	
 	
 	
 	
 	
 	$
M4	
 	
 	
 	
 	
r.   c           
          t          | ||           t          |dd          }t          j        | j        |di           5 }t	          | ||||||           ddd           dS # 1 swxY w Y   dS )z*Export changesets to the given file streamrV   r9  s   exportN)r6  r   r   rn   r%  )r   r  rE  r  r[   r   r  r  s           rW   
exportfiler<    s    $e,,,2v|,,D		TWb)R	8	8 FBD$D-uEEEF F F F F F F F F F F F F F F F F Fs   A""A&)A&c                    ||                      dd|           |                      ddt          |                                                     |                                }|                     |dd|                     t          t          |          d                     |                      d	d
|                                           |                                }|@|                      dd|                     t          t          |          dd                     |                      dd| 	                    |
                                                     |                                                                }|                    dd           t          j        t          j        |          }|                      dd|                     |dd                     |                     d           dS )zdutility function to display obsolescence marker in a readable way

    To be used by debug function.Ns   indexs   %i s   prednodes   %s s	   succnodesr  rU   s   flags   %X s   parentnodess   {%s}    , )rV   sepr7   s   (%s) s   metadatas   {%s}s   %r: %r)fmtr?  rt   )r   r   prednode	succnodesr  r  mapr  parentnodesr  rf   metadatar   r   r   rapplymaybebytestr
formatdictr  )r  markerindexsuccsr   metasmetas          rW   
showmarkerrN    s    
65)))HH[&#foo&7&7"8"8999ELL
c#uooG44	   HHWffllnn---  ""G
MM#c7++'uMEE	
 	
 	

 HHWhfkkmm < <===??!!##DHHWdOH1488EHHWbmmEyemLL   HHUOOOOOr.   c                 d   |                     d|          }	 |                                }n/# t          $ r" t          j        t          d                    w xY w|                     t          d          |t          j        ||         	                                          fz             d|z  S )z;Find the tipmost changeset that matches the given date specs   date(%s)s    revision matching date not founds   found revision %d from %s
s   %d)
r  r)  
ValueErrorr   rZ   r   r   r(   datestrrf   )rn   r   rf   mrevsr  s        rW   finddaterS  	  s    IIk4((EGiikk G G Gq!DEEFFFG II	
()) c!1!122
3	4   3;s	   - ,Ac           
      d   g fd}g }|d          }	d }
t          j        |           \  }}|s|rt          j        | ||j                  }
|                    d          t          j        |          }|j        }t          |                    |t          |	j	                  ddd                    D ]}
                    |          }|s |sy||	vru|j                            |          r[|
r |
|           |                    |           | j        s|s0|                     t!          d           ||          z  d           t          |	j	                  D ] }|	                    |          }	 t          j        |          }|j                            ||          }t          j        ||          }|                    d	          r&                     |j        | |||dfi |           n%                     |j        | |||dfi |           # t0          j        $ r1 |                     t!          d
           ||          z             Y w xY w|                    d          s7|	                    ||          }                    fd|D                        S )Nc                 Z                         |           p                    | |          S rx   r   badr^   yrW  r   s     rW   r   zadd.<locals>.<lambda>$	  "    A9%))Aq// r.   T)includeexactF)subreposr   r   full
   adding %s
s   ui.addremove.addedr   r\  #   skipping missing subrepository: %s
dry_runc              3   H   K   | ]}|                                 v |V  d S rx   r   r   r   r   s     rW   r  zadd.<locals>.<genexpr>Y	  5      ==!u{{}}*<*<1*<*<*<*<==r.   )r!   checkportabilityalertcasecollisionauditorr)  narrowmatchr   r   r  r  r  r  r  r  r   r  r   r   r  subdirmatcherreljoinsubdiruipathfnrY   r   r   r   LookupError)rn   r   r   r   r  explicitonlyr[   badfnnamesr2  ccaabortr   r   r)  r   r  subpathr  submatch	subprefixsubuipathfnrejectedrW  s     `                    @rW   r   r   !	  s-   
C99999EE:D
C/33KE4 E E*2udmDDU66E ..H}H DM** 	 	
 	
    A 	 	$49;L;LQ;O;O ALLOOOz  		n%%3;P     $-((  hhw	-gu==H	))&'::I!0(CCKxx
## 

CGB)[%PP4PP    

CGB)[$OO$OO     	 	 	II9::XXg=N=NN    	
 88I >88E6**

====h======Js   ;B%H!!=I! I!c                    | j         ||<   | j                            d|| j         fz             |                     d          D ]=}| |         }|j        D ]+}|                    |                              ||           ,>d S )Ns   adding %s = %s
s   filelog("path:.hgsub"))r  rn   r  r  r  r  addwebdirpath)r   
serverpathwebconfr  r  rq  s         rW   rw  rw  ]	  s    )GJGMM%TY(??@@@YY011 @ @1g| 	@ 	@GGGG**:w????	@@ @r.   c           	         |r#|r!t          j        t          d                    g fd}|d          }	g }
|                    t	          j        |          d          }t          |j        |j        z   |j	        z   |j
        z             }|rfd|D             }t          |	j                  D ]|	                              }t	          j                  }|j                            |          }t!          j        |          }	 |                    |||||          \  }}                    fd|D                        |
                    fd|D                        # t           j        $ r1 |                     t          d	           |          z             Y w xY w|s                                D ]}||j        vr|j                            |          s||
vr|j                            |          rP|j                            |          |j        v re|                     t          d
           ||          z                                 |           |r*t          d          }|d d          D ]}|                     t          d           ||          |fz            }|dk    r|dk    r|                     |          d         D ]1\  }}|                     d|t?          j         |          fz             2|                     t          d           ||          |fz            }|dk    |dk    r|dk    r|!                    |           |dk    r|"                    |          }||d =  n
|dk    r n|D ]P}| j#        s$                    |          r|r0|                     t          d           ||          z  d           Q|sX|	                    ||                              fdD                        |
                    fd|D                        |
fS )Ns/   cannot specify both --dry-run and --interactivec                 Z                         |           p                    | |          S rx   rV  rX  s     rW   r   zforget.<locals>.<lambda>o	  rZ  r.   Tr   r  c                 >    g | ]}                     |          |S r   )r  rc  s     rW   r   zforget.<locals>.<listcomp>v	  s(    666u{{1~~6!666r.   )r  rU  c                      g | ]
}d z   |z   S rc  r   r   r   rq  s     rW   r   zforget.<locals>.<listcomp>	  s"    ;;;q$*;;;r.   c                      g | ]
}d z   |z   S r  r   r  s     rW   r   zforget.<locals>.<listcomp>	  s"    AAA!7T>A-AAAr.   r_  s+   not removing %s: file is already untracked
s   [Ynsa?]$$ &Yes, forget this file$$ &No, skip this file$$ &Skip remaining files$$ Include &all remaining files$$ &? (display help)s   forget %s %s   r   s   %s - %s
r   r9        removing %s
   ui.addremove.removedr   c              3   H   K   | ]}|                                 v |V  d S rx   rb  rc  s     rW   r  zforget.<locals>.<genexpr>	  rd  r.   c              3   $   K   | ]
}|v|V  d S rx   r   )r   r   ru  s     rW   r  zforget.<locals>.<genexpr>	  s-      ==A1H+<+<a+<+<+<+<==r.   )%r   rZ   r   r   r   r   r  r   r   r   r  r  r  rh  r  ri  r!   rj  r  r   rk  r   r)  r  r  r  r   r   promptchoiceextractchoicesr   r   lowerremoverJ  r  r  )rn   r   r   r   r  rl  r  rU  rm  r2  forgotr8  r  r  rr  rs  rt  subbad	subforgotr   	responsesr   r  r   r#  fnindexrW  ru  rq  s     `                       @@@rW   r  r  g	  s*     
+ 
@AA
 
 	
 C99999E:DF(+E599FFAAJ(194qw>??F 76666V666$-((  hhw)'599I%%fg66	,Wh??	 #

' !+ ! !FI JJ;;;;F;;;<<<MMAAAAyAAABBBB  	 	 	II9::XXg=N=NN    	
  " 	" 	"A%%diooa.@.@%F??y''** 
  =22155FF$!?  'hqkk	*   JJqMMM $
 
	 qqq	 	 	H/""hhx&8&8)%DD A Avv1ff " 1 1) < <Q ? H H1HN14E4E0F!FGGGG/**hhx.@.@)-LL A 1ff Avvah''''a ,,x00788$a    : 	U[[^^ 	{ 	II"##hhqkk19P      >;;vv..

====h================;s   AE33=F32F3c           	      \   d}| j         pddh|                                z  }|                                r|sg }	|                    |          D ]e}
|	                    | ||
          z             t          |	          dk    r-|                     d                    |	                     |	d d = d}f|	r(|                     d                    |	                     n|                    |          D ]}
|                                 |	                    |           |rD||
         }|                    dd	|
                                |                                           |                    |

           |                    | ||
          z             d}t          |j                  D ]}t!          j        ||          }t%          j        ||          }|s6|                    |          s!t+          |                                          r|                    |          }	 |                    |          p|}|                    | |||||          dk    rd}# t2          j        $ r1 |                     t9          d           ||          z             Y w xY w|S )Nr   s   sizes   flagsd   r.   r   r  s
   size flagss   % 10d % 1s r  r_  )r  datahintr  matchesr   ru   r   r  r  r  sizer  r  r  r  r  r   rh  r!   rj  r  r  r   r  
printfilesr   rk  r   r   )rn   r  rJ  r  r  r@  r\  ret	needsfctxbufr   fcrq  rr  rt  r  recurses                    rW   r   r   	  s   
C
Aw1BKKMMAI	zz|| I  Q 	 	AJJsXXa[[()))3xx#~~#'''FCC 	$HHSXXc]]###Q 	 	ALLNNNJJ3J OV		288::NNNGGGOOOHHS88A;;&'''CC#,''  )'155,Wh?? 	qwww'' 	3x~~/?/?+@+@ 	'''""C'''**6hNN2xb#wOO  C$   		=>>hw''(    	 Js   07I((=J('J(c
                    ! d}
|                     |d          }|j        |j        |j        |j        f\  }}}}|d          !|	g }	d}nd}t          !j                  }|                     t          d          t          |          t          d                    }|D ]}t          j        ||          }|j                            ||          }t          j        ||          }|s6|                    |          s!t#          |                                          r|                                 !                    |          }	 |                    ||||||||	          rd}
# t,          j        $ r2 |	                    t          d	           ||          z             Y 	w xY w|                                 t5          j        |          }|                                }|                     t          d
          t          |          t          d                    }|D ]  !fd}|                                  |v p!                               } |j        v s|s dk    s |            s |v rU|j                                       rw|j                                       r/|	                    t          d           |           z             n.|	                    t          d           |           z             d}
|                                 |r||z   |z   |z   }n|r|}||z   |z   }|                     t          d          t          |          t          d                    }|D ]Q |                                 | j         s |v r.|	                    t          d           |           z             d}
R|                                 n||z   }|                     t          d          t          |          t          |          z   t          d                    }|D ]F |                                 |	                    t          d           |           z             d}
G|D ]F |                                 |	                    t          d           |           z             d}
G|                                 t          |          }|                     t          d
          t          |          t          d                    }|D ]b | j         s|                               sD|                                 |                      t          d           |           z  d           c|                                 |s|!                                5  |sB|D ]?  |v r|j"        #                    dd          }|j        $                     d|           @|d          %                    |           d d d            n# 1 swxY w Y   |r|	D ]}| &                    |           |
S )Nr   Tr|  Fs	   searchingrJ   )r=  unitr   r_  s   deletings   filesc                  R    j         D ]}                     | dz             r dS dS )Nrc  TF)r  r  )rq  r   r2  s    rW   	insubrepozremove.<locals>.insubrepo1
  s=    =    <<$//  44 5r.   r   s"   not removing %s: no tracked files
s#   not removing %s: file is untracked
s   skippings#   not removing %s: file still exists
s<   not removing %s: file is modified (use -f to force removal)
sL   not removing %s: file has been marked for add (use 'hg forget' to undo add)
r  r  r   r   r  )ignoremissingr/  )'r   r   r   r   r  r  r  makeprogressr   ru   r   rh  r  ri  r!   rj  r  r  r   	incrementr  removefilesr   rk  r   completer   dirsr  r)  r  r  r  rR  rn   rl   r  r  r   )"rn   r   rJ  r   r  r  r   r\  r  warningsr  r8  r   r   r   r  r   r5  progressrq  rr  rs  rt  r  deleteddirsr   r  r  r  	remainingr/  warningr   r2  s"                                   @@rW   r  r  	  si    C!4((A&'j!'19ag&M#HeWe:D$-  D	,s4yyq~~   H   )'155I%%fg66	,Wh?? 	qwww'' 	3x~~/?/?+@+@ 	   ((7##C??	 	 
 C$   =>>hw''(    	(  -((KGGIIE	+c%jjq{{   H   	 	 	 	 	 	 	[ 2DKKNN!t))yy{{)a4ii9A 	yq!! <==K    =>>!L    )'!E)E1	 'u$u,	??kNN#i..q{{ # 
 
  	 	A   z a5jj=>>!L   CC??kNN3x==3u::#=Qx[[ # 
 
  		 		A   OO,  (1++	   CC 		 		A   OO8  (1++	   CC$<<D	+c$iiakk   H   : 	QWWQZZ 	   II"##hhqkk19P      
$ZZ\\ 		$ 		$ M M MAEzz  G..'); E I(($e(LLLLJd###		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$ 		$   	 	GGGGJs%   E**=F+*F+A X00X47X4c                 X    |                                   pd|                                  v S )N   data)r  )r  s    rW   _catfmtneedsdatar  
  s%    {{}}82;;== 88r.   c                 ^   d}t          |           rD||                                         }|r(|                                                    ||          }|                                  |                     |           |                     dd|           |                     |           dS )zHook for adding data to the formatter used by ``hg cat``.

    Extensions (e.g., lfs) can wrap this to inject keywords/data, but must call
    this method first.r.   r  r  s   %sr  N)r  r  r   
wwritedatar  r  r   )r  r  r   r  decoder  s         rW   _updatecatformatterr  
  s     D 54y~~ 	588::((t44DLLNNNJJ3JHHWeT"""GGGr.   c                    d}t          j                  fd}	t                                                    dk    rĉ                                s                                d         }
|j        }                                }	 |rg||                             |
          d         rFt                    r*t          j
        |                                fg            |	|
           dS n# t          $ r Y nw xY wt                    r*t          j
        |                                fg                                         D ]} |	|           d}t          j        |d          }t          j                  D ]}                    |          }	 t%          j        |          }t(          j                            |          } |j        ||fi t          j                  sd}s# t2          j        $ r1 |                     t9          d           ||          z             Y w xY w|S )Nr   c           
         d }rst          t          j                            |                     }	 t          j        t          j                            |                     n# t          $ r Y nw xY wt          j        |          5 }t          || 
                    d                     d d d            d S # 1 swxY w Y   d S )N)r@  s   decode)rG  r   r  r  r  r  r0  r   r,  r  rY   )	r  r   r  r-  r  r.  r   r[   r   s	      rW   r   zcat.<locals>.write
  s*    	#Z"',,vt*D*D  HBGOOH556666   "6844 	MC$8K8KLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	Ms#   1A) )
A65A6'CC	Cr   Tr  r_  )r   rT  ru   r   anypatsrk  manifestnoder:  r  r!   r3  r  r;  r  r  r  r  r  r   rh  r   r  r  catr(  r   RepoLookupErrorr   r   )rn   r   r  r   r-  r.  r   r[   r<  r   rm  mflmfnoder  r  rq  r  rr  rs  s     ``````           rW   r  r  
  s   
C%%DM M M M M M M M M M  7==??q  ):): }}q!!!##	 #f+**4003 #F++ H)$#''))W1E0FGGGdq 	 	 	D	  <dcggii%9$:;;;xx    c


"4TBBBH#,''  ggg	-gw??HVW55I37	 
 $T**   $ 	 	 	II9::XXg=N=NN    	
 Js&   A'D   
DD0AH=I
Ic                 ^   |                     d          }|rt          j        |          |d<   t          | |          }t	          j        |d         ||          }d}|                     d          rt          j        |d          }|pt          j                    5  |rht	          j	        ||          }	t	          j
        ||	          }
t	          j        ||d|
|          dk    r!t          j        t          d                     || ||||          cddd           S # 1 swxY w Y   dS )	z5commit the specified files or all outstanding changesr7   N	   addremove   commitr  r.   r   5   failed to mark all new/missing files as added/removed)rY   r(   	parsedater  r!   r   r   r&   nullcontextmanagerr  r  	addremover   r  r   )rn   r   rM  rO  r[   rf   r1  r   dsguardrelativer  s              rW   r   r   
  s}   88GD 1 *400WT""GmDJd33GG xx ?-dI>>		-D+-- 	< 	< 	tT22H*4XNNNH wXtDDIIkNOO   z"dGWd;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   A9D""D&)D&c                 ^   | |                                 v r|                    |           }| |                                 v rU|                    |           }|                    |           o)|                                |                                k    S dS | |                                 vS NF)manifestfilectxcmpr  )r   ctx1ctx2r  bs        rW   r  r    s    DMMOOLLOOQAuuQxx<:AGGII$::5''r.   c                 T  $%&'() ddl m% t          j        |t          j                  r|                                  |                     t          d          z                                             $|	                                5  |
                                5  |                    d          5  |d          )|                                }|                                                               |                    )                                           t          | |          }t!          j        |          }                                }|                    d          r't)          j        |                    d                    }|                    d          p                                }t/                                                    dk    rT$                              }	t5          |	j                  t5          |	j                  z  t5          |	j                  z  }
n!t5                                                    }
t?          j         )||          (t?          j!        ||          }t?          j"        ||          }|                    d          r9t?          j#        |(d	||          r!tI          j%        t          d
                    d)v sdv r;tM          j'        | ))j(        (          \  }}}|rJ |rtM          j)        ||           tT          j+        ,                    |          }t[          j.        |           (fd)                                D             't/          '          dk    }|j/        0                    dd          dk    }|s|rtc          j2        $)          &3                                r:&                    tc          j2        3                                )                     |
                    '           $')fd|
D             }
%&')fd}n,|                     t          d          $fz             fd}ti          | |          }tk          d          }|s/6                                }| p|                    d          dv }n|                    d          du }to          ||          }|                                }8                                |d<   %9                    |$:                                3                                :                                g||
|||||	  	        }tw          j<        |6                                          }|s|6                                k    r|                                k    rj|                                k    s|rP|                                k    r8:                                cd d d            cd d d            cd d d            S d }|                    d          rtz          j>        }|?                    |          }|@                                 |jA        B                                5  |C                    ||jD                   |jA        }t5          )                                )                                z             'z  }|D ]}|E                    |ddd           t5          )                                          'z  } | D ]}|E                    |dd           	 d d d            n# 1 swxY w Y   :                                |fi}!d }"|                    d           rd t          jG        |d                    i}"| H                    d!d"          }#t?          jI        ||!d|"d||##           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |S )$Nr   r  s   amending changeset %s
   amendr7   r9   r  r  r.   r  s   .hgsubc                 *    h | ]} |          |S r   r   )r   r   r   s     rW   r  zamend.<locals>.<setcomp>Y  s&    >>>a771::>>>>r.   r   r   s   copies.read-froms   filelog-onlyc                 >    g | ]}|vst          |          |S r   )r  )r   r   basefilestoamendr2  s     rW   r   zamend.<locals>.<listcomp>p  s?       \))!T41H1H) )))r.   c                 v   	 |v r!|
                                 v rd S 
|         }n	                    |          }|                                }                    | ||                                |                                d|v d|v                     |                    }|S # t          $ r Y d S w xY w)Nr4      x)r  isexec
copysource)r   r  r  
memfilectxr  r  rY   r;  )r   ctx_r  fctxr  mctxr  copiedr  oldr2  s         rW   r  zamend.<locals>.filectxfnv  s      |++4<<>>11#'4#Dz"{{400 JJLLE"--				#u}#u}#)::d#3#3 .  D  K      44 s   B* B
B* *
B87B8s   copying changeset %s to %s
c                 R    	                      |          S # t          $ r Y d S w xY wrx   )r  r;  )r   r  r  r  s      rW   r  zamend.<locals>.filectxfn  s<     ;;t,,,      44 s    
&&s   commit.amends   editTNT)r  r  s   amend_source)r   r1  r   r  rh   rf   r  r  r  r   F)r   r   s   noterj   s   backup-bundle)rE  r  targetphasebackup)Jr  r  r   	isenabledcreatemarkersoptrm   rr   r   r  rR  r  r  r   r   r  rp   r   rT  rf   rY   r(   r  rh   ru   r   r   r   r   r   r   r   r!   r   r  r  r  r   r  r#   r  _status
writestater  r   r  r   checkunresolvedrn   r   r   
pathcopiesr  r  r  r  r  r   r  r  r   	stripdescr   secretr  resetr)  r-  r  r  r.  r   	fromlocalrl   r  )*rn   r   r  r  rO  r[   ro   rf   rh   ri  r   r  r  r5  r6  newsubstatemsr   changeset_copiesr  r1  r  doeditr  	pureextranewnewdesccommitphaser  r)  normalfilesr   removedfilesr+  obsmetadatar  r  r  r  r  r   r2  s*     `                                 @@@@@@rW   amendr    s	    $ 9:: 
GGA())C/0006688D	 `
 `
tyy{{ `
 `
D$4$4X$>$> `
 `
 Dz 

 	SYY[[!!! 	TZZ\\""" /r488#D))xxzz88G 	9%dhhw&7&788Dxx  .CHHJJs{{}}!! S!!B$$s28}}4s2:FEE		$$E -dD11?4..&tJJJ88L!! 	g&7'3$'
 '
 	 +JKK   	S 0 0,7,AD$,- -)D*k "!!! :&t[999%**400!"%%%>>>>4::<<>>>l##a'GNN?,?@@ 	  7	 & 7	 &tT22Fvvxx Af/$??@@@ LL&&&       E                   : GGA566#tDEEE          R&& o66 		/oo''G ![EDHHW$5$5$EFF XXg&&$.F fx@@@JJLL	!$onnYY[[#&&((--//2  

 

 %coo&7&788	3??,,,,

""##}#SYY[[(( 88::a`
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
d 88I 	( -Ks##



]'')) 	L 	LOOE4;/// }H dmmoo

<==LK   $$$4 %     t||~~..=L! L L$$Q5U$KKKKL1	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L6 88::x(88G 	G"H$6tG}$E$EFKz+;<< #	
 	
 	
 	
q`
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
 `
D Ls   `#`9U_/``0A%_/B;]	_/]!!_/$]!%A>_/#`/_33`6_37`:``
	
``
	``!$`!c                 z    |                                 r|                                 S t          | |||d          S )NT)r  unchangedmessagedetection)r  r  )r   r  r5  r  s       rW   r  r    sF    
 !   c4(d   r.   c           	         |st          d          }d |                    d          D             }|                    dd           d }|r\d                    |          }	| j                            d|	          rt          | ||||	          x}}
n(|                                 |\t          | |||          }
t          j
                    }t          j        | j                   |                                 }| j                            |           |o|                                o| j        }| j                            |
|                                |                                ||| j        d          }|}t-          j        t0          |t,          j        	          }|r|d |                                         }t-          j        d
d|          }t          j        |           |r ||          }|                                s!t;          j        t          d                    |r'||k    r!t;          j        t          d                    |S )Ns$   Leave message empty to abort commit.c                     g | ]}||S r   r   )r   r   s     rW   r   z%commitforceeditor.<locals>.<listcomp>  s    22212Q222r.   r   r   s	   changeset   committemplater  )r  pendingr   r   )r  s   (?m)^HG:.*(
|$)r.   s   empty commit messages   commit message unchanged)r   r   insertr  rn   r   buildcommittemplater   buildcommittextr   r  r   chdirr  currenttransactionr)  r   writependingr  rh   r  r  research
_linebelow	MULTILINEr  r  r  r   rZ   )r   r  r5  r
  r  r  r  formstemplatetextref
committextolddirtrr  
editortextr1  
stripbelows                    rW   r  r    sY     ><==22t,,222E	LLL!!!L
 	@ii7>>+S11 	(;c43) ) L: 		  	@ %T3h??
 _FHTY 
	 	 	"	"BM4R__&&449G

		   J D :t2<@@@J *(j&&((()6%sD11DHV  z$::<< ;q!899:::  ?Z<%?%?q!<==>>>Kr.   c                 l   | j         }t          j        |          }t          j        || |          }|j        j                            d | j                             d          D                        |sd}|	                                 |
                    ||           |                                S )Nc              3   H   K   | ]\  }}|t          j        |          fV  d S rx   )r%   unquotestring)r   kvs      rW   r  z&buildcommittemplate.<locals>.<genexpr>K  sJ        Aq 
I#A&&'     r.   r  r.   )r  )rn   r   reference_templatespecr   changesettemplaterr#  cacher   configitems
pushbuffershow	popbuffer)r   r  r5  r  r  rn   r0  r#  s           rW   r  r  G  s    	B+C00D%b$55ACI  G''(9::     
  MMOOOFF3F"""<<>>r.   c                 f    d                     d |                     d          D                       S )Nrt   c                     g | ]	}|d |z  
S )s   HG: %sr   )r   r  s     rW   r   zhgprefix.<locals>.<listcomp>Y  s!    DDD!Dy1}DDDr.   )r  r   )r   s    rW   hgprefixr  X  s/    ::DDcii.>.>DDDEEEr.   c                    g }|                                 |                                |                                }}}|                                r'|                    |                                           |                    d           |                    d           |                    t          t          d                               |                    t          |                     |                    d           |                    t          t          d          |                                z                       |                                r/|                    t          t          d                               |	                                rD|                    t          t          d          |	                                z                       t          j        |           r7|                    t          t          d          | j        z                       |                    d |D                        |                    d	 |D                        |                    d
 |D                        |                    d |D                        |s3|s1|s/|                    t          t          d                               |                    d           d                    |          S )Nr.   s>   Enter commit message.  Lines beginning with 'HG:' are removed.s   HG: --s   user: %ss   branch merges   branch '%s's   bookmark '%s'c                 L    g | ]!}t          t          d           |z            "S )s
   subrepo %sr  r   )r   r8  s     rW   r   z#buildcommittext.<locals>.<listcomp>t  s-    BBBXa..233BBBr.   c                 L    g | ]!}t          t          d           |z            "S )s   added %sr  r   r   s     rW   r   z#buildcommittext.<locals>.<listcomp>u  s+    AAAaXannq011AAAr.   c                 L    g | ]!}t          t          d           |z            "S )s
   changed %sr  r!  s     rW   r   z#buildcommittext.<locals>.<listcomp>v  s-    FFFXa..233FFFr.   c                 L    g | ]!}t          t          d           |z            "S )s
   removed %sr  r!  s     rW   r   z#buildcommittext.<locals>.<listcomp>w  s-    EEEXa..233EEEr.   s   no files changedrt   )r   r   r   r  r   r  r   rh   r  r  r   isactivewdirparent_activebookmarkr   r  )r   r  r5  r  edittextr   r   r   s           rW   r  r  \  s   H"||~~syy{{CKKMMWeH
 +))***OOCOOCOO= 	
 	
   OOHX&&'''OOIOOHQ{^^chhjj899:::
vvxx 6?!3!344555
zz|| D>!2!2SZZ\\!ABBCCC#D)) N#3!4!4t7K!KLLMMMOOBBTBBBCCCOOAA5AAABBBOOFFXFFFGGGOOEEWEEEFFF : :' :#6!7!788999OOC::hr.   c                    |i }| |         }|                                 }|E| j                                        |k    r(| j                            t          d                     n^|                    d          sIrG|vrCt          fd|D                       s'| j                            t          d                     |                    d          sm|D ]j}|	                                rT|
                                k    r<| j                            t          d          |                                z             k| j        j        rR| j                            t          d          |                                |                                fz             d S | j        j        r@| j                            t          d          |                                |fz             d S d S )Ns3   warning: commit already existed in the repository!
r  c              3   t   K   | ]2}|                                 v o|                                k    V  3d S rx   )r  r  )r   r  bheadsr  s     rW   r  zcommitstatus.<locals>.<genexpr>  sS       
 
<=AFFHH7188::#7
 
 
 
 
 
r.   s   created new head
s   close_branchs    reopening closed branch head %d
s   committed changeset %d:%s
)r   r   tiprn   r   r   rY   r  r   closesbranchr  r  	debugflagr   r   r  )	r   r  r  r)  r*  r[   r  r   r  s	     ``     rW   commitstatusr-    s   |
t*CkkmmG
4>--//366 	QNOOPPPPHHX11  
 
 
 
 
AH
 
 
 
 
 
 	q.//000< 88O$$  	 	A~~ AHHJJ&$8$8:;;aeeggE   w L,--CGGII0FF	
 	
 	
 	
 	
 
 La67737799c:JJKKKKKL Lr.   c                 b    |                      t          j        | d          ||                    S )Nr   )r   r!   r   )r   rO  r[   s      rW   postcommitstatusr/    s(    ;;W]4:tTBB;CCCr.   c                    :;<= t          j        |          }|j                                        \  }}                                }                                }||k    r|}i <t          j        |d          =|                                5  |	                    dd          }	|d          }
t          j
        |
||          ;t          ;fd|
j        D                       };                                st          j        ;d           }|
                    |          D ]};                    |          <|<   < =fd}                    t          j        ;|                    D ]}|<vr;                    |          <|<   t          j        |<          ;|                    |;ddd          }nN|                    |;	          }|D ]}|D ]};                    |          <|<    t          j        |<          ;t)          |j                  }t)          |j                  }t)          |j                  }t)          |j                  }t)          |j                  }|                    |j                   t)          |j                  }t)                      }||k    r6|}|}|}||z  }t)                      t)                      t)                      }}}n|                    |;	          }t)          |j                  }t)          |j                  }t)          |j                  }||z  }|||z
  z  }||z  }||z  }||z  }||z  }||z  }|||z  z  }||z  }|}||j        k    r7t)          |          }|D ]}||v r|                    |           ||z  }||z  }|D ][}|j                            |          }|r=|<vr9|j                             |          j        r|!                    |           d<|<   \t)          |          } |D ]}||v r|                     |           || z
  }!t)                      }|D ]6}|j                             |          j        s|!                    |           7||z  }| D ]6}|j                             |          j        r|!                    |           7| |z  } t)                      }"|D ]K}|"                    |          }#tF          j$        %                    |#          r|"!                    |           L||"z  }t)                      }$|D ]K}|"                    |          }#tF          j$        %                    |#          r|$!                    |           L||$z  }g tM          d
          fg tM          d          fg tM          d          fg tM          d          fg tM          d          fg tM          d          fd tM          d          fd tM          d          fd:d}%d}&d}'d}(|	                    d          r|(x}%x}&}'|	r|%})n|&})t)                      }*:d         }+|	                    d          s:d         }+|:d         |(f|!:d         |(f|:d         |)f|:d         |(f|:d         |(f||+|&f| :d         |(f|:d         |(f|":d         |'f|:d         |(f|$:d         |'f|:d         |(f|:d         |(ff},t          <'                                          D ]\  }}-|"                    |          }#|,D ]\  }.\  }/}0}1||.vr|/Q|/(                    |           |1r|1|%k    r|*!                    |           n|&|1k    s!|
|         )                    |                   rt          j*         ||          }2tF          j$        +                    |2|j,                  }3 -                    tM          d            =|           =|3          fz             |	                    d!          s-|	rt]          j/        |#|2           nt]          j0        |#|2           |	                    d!          r* j1        s|-s!                     |0 =|          z             n#|-r! 2                    |0 =|          z              |	                    d!          sd"}4:fd#|4D             }5t          j3        }6t          j        |d$ |5D                       }7 |6|4                                |7fg           t          j
        |d          |          }8tk          |<=:|8|	|*           |r|D ]}9	  |
6                    |9          j7        j        |9         g|R i t          j8        |           E# tr          $ r9 tu          j;        d%|9ty                                                    fz            w xY wd d d            d S # 1 swxY w Y   d S )&NTr  s   interactiveFc              3   2   K   | ]} |          |V  d S rx   r   )r   r8  rJ  s     rW   r  zrevert.<locals>.<genexpr>  s0      ==!!=A======r.   c                     dS r  r   )r^   rY  s     rW   r   zrevert.<locals>.<lambda>  s     r.   c                     | v rd S | j         v rd S | dz   }D ]}|                    |          r d S                     d |           |fz             d S )Nrc  s   %s: %s
)r  r  r   )r  r   path_r   r  rn  rn   r  s       rW   rm  zrevert.<locals>.badfn  s    5==F3<''Ft  A||E** xx~~s&;;<<<<<r.   )node1r   r   r   r  )r5  r   s   reverting %s
r^  r  s   forgetting %s
s   undeleting %s
s   no changes needed to %s
s   file not managed: %s
)   revert   add   remove   dropr     undelete   noopry  r  r9  r   r   s	   no_backupr8  r9  r6  r  r7  r:  r;  ry  )r  s#   saving current version of %s as %s
r  )r6  r7  r:  c                 ,    g | ]}|         d          S )r   r   )r   rV   actionss     rW   r   zrevert.<locals>.<listcomp>  s"    <<<4gdmA&<<<r.   c                     g | ]	}|D ]}|
S r   r   )r   sublistr   s      rW   r   zrevert.<locals>.<listcomp>  s%    @@@W@@1q@@@@r.   s(   subrepository '%s' does not exist in %s!)=r   rT  r)  r   r  r  r!   r  rR  rY   r   r  r  alwaysr   r   r  r  r!  r   r   r   r   r   r   r   r   r   r  r  r  r  r+  r   r   r   r  r  r   r*  r   r  
backuppathrelpathr  rr   r&   r  r  r  r   r3  r  _performrevertr  revertr(  r;  r   r  r   )>rn   r   r  rO  r[   r  r  r  rx  rU  r2  
targetsubsr   r  rm  r   kindr   r   r   _deletedr   r  modadded
dsmodifieddsadded	dsremovedlocalchangesmergeaddr  r   r  deladdedr   removunkrf  
dsremovunkbackupinteractiver  checkdiscarddsmodifiedbackupr@  backupanddel	disptabler  r  xlistr   dobackup
absbaknamebaknameneeddataoplistprefetchr!  r   r  r=  rJ  rn  r  s>   ` `                                                       @@@@rW   rD  rD    s   %%D&&((JFB88::D	Brzz E"4TBBBH	 d d hh~u55DzM$d++ ====t}=====
xxzz "	0'+=+=>>Gyy)) * *WWS\\c

	= 	= 	= 	= 	= 	= 	= 	= xx 1!U ; ;<< . .e##!"E#J "4//Akk!T4t "  GG kkAk66G . . . .C!"E#JJ. "4//Aw'((GM""go&&w''go&&w'''GM""55 T>>!JGI%/L'*uuceeSUUWeHHkkak88GW-..J'-((GGO,,I%/L Y((E Iy Gz)HXE ("J(W,,J
"H
 G :H" * *2::OOD)))xG("J  		" 		"A-&&q))C "u$$M++C008 % c"""!c
 x== 	& 	&Drzz%%%X%  	 	C=**3//5 		#5 	! 	!C}&&s++1 !C   G 55 	" 	"CZZ__Fwv&& "S!!!8UU
 	$ 	$CZZ__Fwv&& $s###Z	
 A/001>**+A.//0!,--.A0112a 2334A:;;<q!:;;<	
 	
 88L!! 	91888 	&0%55y)xx%% 	,"7+L wy)73gi('2+-=>GI&0gi('2|V,ww'1gfow/wv.,g6-u5 GG$g.gj)73A!
	F !// #	 #	JCZZ__F 2;  -|sXe##$LL%%% D $'888$LL----#x//49==S3J3J/)0);Bc)J)JJ&(goo *$) '6 ' 'G GG !"I J J#+8C==((72C2C"D!E   $(88J#7#7 D#. !D$(M&*$E$E$E$E$(K
$C$C$Cxx
++ ;: ;U ;IIcHHSMM&9::: 1GGC((3--/000xx
## 	7H<<<<8<<<F,H +@@@@@ J H''))Z()   M$t*d33E	 	 	  	! 	 	(DHHSMM(S),0  4<4Ft4L4L        +Cchhjj 1 123  A	d d d d d d d d d d d d d d d d d ds-   cg4Af! g4!Ag$$g44g8;g8c                    %&  j                                         \  }}	                                }
g % fd} fd} fd}t          j         j        d          }d         d         D ]}|rv j                            t          d           |          z            }|dk    r' |d|            j         	                    |           d%
                    |           z |d|            j         	                    |           d	         d         D ]} ||           |rg j                            t          d
           |          z            }|dk    r |d	|            ||           `%
                    |           v |d	|            ||           d         d         D ]3} ||            |d|            j         	                    |           4|	 j        k    & &fd}t                      }|r%fdd         d         D             }t          j         |          }t          j         j        ddd          }d|_        d|_        d}|
|k    r  j                            dd          rd}nd}|dk    r,t          j         d                                ||          }n+t          j                                         d||          }t          j        |          }	 t-           j        |||          \  }}|dk    rt          j        |          }nq# t0          j        $ r)}t1          j        t          d          |z            d}~wt0          j        $ r)}t1          j        t          d          |z            d}~ww xY wt;          |          \  }}|t                      }t=                      }t?          d |D                       D ]} |d|           t                      }|D ]}tA          |          r|j!        "                                } |j!        "                                |v rZ #                    |           }!t          j$         j         |           }"tK          j&        |!|"           |'                    |            | |vr&|(                    |            |dk    r ||            |)                    |           |*                                }#|+                    d           |#r	 t          j,         j         |dd           nu# t0          j        $ r+}t1          j        t[          j.        |                    d}~wt0          j        $ r+}t1          j        t[          j.        |                    d}~ww xY w~n5d         d         D ]&} |d|            ||           |r ||           'd         d         D ]t}||v r|r: j                            t          d            |          z            }|dk    rC |d|            ||            j         /                    |           ud!         d         D ]}|ri j                            t          d"          |z            }|dk    r# |d!|            ||            ||           W%
                    |           m |d!|            ||            ||           ta          j1         |                   }$d         d         d!         d         z   d         d         z   D ]'}||$v r! j         2                    |$|         |           (dS )#zfunction that actually perform all the actions computed for revert

    This is an independent function to let extension to plug in and react to
    the imminent revert.

    Make sure you have the working directory locked when calling this function.
    c                     |          }                     | |                                |                                           d S rx   )wwriter  r  )r   r  r  r   s     rW   checkoutz _performrevert.<locals>.checkout  s8    VArwwyy"((**-----r.   c                     	 j                             dd          }j                            | |           n# t          $ r Y nw xY wj                            |            d S )Nr   r  r  )rn   rl   r  r  r0  r)  set_untracked)r   r/  r   s     rW   doremovez _performrevert.<locals>.doremove  sz    	G&&8JKKEI  % 0000 	 	 	D	##A&&&&&s   7; 
AAc                     |         }j         j        s|s4j                             |          d          |          z             d S d S )Nr   )rn   r  r   )r   r   r  r=  rn  r   r  s      rW   prntstatusmsgz%_performrevert.<locals>.prntstatusmsg   sY    a7? 	=% 	=GNN76?1-;<<<<<	= 	=r.   T)cachedr  r   s(   forget added file %s (Yn)?$$ &Yes $$ &Nor8  s(   remove added file %s (Yn)?$$ &Yes $$ &Nor9  c                 <    j                             |           S )N)
reset_copy)r)  set_tracked)r   r   ri  s    rW   normalz_performrevert.<locals>.normalL  s    }((j(IIIr.   c                     g | ]}|v|	S r   r   )r   r   excluded_filess     rW   r   z"_performrevert.<locals>.<listcomp>R  s#    PPP!8O8OA8O8O8Or.   r6  r   s   revert.interactive.)r   r   r   s   applyr   s!   revert.interactive.select-to-keeps   keeps   discardNr  )r   r   r   c                 ^    h | ]*}t          |          |j                                        +S r   )r~   r   r   r   r   s     rW   r  z!_performrevert.<locals>.<setcomp>  s1    JJJq		J**,,JJJr.   r   r   r7  s#   add new file %s (Yn)?$$ &Yes $$ &Nor:  s,   add back removed file %s (Yn)?$$ &Yes $$ &No)3r)  r   r  r   pathauditorr  rn   r  r   rc  r   r  r   r!   r!  r   r  r  r	  rl   r  r  r   reversehunksr   r  rZ   r  r  r   r  r  r~   r   r   r   rA  r&   r  r  r   r   r  r  r&  r   r'  rj  r   r  r   )'r   r  rn  r  r=  r   rU  r@  r  r  r  ra  rd  rf  
audit_pathr   r  rk  r   torevertrJ  r9  r   r  r;  r   r[   r<  unusedalsorestorerE  r   r   r  rf  rZ  rG  r  rm  ri  s'   `````                                @@rW   rC  rC    s   " &&((JFB88::DN. . . . . .' ' ' ' '= = = = = = = =
 %di===JY" + + 	+W))=>>!L F {{i+++++A....%%a((((M)Q'''M''****Y"  
1 	W))=>>!L F {{i+++%%a((((M)Q'''HQKKKKWa  ' '
1gq!!!##A&&&& t{"JJ J J J J J "% SPPPPwy1!4PPPtX..(G/	
 
 
  	6>>w!!!E  ' $		&	  :dD#((**ahGGGDD:dCHHJJahGGGD +D11	I')5I  LFD J&&+F33$ 	H 	H 	H"1%?#@#@3#FGGG* 	I 	I 	I"1%@#A#AC#GHHH	I 9Gv8N8N5"$5uuHZZJJfJJJKK 	( 	(AM)Q'''' 	 	Aayy &h''))8$$&&(22!ZZ__F%0$DDGM&'222OOC(((e##IIcNNN G++ GGBKKKK''))



 	>>#DGT2q$GGGGG( > > >&x'7'<'<===. > > >&x'7'<'<===>B#A& 	 	AM)Q'''HQKKK q			V_Q % %*** 	W))899HHQKKG F {{fa   !!!$$$$[!!$   	W))ABBQF F {{k1---q				%%a((((M+q)))HQKKKF1IIIItF|S11F 	W[1!44wy7I!7LL- - ;;Mvay!,,,	- -sH   5M N/$M44N/$N**N/%U V6&U99V6&V11V6c                    t           j        D ]i}|j        s|r|j        s|j        r|                    |           r:t          j        |                                |	                                          jt           j        D ]v}|j        r|r|j        s|j
        dk    r|s|j        r'|                    |           r:t          j        |                                |	                                          wdS )zLook for an unfinished multistep operation, like graft, and abort
    if found. It's probably good to check this right before
    bailifchanged().
    r     mergeN)r  _unfinishedstates
_clearable_allowcommit_reportonlyisunfinishedr   r  r   r  _opname)r   r   	skipmerger"   r8  s        rW   r   r     s'    + C C		 -	  	
 d## 	C"599;;UZZ\\BBBB	C ' 	; 	;		>	 	X%%)%} & >>$ 	;"15577::::	;	; 	;r.   c                    t           j        D ]`}|j        r
|j        sO|                    |           r:t          j        |                                |                                          at           j        D ]b}|j	        dk    s|j        r|j        rF|                    |           r1t          j        | j                            |j                             cdS )z[Check for unfinished operations (as above), and clear the ones
    that are clearable.
    r  rv  N)r  rw  rz  rx  r{  r   r  r   r  r|  r&   r   r'   r  _fname)r   r"   r8  s      rW   clearunfinishedr    s     + C C 	 	CE$6$6t$<$< 	C"599;;UZZ\\BBBB' 1 19  AM < 	1ANN400 	1Kah//000	1 1r.   c                 V    t           j        D ]}|                    |           r|c S dS )zIChecks for unfinished operations and returns statecheck object
    for itN)r  rw  r{  )r   r"   s     rW   getunfinishedstater    s?     +  d## 	LLL	4r.   c                    t          d          }t          j        D ]:}|j        s
|                    |           r||                                z  dfc S ;| d                             ddd          r|t          d          z  dfS dS )ai  Check for an unfinished operation and return the command to finish
    it.

    statemod._unfinishedstates list is checked for an unfinished operation
    and the corresponding message to finish it is generated if a method to
    continue is supported by the operation.

    Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
    a boolean.
    s   continue: %sTNF)missingr   r  s	   hg commitNN)r   r  rw  _continueflagr{  continuemsgdirty)r   contmsgr"   s      rW   howtocontinuer    s       G+ 7 7" 	d## 	7U..000$6666	7DzE%@@ 0<(%//:r.   c                     t          |           \  }}|@|r| j                            d|z             dS | j                            d|z             dS dS )zInform the user about the next action after completing hg resolve

    If there's a an unfinished operation that supports continue flag,
    howtocontinue will yield repo.ui.warn as the reporter.

    Otherwise, it will yield repo.ui.note.
    Nr   )r  rn   r   rr   )r   r   r  s      rW   checkafterresolvedr  -  se     !&&LC
 	(GLL3'''''GLL3'''''	 r.   c                     t          |           }d}|d         r|d         }t          j        t          d          |z  |          )zRaise an abort suggesting how to properly continue if there is an
    active task.

    Uses howtocontinue() to find the active task.

    If there's no task (repo.ui.note for 'hg commit'), it does not offer
    a hint.
    Nr   r   s   no %s in progressr  )r  r   r  r   )r   taskr  r  s       rW   wrongtooltocontinuer  =  sO     $EDQx Qx

1122T9
E
E
EEr.   c                    |                                 s!t          j        t          d                    t	          |          }|                    d          }|!t          j        t          d                    t          |          dk    r!|d                                                  }nd         }d}|rfd|D             }d	}fd
|D             }|rZj	        
                    t          d          d                    fd|D                       z  t          d                     d}t          j                            |                    }|t          |          z
  r)j	        
                    t          d                     d}|r                                5                                  5  t#          j        |           d                     d|          D             }	t'          j        j	        |	d           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |sd         }t#          j        |           |                     t          d                     |                     t          d          |                                dd         z             |                                 dS )zSabort the interrupted graft and rollbacks to the state before interrupted
    grafts   no interrupted graft to aborts   newnodesNs$   cannot abort using an old graftstater   r   Fc                 D    g | ]}|                                          S r   )r  r   r  r   s     rW   r   zabortgraft.<locals>.<listcomp>b  s%    444aDGKKMM444r.   Tc                 H    g | ]}|                                          |S r   )mutabler   s     rW   r   zabortgraft.<locals>.<listcomp>e  s,    BBB1Q0A0ABQBBBr.   s%   cannot clean up public changesets %s
r>  c              3   B   K   | ]}t          |                   V  d S rx   )bytesr  s     rW   r  zabortgraft.<locals>.<genexpr>i  s-      ??U47^^??????r.   s    see 'hg help phases' for detailsr  s;   new changesets detected on destination branch, can't strip
c                 6    g | ]}|                                 S r   r  ro  s     rW   r   zabortgraft.<locals>.<listcomp>}  s-       !"AFFHH  r.   r  )r  s   graft aborted
s   working directory is now at %s
   )r  r   r  r   readgraftstaterY   r  ru   r  rn   r   r  r   r   descendantsrR  r  r#  clean_updater   r  r   r   delete)
rn   r   
graftstate	statedatanewnodesstartctxcleanup	immutabledescstrippointss
    `        rW   
abortgraftr  M  s     Dq!ABBCCCtZ00I}}[))H k!CDDEEE 8}}q$'')):G G44448444BBBBBBB	 	GLL;<<**????Y?????@:;;    
 G 4>--h7788#h-- 	GLL-    G 	G G Gtyy{{ G G%h/// &*hh}h&G&G   TWdKFFFFG G G G G G G G G G G G G G G G G G G G G G G G G G G G G G  (:h'''IIa"##$$$IIa344x||~~crc7JJKKK1s7   2H<AH%H<%H)	)H<,H)	-H<<I I c                     	 |                                 S # t          j        $ r3 | j                             d                                          }d|icY S w xY w)zDread the graft state file and return a dict of the data stored in it
   graftstates   nodes)r  r   CorruptedStater'   r  )r   r  nodess      rW   r  r    se    !    ! ! !m,,7799%    !s    ?AAc                     |                                 5  t          j        |d          }t          | ||          cddd           S # 1 swxY w Y   dS )z/abort logic for aborting graft using 'hg abort'r  N)rR  r  cmdstater  )rn   r   r  s      rW   hgabortgraftr    s    	 0 0&t];;
"dJ//0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s   &AAArx   )F)Tr  )FNNr.   r  )NNNN)r\  )r7  FNN)FNN)r.   )NNr.   F)NNN)FN)FF)r   r   r  r   r  i18nr   r  r   r   r   r   r   r	   r
   
thirdpartyr   r  r   r   r   r   ry   r   r   r   r   r   r   r   r   r#  r   r  r   r   r   r   r   r   r   r    r!   r"   r  r#   r$   r%   r&   r'   rt  utilsr(   r)   revlogutilsr*   rr  TYPE_CHECKINGtypingr+   r,   r#  r  
dryrunoptsconfirmopts
remoteoptswalkopts
commitoptscommitopts2commitopts3formatteroptstemplateoptslogoptsr9  
diffwsopts	diffopts2mergetooloptssimilarityoptssubrepooptsdebugrevlogoptsr  r_   rd   rp   rv   r~   r   r   r   r   r   r   rW  rY  r  r  r8  r  r  r  r  r  r  r  r  r  r  r  r$  r,  r2  rE  rG  r  rJ  rb  r{  r}  r  r  r  r  r  r  r  r!  r%  r0  r6  r:  r<  rN  rS  r   rw  r  r   r  r  r  r  r   r  r  r  r  r  r  r  r-  r/  rD  rC  hooksoutgoinghookssummaryhookssummaryremotehooksr   r  r  r  r  r  r  r  r  r   r.   rW   <module>r     sg        				 				               
         
                                                                 >       
              
 4[  =
 
:tQQKLLM

 	*dAA<==>
 
63788!!F))D	
9::	&		 		
KLL	
& 	
	
677	* 	
	
677	*$ 
:sAA;<<aajjI	:sAA>??7L
 		
566	'

 		
344	'

$ 
>4#L!M!MN	>4#J!K!KL 
;QQ788!!K..I 		
9::	( 
;QQ788!!K..I	 
8T11]++,	64:;;<	8S!!@AA11V99M	<qq!6778'4FGGH	8T115667  
7D!!6778	
=>>	 	)T11KLLM*dAA=>>?
 		
455	 		
899	 		
566	 		
011	'
: 
k4#L!M!MNAQ 		
 
j$"K L LM  A344AfII	
 
gtQQJKKLA788AfII	
 
D 
7C01111W::> 		
:;;	- k4+J)K)KLM 
<"3 4 45	;qq!1223&#qq3445 K
  *2 2 2  6
D 
D 
D& & &
( ( (
3 3 3     B B B B(   &i7 i7 i7Xb  b  b  b  b  b  b  b J6' 6' 6'r. . . tLB LB LB LB LB LB LB LB^  $$ $ $ $N- - - -"dO dO dON  , , , ,&  ,% % %& :=   @  " " "&$ $ $ $"       0D D D DNB B B" " "
       (   H H H HV
B 
B 
Bk k k k`     V V Vv  ** ** **ZL L L  4, , , 	
(
 (
 (
 (
VF F F F   @  9 9 9x@ @ @b b bJ- - -b MQT T T Tn9 9 9  &; ; ;|< < <2	( 	( 	(n n nb    #> > > >B  "F F F        F=L =L =L =L@D D Dy y yF
 K- K- K- K-b 
 tz||  TZ\\ ; ; ; ;:1 1 1"    ,( ( ( F F F = = =@! ! !0 0 0 0 0r.   