
    q&fc                        d Z ddlZddlZddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZ dZi Z e
j                   e      Zd Z edg  ed	      ej$                  d
      d        Zd Z G d d      Z G d d      Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d  Z%d! Z&d" Z'd# Z(d$ Z)d% Z*d& Z+d' Z,d( Z-d) Z.d* Z/d+ Z0d, Z1d- Z2d. Z3d/ Z4d0 Z5d1 Z6d2 Z7d3 Z8d4 Z9d5 Z:d6 Z;d7 Z<d8 Z=d9 Z>d: Z?i d;ed<ed=ed>ed?ed@edAedBedCe dDe!dEe"dFe$dGe%dHe&dIe'dJe(dKe)i dLe*dMe+dNe,dOe-dPe.dQe/dRe0dSe1dTe2dUe3dVe4dWe5dXe6dYe7dZe8d[e9d\e:e?e#d]Z@e;e<e=e>d^ZAy)_ztry mapping git commands to Mercurial commands

Tries to map a given git command to a Mercurial command:

  $ hg githelp -- git checkout master
  hg update master

If an unknown command or parameter combination is detected, an error is
produced.
    N)_)encodingerror	fancyoptspycompat	registrarscmutil)procutils   ships-with-hg-corec                     | j                  d      r| dd  S d| v r| j                  dd      } t        j                  dd|       } | S )Ns   origin/   s   HEAD   .s   ~$s   ~1)
startswithreplaceresub)ss    //usr/lib/python3/dist-packages/hgext/githelp.pyconvertr   +   sG    ||Ju!|IIgt$
ueQAH    s   githelp|gits
   hg githelpT)helpcategory	helpbasicc                 N   t        |      dk(  st        |      dk(  r&|d   dk(  rt        j                  t        d            |d   dk(  r|dd }|d   }|t        vr!t        j                  t        d      |z        | j                  d       |dd }t	        |   | |g|i |S )zgsuggests the Mercurial equivalent of the given git command

    Usage: hg githelp -- <git command>
    r      s   gits8   missing git command - usage: hg githelp -- <git command>Ns   error: unknown git command %ss   githelp)lenr   Abortr   gitcommandspager)uirepoargskwargscmds        r   githelpr#   5   s     4yA~#d)q.T!W->kkIJ
 	
 Aw&ABx
q'C+kk!<=CDDHHZ8DsB6t6v66r   c           
         t        |      }i }t        |      }	 	 t        j                  t        |      ||d      }	 |D cg c]  }t        |       }}t        |j!                         D 	
cg c]&  \  }	}
t#        |
t$              r|	t        |
      fn|	|
f( c}
}	      }||fS # t        j                  $ r}}d|j                  v r d|j
                  z   |j                  v r#dt        j                  |j
                        z   }n|d|j
                  z   |j                  v r#dt        j                  |j
                        z   }n>t        j                  t        d      t        j                  |j
                        z        	 |j                  |       nz# t        $ rn t        d      }t        d	      }t        j                  |t        j                  |j
                        z  |t        j                  |j
                        z  
      w xY w| j                  t        d      |z         Y d }~nd }~ww xY w c c}w c c}
}	w )NTzrequires argumentz--   ---   -s   unknown option %ss-   unknown option '%s' packed with other optionss2   please try passing the option as its own flag: -%s)hints   ignoring unknown option %s
)listr   getoptGetoptErrormsgoptr   bytestrr   r   r   remove	Exceptionwarnr   dictitems
isinstancebytes)r   
cmdoptionsr    optsexflagr,   r(   xkvs              r   parseoptionsr=   S   s   j!JD:D
	?&&tDz:tTJD0 !%%1GAJ%D% 

	
1  *!U3Q
O!Q?	
D :? !! 	?"bff,rvv"&&(x//77,266)h..rvv66kk*+h.>.>rvv.FF D! HINOkk(**26622 0 0 88  GGA56=>>+	?	 6 &	
s=   !B$ H:-+H?
$H58C	H0FH0A7H H00H5c                   T    e Zd Zd Zd Z ej                  e      Zd Zd Z	d Z
d Zy)Commandc                 .    || _         g | _        i | _        y N)namer    r7   )selfrB   s     r   __init__zCommand.__init__~   s    			r   c                 T   d| j                   z   }| j                  r]t        | j                  j                               D ]7  \  }}|D ]-  }|r t	        |t
              rd}nd}||||fz  z  }%|d|fz  z  }/ 9 | j                  r#|dz  }|dj                  | j                        z  }|S )Ns   hg s    %s %ds    %s %ss    %s    )rB   r7   sortedr3   r4   intr    join)rC   r"   r;   valuesr<   fmts         r   	__bytes__zCommand.__bytes__   s    tyy 99#DIIOO$56 
