hgext/git/index.py
changeset 44484 ec54b3d2af0b
parent 44477 ad718271a9eb
child 44946 fb2936c5f6dc
equal deleted inserted replaced
44483:2e464925f662 44484:ec54b3d2af0b
     1 from __future__ import absolute_import
     1 from __future__ import absolute_import
     2 
     2 
     3 import collections
     3 import collections
     4 import os
     4 import os
     5 import sqlite3
     5 import sqlite3
     6 
       
     7 import pygit2
       
     8 
     6 
     9 from mercurial.i18n import _
     7 from mercurial.i18n import _
    10 
     8 
    11 from mercurial import (
     9 from mercurial import (
    12     encoding,
    10     encoding,
    15     pycompat,
    13     pycompat,
    16 )
    14 )
    17 
    15 
    18 from . import gitutil
    16 from . import gitutil
    19 
    17 
       
    18 
       
    19 pygit2 = gitutil.get_pygit2()
    20 
    20 
    21 _CURRENT_SCHEMA_VERSION = 1
    21 _CURRENT_SCHEMA_VERSION = 1
    22 _SCHEMA = (
    22 _SCHEMA = (
    23     """
    23     """
    24 CREATE TABLE refs (
    24 CREATE TABLE refs (
    99     db.execute('PRAGMA journal_mode=WAL')
    99     db.execute('PRAGMA journal_mode=WAL')
   100 
   100 
   101     return db
   101     return db
   102 
   102 
   103 
   103 
   104 _OUR_ORDER = (
   104 _OUR_ORDER = ()
   105     pygit2.GIT_SORT_TOPOLOGICAL | pygit2.GIT_SORT_TIME | pygit2.GIT_SORT_REVERSE
   105 if pygit2:
   106 )
   106     _OUR_ORDER = (
       
   107         pygit2.GIT_SORT_TOPOLOGICAL
       
   108         | pygit2.GIT_SORT_TIME
       
   109         | pygit2.GIT_SORT_REVERSE
       
   110     )
   107 
   111 
   108 _DIFF_FLAGS = 1 << 21  # GIT_DIFF_FORCE_BINARY, which isn't exposed by pygit2
   112 _DIFF_FLAGS = 1 << 21  # GIT_DIFF_FORCE_BINARY, which isn't exposed by pygit2
   109 
   113 
   110 
   114 
   111 def _find_nearest_ancestor_introducing_node(
   115 def _find_nearest_ancestor_introducing_node(