ó
    6°hû3  ã                  ó2  • S SK Jr  S SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
JrJr  SSKJr  \R                  " 5       rSrS	\-  rS
 rSr\(       a&  \R*                  \R,                  -  \R.                  -  rSrS rS rSS jrS S 4S jrS S 4S jrg)é    )ÚannotationsN)Ú_)Úsha1nodeconstants)ÚencodingÚerrorÚpycompaté   )Úgitutilé   a”  
CREATE TABLE refs (
  -- node and name are unique together. There may be more than one name for
  -- a given node, and there may be no name at all for a given node (in the
  -- case of an anonymous hg head).
  node TEXT NOT NULL,
  name TEXT
);

-- The "possible heads" of the repository, which we use to figure out
-- if we need to re-walk the changelog.
CREATE TABLE possible_heads (
  node TEXT NOT NULL
);

CREATE UNIQUE INDEX possible_heads_idx ON possible_heads(node);

-- The topological heads of the changelog, which hg depends on.
CREATE TABLE heads (
  node TEXT NOT NULL
);

-- A total ordering of the changelog
CREATE TABLE changelog (
  rev INTEGER NOT NULL PRIMARY KEY,
  node TEXT NOT NULL,
  p1 TEXT,
  p2 TEXT,
  synthetic TEXT,
  changedfiles BOOLEAN
);

CREATE UNIQUE INDEX changelog_node_idx ON changelog(node);
CREATE UNIQUE INDEX changelog_node_rev_idx ON changelog(rev, node);

-- Changed files for each commit, which lets us dynamically build
-- filelogs.
CREATE TABLE changedfiles (
  node TEXT NOT NULL,
  filename TEXT NOT NULL,
  -- 40 zeroes for deletions
  filenode TEXT NOT NULL,
-- to handle filelog parentage:
  p1node TEXT,
  p1filenode TEXT,
  p2node TEXT,
  p2filenode TEXT
);

CREATE INDEX changedfiles_nodes_idx
  ON changedfiles(node);

-- Cached values to improve performance
CREATE TABLE cache (
  ncommits INTEGER
);
INSERT INTO cache (ncommits) VALUES (NULL);