-	6 	-A%a-"+C"+CsaV|+v},	-
- 994KC499TYY''C
r   c                 :    | j                   j                  |       y rA   )r    append)rC   values     r   rN   zCommand.append   s    		r   c                 :    | j                   j                  |       y rA   )r    extend)rC   rJ   s     r   rQ   zCommand.extend   s    		 r   c                 ^    | j                   j                  |g       }|j                  |       y rA   )r7   
setdefaultrN   )rC   keyrO   rJ   s       r   __setitem__zCommand.__setitem__   s$    %%c2.er   c                     t        | |      S rA   
AndCommandrC   others     r   __and__zCommand.__and__       $&&r   N)__name__
__module____qualname__rD   rL   r   	strmethod__str__rN   rQ   rU   r[    r   r   r?   r?   }   s4    
& !h  +G !'r   r?   c                       e Zd Zd Zd Zd Zy)rX   c                      || _         || _        y rA   leftright)rC   rf   rg   s      r   rD   zAndCommand.__init__   s    	
r   c                 8    d| j                   | j                  fz  S )Ns   %s && %sre   )rC   s    r   ra   zAndCommand.__str__   s    dii444r   c                     t        | |      S rA   rW   rY   s     r   r[   zAndCommand.__and__   r\   r   N)r]   r^   r_   rD   ra   r[   rb   r   r   rX   rX      s    5'r   rX   c                 `   ddg}t        | ||      \  }}|j                  d      r&| j                  t        d             t	        d      }nHt	        d      }|j                  d      s|j                  |       n| j                  t        d             | j                  t        |      d	       y )
N)   A   allNr      p   patchNr   ro   sU   note: Mercurial will commit when complete, as there is no staging area in Mercurial

   commit --interactive   addrl   s?   note: use hg addremove to remove files that have been deleted

   
)r=   getstatusr   r?   rQ   r5   r   r   r    r!   r6   r7   r"   s          r   addrv      s    !#J b*d3JD$xx
		@	
 -.foxxJJtII( IIuSzE"r   c                 n    g }t        | ||       t        d      }| j                  t        |      d       y )Ns   importrr   r=   r?   rt   r5   r   r   r    r!   r6   r"   s         r   amrz      s/    JZ&
)
CIIeCj% r   c                 >   ddt         dfdg}t        | ||      \  }}t        d      }|j                  d      r|j                  d      |d<   |j                  d      r|j                  d      |d<   |j	                  |       | j                  t        |      d       y )	Nrn   r   )r   	   directoryr   r   s   import --no-commit   -pr|   s   --prefixrr   )rH   r=   r?   rs   rQ   rt   r5   ru   s          r   applyr~      s    	tS#%J b*d3JD$
'
(Cxx~XXd^E
xx88L1KJJtIIuSzE"r   c                 8    | j                  t        d             y )Ns,   see 'hg help bisect' for how to use bisect

rt   r   r   r   r    r!   s       r   bisectr      s    IIaABCr   c                     g }t        | ||      \  }}t        d      }|j                  |D cg c]  }t        |       c}       | j	                  t        |      d       y c c}w )Ns   annotate -udlrr   )r=   r?   rQ   r   rt   r5   r   r   r    r!   r6   r7   r"   r<   s           r   blamer      sV    Jb*d3JD$
"
#CJJD)q
)*IIuSzE" *s   A"c                    g d}t        | ||      \  }}t        d      }|j                  d      s|j                  d      r| j                  t	        d             y |j                  d      rt        d      }|D ]  }||d<   	 d |d<   n|j                  d	      rkt        |      d
kD  r#t        |      dkD  r|j                  d
      }n!d}nt        j                  t	        d            |d
   }	||d<   |j                  |	       nMt        |      dkD  r|d   |d<   |j                  |d
          n"t        |      dk(  r|j                  |d
          | j                  t        |      d       y )N))r   s   set-upstreamNr   )r   s   set-upstream-tor   r      d   deleteNr   )   Dr   Nr   )   m   moveNr   )   Mr   Nr      bookmarks   set_upstreams   set_upstream_tos.   Mercurial has no concept of upstream branches
