ó
™Ácc           @   sX  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z e j d k  r‰ e j	 j
 d ƒ e j d ƒ n  i  Z i  Z i  Z i  Z d Z d „  Z d „  Z d	 Z d Z e Z yÁ e j e j d d
 d d d d g ƒ \ Z Z xk e D]c \ Z Z e dF k r6e Z e j j e ƒ Z n  e dG k rQe e ƒ Z n  e dH k re Z qqWe  e ƒ d k r‹e! d ƒ ‚ n  Wn e ƒ  e j d ƒ n Xe d Z" e j# e" ƒ e re j j$ e ƒ re rçd GHn  e% e d ƒ Z& e j' e& ƒ Z qd GHn  e j( d ƒ Z) e) j* ƒ  Z+ e) j, ƒ  rGe j d ƒ n  e r[d e+ f GHn  e rid GHn  dI e d <dJ e d <d e d <xœe. d e e+ ƒ d ƒ D]Z/ dK e e0 e/ ƒ <e j( d e/ ƒ j* ƒ  j1 ƒ  j2 d ƒ Z3 e4 d  „  e3 ƒ Z3 e3 d d	 k re3 d j1 ƒ  Z5 n e0 e/ d ƒ Z5 e e5 c e0 e/ ƒ f 7<e  e3 ƒ d k r{e3 d j1 ƒ  Z6 e e6 c e0 e/ ƒ f 7<n d Z6 e5 e6 f e e0 e/ ƒ <e6 r×e e6 d k rÀd e e0 e/ ƒ <q"e e5 e e0 e/ ƒ <q¡e e5 d e0 e/ ƒ k re e5 e e0 e/ ƒ <q¡d! e0 e/ ƒ e e0 e/ ƒ <q¡Wd e k rGd" GHe j7 d# ƒ n  x¬e. e e+ ƒ d ƒ D]”Z/ e0 e/ ƒ e k r|q^n  e d 7Z e j( d$ e/ ƒ j8 ƒ  Z9 e9 d j1 ƒ  Z: e9 d j1 ƒ  Z; e9 d% j1 ƒ  Z< e e0 e/ ƒ d Z5 e e0 e/ ƒ d Z6 e j= ƒ  \ Z> Z? e j( d& e/ ƒ j* ƒ  j1 ƒ  Z@ e j
 e> e@ ƒ e j, e> ƒ d' GHd( e/ f GHd) e e0 e/ ƒ f GHd* e< f GHd+ e; f GHd, e@ f GHe5 rŸd- e5 f GHn  e6 r³d. e6 f GHn  e: rÇd/ e: f GHn  d' GHe/ d k rhe e0 e/ ƒ d! e0 e/ ƒ k r5d0 e e0 e/ ƒ f GHe j7 d1 e e0 e/ ƒ e e5 f ƒ qhd2 e e0 e/ ƒ f GHe j7 d3 e e0 e/ ƒ ƒ n  e6 rëe e5 e e0 e/ ƒ k r•e e6 ZA n
 e e5 ZA d4 eA d5 e e0 e/ ƒ f GHe j7 e e< e; ƒ d6 e e0 e/ ƒ eA f ƒ n  e j7 d7 ƒ e j7 d8 e/ ƒ e j7 d9 ƒ e j7 d: ƒ e j7 e e< e; ƒ d; e? ƒ e jB e? ƒ e: re: d< k re j7 e e< e; ƒ d= e: ƒ n  e6 r¼e  e e0 e/ ƒ ƒ r¼d> eA f GHe j7 d? eA ƒ n  e j( d@ ƒ j* ƒ  ZC dA e/ dB eC f GHeC e e0 e/ ƒ <q^We e k re d k re j7 dC ƒ n  e rTe r2dD GHn  e% e dE ƒ Z& e jD e e& ƒ n  d S(L   sâ   hg-to-git.py - A Mercurial to GIT converter

    Copyright (C)2007 Stelian Pop <stelian@popies.net>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.
iÿÿÿÿNi  s,   hg-to-git.py: requires Python 2.3 or later.
i   i    c           C   s   d t  j d GHd  S(   Nsn  %s: [OPTIONS] <hgprj>

options:
    -s, --gitstate=FILE: name of the state to be saved/read
                         for incrementals
    -n, --nrepack=INT:   number of changesets that will trigger
                         a repack (default=0, -1 to deactivate)
    -v, --verbose:       be verbose

required:
    hgprj:  name of the HG project to import (directory)
i    (   t   syst   argv(    (    (    s2   /usr/share/git-core/contrib/hg-to-git/hg-to-git.pyt   usage+   s    c         C   sÓ   d } t  j d ƒ j |  ƒ } | rƒ | d | j d ƒ 7} | d | j d ƒ 7} | d | j d ƒ 7} | d | j d ƒ 7} n0 | d |  7} | d |  7} | d	 7} | d
 7} | d | 7} | d | 7} | S(   Nt    s   (.*?)\s+<(.*)>s   export GIT_AUTHOR_NAME="%s" ;i   s    export GIT_COMMITTER_NAME="%s" ;s   export GIT_AUTHOR_EMAIL="%s" ;i   s!   export GIT_COMMITTER_EMAIL="%s" ;s   export GIT_AUTHOR_EMAIL= ;s   export GIT_COMMITTER_EMAIL= ;s   export GIT_AUTHOR_DATE="%s" ;s    export GIT_COMMITTER_DATE="%s" ;(   t   ret   compilet   matcht   group(   t   usert   datet   envt   elems(    (    s2   /usr/share/git-core/contrib/hg-to-git/hg-to-git.pyt	   getgitenv=   s    

R   s   s:t:n:vs	   gitstate=s   tempdir=s   nrepack=t   verboses   -ss
   --gitstates   -ns	   --nrepacks   -vs	   --verboset   paramss   State does exist, readingt   rs   State does not exist, first runs   hg tip --template "{rev}"s   tip iss   analysing the branches...t   0t   masters#   hg log -r %d --template "{parents}"t    c         C   s   |  |  j  d ƒ  S(   Nt   :(   t   find(   t   x(    (    s2   /usr/share/git-core/contrib/hg-to-git/hg-to-git.pyt   <lambda>   s    s   branch-s   creating repositorys   git inits6   hg log -r %d --template "{tags}
{date|date}
{author}
"i   s    hg log -r %d --template "{desc}"s)   -----------------------------------------s   cset:s   branch:s   user:s   date:s   comment:s   parent:s   mparent:s   tag:s   creating new branchs   git checkout -b %s %ss   checking out branchs   git checkout %st   mergingt   intos&   git merge --no-commit -s ours "" %s %ssX   find . \( -path "./.hg" -o -path "./.git" \) -prune -o ! -name "." -print | xargs rm -rfs   hg update -C %ds=   git ls-files -x .hg --others | git update-index --add --stdinsA   git ls-files -x .hg --deleted | git update-index --remove --stdins7   git commit --allow-empty --allow-empty-message -a -F %st   tips
   git tag %ss   Deleting unused branch:s   git branch -d %ss#   git show --quiet --pretty=format:%Ht   records   ->s   git repack -a -ds   Writing statet   w(   s   -ss
   --gitstate(   s   -ns	   --nrepack(   s   -vs	   --verbose(    (   NN(    (E   t   __doc__t   ost   os.pathR    t   tempfilet   picklet   getoptR   t
   hexversiont   stderrt   writet   exitt   hgverst
   hgchildrent	   hgparentst   hgbrancht
   hgnewcsetsR   R   t   statet   opt_nrepackt   FalseR   R   t   optst   argst   ot   at   patht   abspatht   intt   Truet   lent	   Exceptiont   hgprjt   chdirt   existst   opent   ft   loadt   popent   sockt   readR   t   closet   Nonet   ranget   csett   strt   stript   splitt   prntst   mapt   parentt   mparentt   systemt	   readlinest   log_datat   tagR	   R   t   mkstempt	   fdcommentt   filecommentt   csetcommentt   otherbrancht   unlinkt   vvvt   dump(    (    (    s2   /usr/share/git-core/contrib/hg-to-git/hg-to-git.pyt   <module>   s  $$		.



 (
 (
1!