PRAGMA user_version=%d
c                óÎ  • [         R                  " [        R                  " U 5      5      n[        Ul        UR                  S5      R                  5       S   nUS:X  aL  [        R                  S5       H"  nUR                  UR                  5       5        M$     UR                  5         O*U[        :X  a  O[        R                  " [        S5      5      eUR                  S5        U$ )NzPRAGMA user_versionr   Ú;s(   sqlite database has unrecognized versionzPRAGMA journal_mode=WAL)Úsqlite3Úconnectr   ÚstrfromlocalÚbytesÚtext_factoryÚexecuteÚfetchoneÚ_SCHEMAÚsplitÚstripÚcommitÚ_CURRENT_SCHEMA_VERSIONr   ÚAbortr   )ÚpathÚdbÚresÚ	statements       Ú1/usr/lib/python3/dist-packages/hgext/git/index.pyÚ	_createdbr    W   s°   € ô 
�Šœ×.Ò.¨tÓ4Ó	5€BÜ€B„Oà
�*‰*Ð*Ó
+×
4Ñ
4Ó
6°qÑ
9€Cð ˆaƒxÜ Ÿ™ sÖ+ˆIØ�J‰J�y—‘Ó(Ö)ñ ,ð 	�	‰	�à	Ô'Ó	'Øô �kŠkœ!ÐGÓHÓIÐIà‡J�JÐ(Ô)à€Ió    © i    c                óê  • [        U[        5      (       d   S[        U5      -  5       e[        U[        5      (       d   S[        U5      -  5       eU R                  SX$45       Vs1 s H  nUS   R	                  S5      iM     nnUR                  U[        5      nU H5  nUR                  R                  U;   d  M  UR                  R                  s  $    [        R                  " SX$U45      es  snf )az  Find the nearest ancestor that introduces a file node.

Args:
  db: a handle to our sqlite database.
  gitrepo: A pygit2.Repository instance.
  file_path: the path of a file in the repo
  walk_start: a pygit2.Oid that is a commit where we should start walking
              for our nearest ancestor.

Returns:
  A hexlified SHA that is the commit ID of the next-nearest parent.
zfile_path must be str, got %rzfilenode must be str, got %rzASELECT node FROM changedfiles WHERE filename = ? AND filenode = ?r   Úasciiz8Unable to find introducing commit for %s node %s from %s)Ú
isinstanceÚstrÚtyper   ÚdecodeÚwalkÚ
_OUR_ORDERÚidÚhexr   ÚProgrammingError)	r   ÚgitrepoÚ	file_pathÚ
walk_startÚfilenodeÚrowÚparent_optionsÚinner_walkerÚws	            r   Ú'_find_nearest_ancestor_introducing_noder6   }   s  € ô �i¤×%Ñ%ð Ð'FÌØóJñ (ó Ð%ô �h¤×$Ñ$ð Ð&DÄtØóHñ 'ó Ð$ð
 —:‘:ð2àÐ!ô
óò
ˆCð 	ˆA‰�‰�gÖñ
ð ð ð —<‘< 
¬JÓ7€LÛˆØ�4‰4�8‰8�~Õ%Ø—4‘4—8‘8ŠOñ ô ×
 Ò
 ØBØ	˜jÐ)óð ùòs   Á&C0c           
     ón  • [        U[        5      (       d   S[        U5      -  5       e[        U[        5      (       d   S[        U5      -  5       e[        R                  " X$4/5      nU(       Ga¢  UR                  5       u  pgX   n/ n	UR                   HŠ  n
U
R                  nUR                  S5       H  n XU   R                     nM     [        XX:R                  UR                  R                  5      nU	R                  XÛR                  R                  45        MŒ     [        R                  =n=n=nnU	 HU  u  nn[!        UR#                  SUUU45      R%                  5       S   5      nUS:X  d  M=  Uc   eUR                  UU45        MW     U	(       a  U	S   u  pï['        U	5      S:X  a  U	S   u  nn['        U	5      S:”  a  [(        R*                  " S	5      eUR#                  S
XïUUUR                  R                  X745        U(       a  GM¢  UR-                  5         g! [         a       GMž  f = f)ar  Given a starting commit and path, fill in a filelog's parent pointers.

Args:
  gitrepo: a pygit2.Repository
  db: a handle to our sqlite database
  startcommit: a hexlified node id for the commit to start at
  path: the path of the file whose parent pointers we should fill in.
  filenode: the hexlified node id of the file at startcommit

TODO: make filenode optional
zstartcommit must be str, got %rz!startfilenode must be str, got %rÚ/zfSELECT COUNT(*) FROM changedfiles WHERE node = ? AND filename = ? AND filenode = ? AND p1node NOT NULLr   Né   r	   s'   git support can't handle octopus mergeszUPDATE changedfiles SET p1node = ?, p1filenode = ?, p2node = ?, p2filenode = ? WHERE node = ? AND filename = ? AND filenode = ?)r%   r&   r'   ÚcollectionsÚdequeÚpopleftÚparentsÚtreer   r+   ÚKeyErrorr6   r,   Úappendr
   ÚnullgitÚintr   r   Úlenr   r-   r   )r.   r   Ústartcommitr   ÚstartfilenodeÚvisitÚcnoder1   r   r=   ÚparentÚtÚcompÚ
introducerÚp1nodeÚp1fnodeÚp2nodeÚp2fnodeÚparÚparfnodeÚfounds                        r   Úfill_in_filelogrS   ¤   s0  € ô Ø”S÷ñ ð =à(¬4°Ó+<Ñ<ó=ð ô Ø”s÷ñ ð Aà*¬T°-Ó-@Ñ@óAð ô ×Ò Ð;Ð<Ó=€Eß
ØŸ-™-›/‰ˆØ‘ˆØˆØ—n”nˆFØ—‘ˆAØŸ
™
 3ž�ðØ $¡§
¡
Ñ+’Añ (ô EØ §y¡y°!·$±$·(±(ó�
ð —‘ 
¯D©D¯H©HÐ5Ö6ñ %ô /6¯o©oÐ=ˆÐ=�Ð=˜6 GÛ$‰MˆC�ÜØ—
‘
ð&ð ˜$ Ð)ó	÷
 ‘(“*˜Qñ óˆEð ˜�zØ‘Ð&�Ø—‘˜c 8˜_Ö-ñ %ö Ø% a™j‰OˆFÜˆw‹<˜1ÓØ% a™j‰OˆF�GÜˆw‹<˜!ÓÜ×(Ò(Ø:óð ð 	�
‰
ð?ð ˜f g¨v¯y©y¯}©}¸dÐMô		
÷K ‰%ðV ‡I�I…KøôE  ó Üðús   Â9H$È$
H4È3H4c                óB  • UR                  SU45      R                  5       S   nU(       a  g X   n0 nUR                  (       a#  UR                  S   R                  R                  OS nUb)  U R                  XcR                  R                  [        S9nOUR                  R                  S[        S9nS U 5       nU V	s0 s HN  n	U	R                  R                  [        R                  :w  d  M-  U	R                  U	R                  R                  _MP     nn	UR                  5        H1  u  p«UR                  SUR                  R                  X«S S S S 45        M3     UR                  SUR                  R                  45        U(       a  UR                  5         g g s  sn	f )	Nz/SELECT changedfiles FROM changelog WHERE node=?r   )ÚflagsT)ÚswaprU   c              3  óL   #   • U  H  oR                   R                  v •  M     g 7f©N)ÚdeltaÚnew_file)Ú.0Úps     r   Ú	<genexpr>Ú%_index_repo_commit.<locals>.<genexpr>÷   s   é € Ð4ª8 a—‘×!Ö!ª8ùs   ‚"$zwINSERT INTO changedfiles (node, filename, filenode, p1node, p1filenode, p2node, p2filenode) VALUES(?, ?, ?, ?, ?, ?, ?)z3UPDATE changelog SET changedfiles=TRUE WHERE node=?)r   r   r=   r+   r,   ÚdiffÚ_DIFF_FLAGSr>   Údiff_to_treeÚrawr   Únullidr   Úitemsr   )r.   r   Únoder   Úalready_doneÚfilesÚp1ÚpatchgenÚ	new_filesÚnfr\   Úns               r   Ú_index_repo_commitrm   å   sb  € Ø—:‘:Ø9¸D¸7óç�hƒj�ñ€Lö Øà‰]€FØ€Eð
 &,§^§^ˆ�‰˜Ñ	×	Ñ	×	!Ò	!¸€BØ	�~Ø—<‘< §I¡I§M¡M¼�<ÐE‰à—;‘;×+Ñ+°¼[Ð+ÐIˆÙ4©8Ó4€Iñ óâˆBØ�5‰5�9‰9Ô)×0Ñ0Ñ0ó 	ˆ�‰�—‘—‘ÒÙð 
ð ð
 —‘–‰ˆð 	�
‰
ð6ð �Y‰Y�]‰]˜A $¨¨d°DÐ9ö		
ñ	 ð ‡J�JØ=ÀÇ	Á	ÇÁÐ?Oôö Ø
�	‰	�ð ùò's   Ã ,FÃ0%Fc                ó   • g rX   r"   ©Úxs    r   Ú<lambda>rq     s   € �Dr!   c                 ó   • g rX   r"   ©ÚargsÚkwargss     r   rq   rq     s   € ¨Tr!   c           	     ó„	  • U R                  5       n[        5       nU" S5      n[        U5       H½  u  pxUb  UR                  U5        UR	                  S5      (       dD  UR	                  S5      (       d.  UR	                  S5      (       d  UR	                  S5      (       d  Ms   U R                  U5      R                  [        R                  5      n	UR                  U	R                  5        M¿     UR                  S5       V
s1 s H  n
[        R                  " U
S   5      iM     nn
S nU Vs1 s H  oÝR                  iM     nnXë:X  a  g U" S5        U H/  n	Uc  U R!                  U	["        5      nM  UR%                  U	5        M1     UR                  S	5        Ub  UR'                  5         U" S
5      nSnU GH¶  nUb  UR                  U5        [(        R*                  =nn[-        UR.                  5      S::  a   UR.                  (       a#  UR.                  S   R                  R                  n[-        UR.                  5      S:X  a#  UR.                  S   R                  R                  nUS-  nUR                  SXR                  R                  UU45        Mã  [1        UR.                  5      nUR3                  S5      R                  R                  nU(       d  GM'  US-  n[-        U5      S:X  a  UR                  R                  nS nOSU-  nUR                  R                  nUR3                  S5      R                  R                  nUR                  SUUUUU45        UnU(       a  M�  GM¹     UR                  S5        UR                  S5        UR5                  SU Vs/ s H  nUR                  4PM     sn5        UR                  S5        UR                  S5        Ub  UR'                  5         U" S5      nUR                  S5       Vs/ s H  nUS   R7                  S5      PM     nn[        U5       H%  u  p}Ub  UR                  U5        [9        XU5        M'     UR                  S5        UR;                  5         Ub  UR'                  5         g g ! [         a     GM|  f = fs  sn
f s  snf s  snf s  snf )Ns   indexing refszrefs/heads/z
refs/tags/zrefs/remotes/zrefs/hg/zSELECT node FROM possible_headsr   s$   heads mismatch, rebuilding dagcache
zDELETE FROM changelogs   indexing commitséÿÿÿÿr9   r	   zbINSERT INTO changelog (rev, node, p1, p2, synthetic, changedfiles) VALUES(?, ?, ?, ?, NULL, FALSE)z%040xz_INSERT INTO changelog (rev, node, p1, p2, synthetic, changedfiles) VALUES(?, ?, ?, ?, ?, FALSE)zDELETE FROM headszDELETE FROM possible_headsz+INSERT INTO possible_heads (node) VALUES(?)aB  
    INSERT INTO heads (node)
        SELECT node FROM possible_heads WHERE
            node NOT IN (
                SELECT DISTINCT possible_heads.node FROM changelog, possible_heads WHERE
                    changelog.p1 = possible_heads.node OR
                    changelog.p2 = possible_heads.node
            )
    zu
    UPDATE changelog SET changedfiles=TRUE WHERE node IN (
        SELECT DISTINCT node FROM changedfiles
    )
    s   indexing head fileszSELECT * FROM headsr$   zN
    UPDATE cache SET
        ncommits = (SELECT COUNT(1) FROM changelog)
    )Úlistall_referencesÚsetÚ	enumerateÚupdateÚ
startswithÚlookup_referenceÚpeelÚpygit2ÚGIT_OBJ_COMMITÚ
ValueErrorÚaddr+   r   r   Úsysstrr,   r)   r*   ÚpushÚcompleter
   rA   rC   r=   ÚlistÚpopÚexecutemanyr(   rm   r   )r.   r   ÚlogfnÚprogress_factoryÚall_refsÚpossible_headsÚprogÚposÚrefÚstartrp   Úcache_headsÚwalkerÚhÚcur_cache_headsr   rh   Úp2r=   ÚthisÚsynthÚhidr2   Úheadss                           r   Ú_index_reporš     s)  € ð ×)Ñ)Ó+€HÜ“U€NÙÐ,Ó-€DÜ˜hÖ'‰ˆØÑØ�K‰K˜Ôà�N‰N˜=×)Ñ)Ø�~‰~˜l×+Ñ+Ø�~‰~˜o×.Ñ.Ø�~‰~˜j×)Ñ)áð	Ø×,Ñ,¨SÓ1×6Ñ6´v×7LÑ7LÓMˆEð 	×Ñ˜5Ÿ8™8Ö$ñ (ð4 —‘Ð=Ô>óâ>ˆAô 	�Š˜˜!™ÖÙ>ð ð ð €FÙ&4Ó5¢n —u”u¡n€OÐ5ØÓ%ØÙ	Ð
2Ô3ÛˆØ‰>Ø—\‘\ %¬Ó4ŠFà�K‰K˜Öñ	  ð ‡J�JÐ&Ô'ØÑØ�‰ŒÙÐ/Ó0€Dð €CÜˆØÑØ�K‰K˜ÔÜ—/‘/Ð!ˆˆRÜˆv�~‰~Ó !Ó#Ø�~�~Ø—^‘^ AÑ&×)Ñ)×-Ñ-�Ü�6—>‘>Ó" aÓ'Ø—^‘^ AÑ&×)Ñ)×-Ñ-�Ø�1‰HˆCØ�J‰JØtØ—i‘i—m‘m R¨Ð,öô
 ˜6Ÿ>™>Ó*ˆGà—‘˜Q“×"Ñ"×&Ñ&ˆBß‘'Ø�q‘�ä�w“< 1Ó$Ø!Ÿ9™9Ÿ=™=�DØ ‘Eà" S™=�DØ"ŸI™IŸM™M�Eà—[‘[ “^×&Ñ&×*Ñ*�à—
‘
ØuØ˜$  B¨Ð.ôð
 �÷# “'ñ% ðJ ‡J�JÐ"Ô#Ø‡J�JÐ+Ô,Ø‡N�NØ5Ù-Ó.š~˜ˆ#�'‰'‹™~Ñ.ôð ‡J�Jð	ô
ð ‡J�Jð	ôð ÑØ�‰Œñ Ð2Ó3€Dà*,¯*©*Ð5JÔ*KóÚ*K 3ˆˆA‰�‰�gÖÑ*Kð 
ð ô ˜EÖ"‰ˆØÑØ�K‰K˜ÔÜ˜7¨Ö*ñ #ð
 ‡J�Jð	ôð ‡I�I„KØÑØ�‰�ð øôu ó 	ãð	üòùò
 6ùò| 	/ùò6s*   Â".RÄ#R.Ä-R3Î$R8
ÐR=Ò
R+Ò*R+c                ó   • g rX   r"   ro   s    r   rq   rq   ¤  s   € ˜Tr!   c                 ó   • g rX   r"   rs   s     r   rq   rq   ¤  s   € ÈDr!   c                óh  • [         R                  R                  [        R                  " U R                  5      SSS5      n[         R                  R                  U5      (       d  [         R                  " U5        [         R                  R                  US5      n[        U5      n[        XX5        U$ )Ns   ..s   .hgs   caches   git-commits.sqlite)	Úosr   Újoinr   ÚfsencodeÚexistsÚmakedirsr    rš   )r.   r‰   rŠ   Ú	cachepathÚdbpathr   s         r   Ú	get_indexr¥   £  s   € ô —‘—‘Ü×Ò˜'Ÿ,™,Ó'¨°¸ó€Iô �7‰7�>‰>˜)×$Ñ$Ü
�Š�IÔÜ�W‰W�\‰\˜)Ð%:Ó;€FÜ	�6Ó	€Bô �˜UÔ5Ø€Ir!   )F)Ú
__future__r   r:   rž   r   Úmercurial.i18nr   Úmercurial.noder   Ú	mercurialr   r   r   Ú r
   Ú
get_pygit2r   r   r   r    r*   ÚGIT_SORT_TOPOLOGICALÚGIT_SORT_TIMEÚGIT_SORT_REVERSEr`   r6   rS   rm   rš   r¥   r"   r!   r   Ú<module>r¯      sÁ   ðÝ "ã Û 	Û å Ý ,÷ñ õ ð 
×	Ò	Ó	€àÐ ð;ðx ñy<ð òBð6 €
Þ	à×#Ñ#Ø
×
Ñ
ñ	à
×
!Ñ
!ñ	"ð ð €ò$òN>ôB'ñZ Ù1ô	Qñj "Ñ4Põr!   