r   s   strip   -Br   r   r   s"   `hg log -T"{activebookmark}" -r .`s   missing newbranch argument   -m   -rrr   )r=   r?   rs   rt   r   r   popr   r   rN   r5   )
r   r   r    r!   r6   r7   r"   brancholdnews
             r   r   r      sJ   J b*d3JD$
+
Cxx DHH-?$@
		!FGH	)	h 	FCJ	 CJ	'	t9q=4y1}hhqk <++a =>??1gE


3t9q=aCJJJtAwY!^JJtAwIIuSzE"r   c                    t        j                  | |      ry| j                         }|dk(  r|}n|dz   |z   }| j                  j	                  |      }|ry| d   j                         }||v xs |j                  |      }|S )a  
    The first argument to git checkout can either be a revision or a path. Let's
    generally assume it's a revision, unless it's obviously a path. There are
    too many ways to spell revisions in git for us to reasonably catch all of
    them, so let's be conservative.
    Fr      /Tr   )r	   isrevsymbolgetcwdwvfsexistsmanifesthasdir)r   stringcwdrepopathr   r   didexists          r   ispathr   !  s     4( 
++-C
cz:&YYh'FDz""$HH$B)BHOr   c                 `   g d}g }d|v r-|j                  d      }|j                  ||dz   d         |d | }t        | ||      \  }}d }|rt        ||d         r||z   }n|r|d   }|dd  |z   }t	        d      }	|j                  d      r	|s|rd |	d<   |j                  d      rt	        d	      }	d |	d
<   |j                  d      rt        |      dk(  r-t	        d      }	|	j                  |j                  d             n|	j                  |d          t	        d      }
|
j                  |j                  d             |	|
z  }	nt        |      dkD  rT| j                  t        d             t	        d	      }	|j                  d      rd |	d
<   |r||	d<   |	j                  |       nk|r)|j                  d      r||	d<   nR|	j                  |       n@|j                  d      rt	        d	      }	d |	d<   nt        j                  t        d            | j                  t        |	      d       y )N)   b   branchr   r   )   Br   r   r      f   forceNr   rm   r%   r   r      updater   s   -Cro      revert   -ir   r   s5   note: use --no-backup to avoid creating .orig files

r      --alls   a commit must be specifiedrr   )indexrQ   r=   r   r?   rs   r   rN   rt   r   r   r   r5   )r   r   r    r!   r6   pathssepindexr7   revr"   bookcmds              r   checkoutr   >  s   J E}::e$T(Q,.)*IXb*d3JD$
CtT!W%u	1gQR5 
)
CxxCCJxxi E
xx	t9>+&CJJtxx	*+JJtAwk*GNN488I./-C	Ua
		!NOPi 88HCJCJ

5	88HCJJJsO	(	i Hkk!9:;;IIuSzE"r   c                 L   g d}t        | ||      \  }}t        d      }|j                  d      rd |d<   |j                  d      rd |d<   n=|j                  d      r| j                  t	        d             y |j                  |       | j                  t        |      d	       y )
N)r      continueNr   r      abortNr   )   e   editNr   s   graftr   s   --editr   
   --continuer   s&   note: hg graft does not have --abort

rr   r=   r?   rs   rt   r   rQ   r5   ru   s          r   
cherrypickr   ~  s    J
 b*d3JD$
(
CxxIxx!M	(	
		!?@A

4IIuSzE"r   c                     g d}t        | ||      \  }}t        d      }|j                  d      rd |d<   |j                  |       | j	                  t        |      d       y )N))r   r   Nr   r   )   xr   Nr   s   purger   r   rr   )r=   r?   rs   rQ   rt   r5   ru   s          r   cleanr     sY    J
 b*d3JD$
(
Cxx~HJJtIIuSzE"r   c                 L   g d}t        | ||      \  }}t        |      dk(  rt        j                  t	        d            t        d      }|j                  |d          t        |      dkD  r|j                  |d          |j                  d      r d |d<   | j                  t	        d             n|j                  d	      rd |d<   |j                  d
      r0t        d      }|j                  |j                  d
             ||z  }| j                  t        |      d       y )N))r      bareNr   )   ns   no-checkoutNr   r   r   s'   a repository to clone must be specified   cloner   r   s   -Usa   note: Mercurial does not have bare clones. -U will clone the repo without checking out a commit

s   no_checkoutr   r   rr   )
r=   r   r   r   r   r?   rN   rs   rt   r5   )r   r   r    r!   r6   r7   r"   cocmds           r   cloner     s    J
 b*d3JD$
4yA~kk!FGHH
(
CJJtAw
4y1}

47xxE

		L	
 
.	!E
xx		"TXXi()EkIIuSzE"r   c                    g d}t        | ||      \  }}t        d      }|j                  d      rt        d      }|j                  d      r"|j                  d      rt        d      }nd |d<   |j                  d      r|j                  d      |d	<   |j                  d
      rd|j                  d
      fz  |d<   |j                  d      r| j                  t	        d             |j                  d      r|j                  d      |d<   |j                  d      r|j                  d      |d<   |j                  d      r|j                  d      |d<   |j                  |       | j                  t        |      d       y )N)	   arl   Nr   )r      messager   r   rm   )   Cs   reuse-messager   r   )   F   filer   r   )r      authorr   r   )r      dater   r   )r      amendNr   )r   s   no-editNr      commitro   rp   r   s   no_edits   --amends   reuse_messages   -Mr   s   '%s'r   rl   sq   note: Mercurial doesn't have a staging area, so there is no --all. -A will add and remove files for you though.

r      -lr   s   -ur      -drr   r   ru   s          r   commitr     sN   
J b*d3JD$
)
Cxx-.xx88J(#C"C
Oxx !XX./E
xx
 466E
xx
		'	
 xxXXg&E
xx	XXi(E
xxXXg&E
JJtIIuSzE"r   c                 8    | j                  t        d             y )NsX   this command has been deprecated in the git project, thus isn't supported by this tool

)r1   r   r   s       r   
deprecatedr     s    GG	6	
r   c                    g d}t        | ||      \  }}t        d      }|j                  d      r| j                  t	        d             |j                  d      rd |d<   t        |      D ]*  }|j                  |       	 |j                  |       ||d<   , | j                  t        |      d       y # t        $ r |j                  |       Y ew xY w)	N)r   )r      cachedNr   )   R   reverseNr      diffr   sL   note: Mercurial has no concept of a staging area, so --cached does nothing

r   s	   --reverser   rr   )r=   r?   rs   rt   r   r)   r/   revsr0   rN   r5   )r   r   r    r!   r6   r7   r"   as           r   diffr     s    J
 b*d3JD$
'
Cxx	
		0	
 xx
 L$Z A	IIaLCJ	 IIuSzE"  	JJqM	s   B55CCc                 8    | j                  t        d             y )Ns  Mercurial does not enable external difftool by default. You need to enable the extdiff extension in your .hgrc file by adding
extdiff =
to the [extensions] section and then running

hg extdiff -p <program>

See 'hg help extdiff' and 'hg help -e extdiff' for more information.
r   r   s       r   difftoolr   &  s    II		

r   c                 R   ddg}t        | ||      \  }}t        d      }t        |      dkD  r_|j                  |d          t        |      dkD  r=| j	                  t        d             |dd  D ]  }||j                  v r||d<   ||d<    | j	                  t        |      d	       y )
Nr   rl   Nr   r      pullr   r      note: Mercurial doesn't have refspecs. -r can be used to specify which commits you want to pull. -B can be used to specify which bookmark you want to pull.

r   r   rr   r=   r?   r   rN   rt   r   
_bookmarksr5   r   s           r   fetchr   4  s     #J b*d3JD$
'
C
4y1}

47t9q=II) !"X #'!"CJ!"CJ	# IIuSzE"r   c                     g }t        | ||      \  }}t        d      }|j                  |       | j                  t	        |      d       y )N   greprr   )r=   r?   rQ   rt   r5   ru   s          r   grepr   Q  sC    Jb*d3JD$
'
C JJtIIuSzE"r   c                     g }t        | ||      \  }}t        d      }t        |      dkD  r|j                  |d          | j	                  t        |      d       y )N   initr   rr   r=   r?   r   rN   rt   r5   ru   s          r   initr   ^  sP    Jb*d3JD$
'
C
4y1}

47IIuSzE"r   c                 0   g d}t        | ||      \  }}|j                  d      xs |j                  d      }|r.t        d      }||d<   | j                  dt	        |      z         y | j                  t        d             | j                  t        d             t        d	      }d |d
<   |j                  d      r|j                  d      |d<   |j                  d      rd|d<   |j                  d      rd |d<   |j                  d      rd |d<   |j                  d      rd |d<   |j                  d      s"|j                  d      s|j                  d      rU|j                  dd      }d|v r | j                  t        d             d|d<   n| j                  t        d             d|d<   t        |      dkD  r<d|d   v r$|d   j                  d      \  }	}
d |	|
fz  |d!<   |d= |j                  |       | j                  t	        |      d"       y )#N))r   s   followNr   )r   s   decorateNr   )r      numberr   r   )   1r   Nr   r      prettyr   r   )r      formatr   r   )r      onelineNr   )r      statNr   )r      graphNr   rm   )   Gs	   grep-diffr   r   )   Ss   pickaxe-regexr   r   s	   grep_diffs   pickaxe_regexr   s   --diffs   %s
se   note: -v prints the entire commit message like Git does. To print just the first line, drop the -v.

sF   note: see hg help revset for information on how to filter log output

   logs   -vr   r   r   r      --statr   s   -Gro   r}   r   r   r   r      format:sc   note: --format format:??? equates to Mercurial's --template. See hg help templates for more info.

s   ???s
   --templatesq   note: --pretty/format/oneline equate to Mercurial's --style or --template. See hg help templates for more info.

s   --styler   s   ..s   '%s::%s'r   rr   )	r=   rs   r?   rt   r5   r   r   splitrQ   )r   r   r    r!   r6   r7   grep_patr"   formatsinceuntils              r   logr  j  s	   J b*d3JD$xx%C2B)CHg!I
		'E#J&'II	;	
 II		
 &/CCJxx	XXi(E
xx~E
xxIxxE
xxE
xx	dhhy1TXXj5I)S)IIL "(CII& %C
O
4y1}DG7==/LE5$u~5CJQ

4IIuSzE"r   c                    g d}t        | ||      \  }}|j                  d      s3|j                  d      s"|j                  d      s|j                  d      rdt        d      }|j                  d      rd |d<   |j                  d      rd |d<   |j                  d      rd |d	<   |j                  d      rd |d
<   nt        d      }|j                  d      r| j                  t	        d             |j                  d      rd |d<   |j                  d       |D ]  }t        j                  |      |d<    | j                  t        |      d       y )N))   cr   Nr   )r      deletedNr   )r      modifiedNr   )   o   othersNr   )   i   ignoredNr   )   s   stageNr   )   z   _zeroNr   r  r  r	  r     statusr   r   s   -or   s   filesr  s>   note: Mercurial doesn't have a staging area, ignoring --stage
r  s   -0r   s   -Irr   )	r=   rs   r?   rt   r   rN   r
   
shellquoter5   )r   r   r    r!   r6   r7   r"   includes           r   lsfilesr    s6   J b*d3JD$ 	88J88I88Ji 88JCJ88K CJ88ICJ88JCJhxx
			
 xxE
JJt 2((1E
2 IIuSzE"r   c                     g }t        | ||      \  }}t        d      }t        |      dkD  r |j                  |t        |      dz
            | j	                  t        |      d       y )N   merger   r   rr   r   ru   s          r   merger    sY    Jb*d3JD$
(
C
4y1}

4D	A&'IIuSzE"r   c                     g }t        | ||      \  }}t        |      dk7  rddg}t        d|d   |d   fz        }| j                  t	        d      t	        d             | j                  t        |      d	       y )
N   rk   r   s&   log -T '{node}\n' -r 'ancestor(%s,%s)'r   r   s1   note: ancestors() is part of the revset language
s3   (learn more about revsets with 'hg help revsets')

rr   )r=   r   r?   rt   r   r5   ru   s          r   	mergebaser    s    Jb*d3JD$
4yA~d|
2d1gtAw5GGC II	
?@	
BC IIuSzE"r   c                     g }t        | ||      \  }}t        d      }t        |      dk(  rd |d<   |j                  |       | j	                  t        |      d       y )Ns   resolver   r   rr   )r=   r?   r   rQ   rt   r5   ru   s          r   	mergetoolr    sU    Jb*d3JD$
*
C
4yA~HJJtIIuSzE"r   c                     ddg}t        | ||      \  }}t        d      }|j                  |       |j                  d      rd |d<   |j                  d      rd |d<   | j	                  t        |      d       y )	Nr   r   s   dry-runNr      mvr      -f   dry_run   -nrr   r=   r?   rQ   rs   rt   r5   ru   s          r   mvr#    t    #%J b*d3JD$
%.CJJtxxE
xx
E
IIuSzE"r   c                 \   g d}t        | ||      \  }}t        d      }d |d<   t        |      dkD  r_|j                  |d          t        |      dkD  r=| j	                  t        d             |dd  D ]  }||j                  v r||d<   ||d<    | j	                  t        |      d	       y )
N)r   r   )   r   rebaseNr   r   s   --rebaser   r   r   r   r   rr   r   r   s           r   pullr(  #  s    J
 b*d3JD$
'
CC
4y1}

47t9q=II) !"X #'!"CJ!"CJ	# IIuSzE"r   c                 ~   ddg}t        | ||      \  }}t        d      }t        |      dkD  r_|j                  |d          t        |      dkD  r=| j	                  t        d             |dd  D ]  }||j                  v r||d<   ||d<    |j                  d	      rd |d
<   | j	                  t        |      d       y )Nr   r      pushr   r   s   note: Mercurial doesn't have refspecs. -r can be used to specify which commits you want to push. -B can be used to specify which bookmark you want to push.

r   r   r   r  rr   )	r=   r?   r   rN   rt   r   r   rs   r5   r   s           r   pushr+  B  s     #J b*d3JD$
'
C
4y1}

47t9q=II- !"X #'!"CJ!"CJ	# xxE
IIuSzE"r   c                 "   g d}t        | ||      \  }}|j                  d      ri| j                  t        d             t	        d      }t        |      dkD  r| j                  t        d             | j                  t        |      d       y |j                  d      r&t	        d	      }| j                  t        |      d       t	        d
      }|j                  d      s|j                  d      rd |d<   |j                  d      rd |d<   |j                  d      r| j                  t        d             t        |j                  d            |d<   t        |      dk  rt        j                  t        d            dt        |d         t        |d         fz  |d<   nPt        |      dk(  rt        |d         |d<   n0t        |      dk(  r"t        |d         |d<   t        |d         |d<   | j                  t        |      d       y )N)r   )r
     interactiveNr   )r      ontor   r   r   r   )r      skipNr   r-  sE   note: hg histedit does not perform a rebase. It just edits history.

s   histeditr   sc   also note: 'hg histedit' will automatically detect your stack, so no second argument is necessary

rr   r/  s   revert --all -r .r'  r   r   r   s   --abortr.  sx   note: if you're trying to lift a commit off one branch, try hg rebase -d <destination commit> -s <commit to be lifted>

r   r  s(   expected format: git rebase --onto X Y Zs   '::%s - ::%s'r   s   -ss   -b)
r=   rs   rt   r   r?   r   r5   r   r   r   ru   s          r   rebaser0  b  s   J b*d3JD$xx
		.	
 k"t9q=IIK 			5:&xx*+
		5:&
)
Cxx 1!MxxJxx
			
 TXXg./E
t9q=++a KLMM%a)9747;K(LLE
t9> a)CJY!^ a)CJ a)CJIIuSzE"r   c                    dg}t        | ||      \  }}t        d      }|j                  d      rd |d<   t        |      dkD  r|j	                  |d          | j                  t        |      d       | j                  t        d             y )Nr   s   journalrl   r   r   s   

sH   note: in hg commits can be deleted from repo but we always have backups
)r=   r?   rs   r   rN   rt   r5   r   ru   s          r   reflogr2    s     J b*d3JD$
*
CxxH
4y1}

47IIeCj'"II		
r   c                    g d}t        | ||      \  }}t        t        |      dkD  r|d   nd      }|j                  d      }|j                  d      r| j	                  t        d             |j                  d      r| j	                  t        d             t        d	      }|r|j                  d
       |j                  |       | j	                  t        |      d       y )N))r      softNr   )r      hardNr   )r      mixedNr   r   r   r5  r6  sB   note: --mixed has no meaning since Mercurial has no staging area

r4  sA   note: --soft has no meaning since Mercurial has no staging area

r   s   --cleanrr   )	r=   r   r   rs   rt   r   r?   rN   r5   )	r   r   r    r!   r6   r7   r   hardr"   s	            r   resetr8    s    J
 b*d3JD$D	AT!W48F88GDxx
		$	
 xx
		$	
 )
C

:JJvIIuSzE"r   c                     g }t        | ||      \  }}t        |      dkD  r| j                  t        d             t	        d      }|r|j                  |d          | j                  t        |      d       y )Nr   s;   note: hg backout doesn't support multiple commits at once

s   backoutr   rr   )r=   r   rt   r   r?   rN   r5   ru   s          r   revertr:    sn    Jb*d3JD$
4y1}
			
 *
C

47IIuSzE"r   c                 H   ddg}t        | ||      \  }}|j                  d      s|j                  d      rRt        d      }|j                  d      r| j                  t	        d             | j                  t        |      d       y | j                  t	        d             y )	N)r   s	   show-cdupNr   )r   s   show-toplevelNr   s	   show_cdups   show_toplevels   roots1   note: hg root prints the root of the repository

rr   s5   note: see hg help revset for how to refer to commits
)r=   rs   r?   rt   r   r5   ru   s          r   revparser<    s    &*J b*d3JD$xx*:!;g88L!IIaNOP
		5:&
		!MNOr   c                     ddg}t        | ||      \  }}t        d      }|j                  |       |j                  d      rd |d<   |j                  d      rd |d<   | j	                  t        |      d       y )	Nr   r     rmr   r  r   r!  rr   r"  ru   s          r   rmr?    r$  r   c                    ddddt         dfg}t        | ||      \  }}|j                  d      rS|j                  d      dk(  rt        d	      }d
|d<   nt        d      }|j	                  d       |j	                  d       nt        |      dkD  rat        ||d         rt        d      }nt        d      }|j                  |       |j                  d      rY|j	                  d|d   fz         n@|j                  d      r$t        d      }|j	                  d|d   fz         nt        d      }| j                  t        |      d       y )N)r   s   name-statusNr   r      Us   unifiedr   s   name_statusr   r   r  r   s   --changer   s   --style statuss   -r .r   s   cats   exports   --config diff.unified=%drr   )
rH   r=   rs   r?   rN   r   r   rQ   rt   r5   ru   s          r   showrB    s,   ("	z3$J
 b*d3JD$xx88I*,)$C#C&/CJJ()JJw	TQ$Q &/C)$C

488JJJ2d:6F5HHI	*	i 

.$z2B1DDEi IIuSzE"r   c                 :   dg}t        | ||      \  }}t        d      }t        |      dkD  r|d   nd }|dk(  rd |d<   |j                  d      r1d |d<   n*|dk(  r?|j                  d      rd |d<   nd |d	<   t        |      d
kD  r|j	                  |d
          n|dk(  rd |d<   n|dk(  r:d |d<   t        |      d
kD  r|j	                  |d
          n|j	                  d       n|dk(  s|dk(  r8t        d      }t        |      d
kD  r|j	                  |d
          |dk(  r`d |d<   nZ|dk(  s|dk(  r| j                  t        d             y t        |      dkD  r'|d   dk7  r	|d   |d<   nt        |      d
kD  r|d
   |d<   | j                  t        |      d       y )Nrm   s   shelver      listr   ro   r}      showr   r   s   clears	   --cleanups   dropr   s   <shelve name>s   pop   applys   unshelves   --keepr   s   createsT   note: Mercurial doesn't have equivalents to the git stash branch or create actions

s   saves   --namerr   )r=   r?   r   rs   rN   rt   r   r5   )r   r   r    r!   r6   r7   r"   actions           r   stashrH  .  s   #J b*d3JD$
)
CD	AT!W4FE
88HCJ	7	88HCJ!C	Nt9q=JJtAw	8	 L	7	E
t9q=JJtAwJJ'(	6	Vx/k"t9q=JJtAwX!C	N	9	) 3
		:	
 	t9q=Aw'!!%aITQ!%aIIIuSzE"r   c                     dg}t        | ||      \  }}t        d      }|j                  |       |j                  d      rd |d<   | j	                  t        |      d       y )N)r   r  Nr   r  r  r   rr   r"  ru   s          r   rt   rt   b  s]    $J b*d3JD$
)
CJJtxx
E
IIuSzE"r   c                     |st        j                  t        d            |d   }|t        vr!t        j                  t        d      |z        |dd  }t        |   | |g|i |S )Ns   missing svn commandr   s   unknown git svn command "%s"r   )r   r   r   gitsvncommands)r   r   r    r!   svncmds        r   svnrM  q  sl    kk!2344!WF^#kk!;<vEFF8D&!"d<T<V<<r   c                 n    g }t        | ||       t        d      }| j                  t        |      d       y )Nr*  rr   rx   ry   s         r   
svndcommitrO  |  s/    JZ&
'
CIIuSzE"r   c                     g }t        | ||       t        d      }|j                  d       | j                  t	        |      d       y )Nr      default-pushrr   r=   r?   rN   rt   r5   ry   s         r   svnfetchrS    s;    JZ&
'
CJJIIuSzE"r   c                     g }t        | ||      \  }}|st        j                  t        d            t	        d      }|d   |d<   | j                  t        |      d       y )Ns   missing find-rev argumentr   r   r   rr   )r=   r   r   r   r?   rt   r5   ru   s          r   
svnfindrevrU    sY    Jb*d3JD$kk!89::
&/CaCJIIuSzE"r   c                     dg}t        | ||       t        d      }|j                  d       t        d      }|j                  d       ||z  }| j                  t	        |      d       y )N)   ls   localNr   r   rQ  r'  s   tiprr   rR  )r   r   r    r!   r6   pullcmd	rebasecmdr"   s           r   	svnrebaserZ    sd    #J Z&gGNN?#	"IV
I
CIIuSzE"r   c                    g d}t        | ||      \  }}|j                  d      rt        d      }nt        d      }|st        j                  t        d            |j                  |d          t        |      dkD  r|d   |d<   |j                  d	      rd |d
<   |j                  d      rd |d<   | j                  t        |      d       y )N)r   )rW  rD  Nr   r   rD  s   tags   tags   missing tag argumentr   r   r   r   s   --remover   r  rr   )
r=   rs   r?   r   r   r   rN   r   rt   r5   ru   s          r   tagr]    s    J
 b*d3JD$xxgfo++a 7899

47t9q=aCJ88I#C88HCJIIuSzE"r   rq   s   amrF  s   bisects   blamer   s   checkouts   cherry-picks   cleanr   r   r   s   difftool   fetchr   r   r   s   ls-filesr  s
   merge-bases	   mergetoolr  r   r*  r'  s   reflogs   resetr   s	   rev-parser>  rE  s   stashr  s   svn)r\  s   whatchanged)s   dcommitr^  s   find-revr'  )B__doc__r*   r   mercurial.i18nr   	mercurialr   r   r   r   r   r	   mercurial.utilsr
   
testedwithcmdtablecommandr   CATEGORY_HELPr#   r=   r?   rX   rv   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r#  r(  r+  r0  r2  r8  r:  r<  r?  rB  rH  rt   rM  rO  rS  rU  rZ  r]  r   rK  rb   r   r   <module>rg     s7  	  	   % #

)

H
% 	m&&77.'T&' &'R	' 	'#>!#"D#)#X:=#@#.#  #F2#j#@#:
#	#M#`*#Z	##$	##$#>#@;#|* #F#&P #$#B1#h#=##
## #:%
C%	2% e% v	%
 e% v% % J% e% e% v% T% % e% T%  T!%" C#%$ %%& e'%( 9)%* )+%, 
2-%. T/%0 T1%2 v3%4 v5%6 e7%8 v9%: (;%< 
2=%> T?%@ eA%B vC%D CE%F I%P 	r   