hgext/git/index.py
changeset 46113 59fa3890d40a
parent 44951 83e41b73d115
child 47012 d55b71393907
child 47051 de26b9a7ec29
equal deleted inserted replaced
46112:d6afa9c149c3 46113:59fa3890d40a
     3 import collections
     3 import collections
     4 import os
     4 import os
     5 import sqlite3
     5 import sqlite3
     6 
     6 
     7 from mercurial.i18n import _
     7 from mercurial.i18n import _
       
     8 from mercurial.node import (
       
     9     nullhex,
       
    10     nullid,
       
    11 )
     8 
    12 
     9 from mercurial import (
    13 from mercurial import (
    10     encoding,
    14     encoding,
    11     error,
    15     error,
    12     node as nodemod,
       
    13     pycompat,
    16     pycompat,
    14 )
    17 )
    15 
    18 
    16 from . import gitutil
    19 from . import gitutil
    17 
    20 
   276     # This walker is sure to visit all the revisions in history, but
   279     # This walker is sure to visit all the revisions in history, but
   277     # only once.
   280     # only once.
   278     for pos, commit in enumerate(walker):
   281     for pos, commit in enumerate(walker):
   279         if prog is not None:
   282         if prog is not None:
   280             prog.update(pos)
   283             prog.update(pos)
   281         p1 = p2 = nodemod.nullhex
   284         p1 = p2 = nullhex
   282         if len(commit.parents) > 2:
   285         if len(commit.parents) > 2:
   283             raise error.ProgrammingError(
   286             raise error.ProgrammingError(
   284                 (
   287                 (
   285                     b"git support can't handle octopus merges, "
   288                     b"git support can't handle octopus merges, "
   286                     b"found a commit with %d parents :("
   289                     b"found a commit with %d parents :("
   313                 patchgen = commit.tree.diff_to_tree(
   316                 patchgen = commit.tree.diff_to_tree(
   314                     swap=True, flags=_DIFF_FLAGS
   317                     swap=True, flags=_DIFF_FLAGS
   315                 )
   318                 )
   316             new_files = (p.delta.new_file for p in patchgen)
   319             new_files = (p.delta.new_file for p in patchgen)
   317             files = {
   320             files = {
   318                 nf.path: nf.id.hex
   321                 nf.path: nf.id.hex for nf in new_files if nf.id.raw != nullid
   319                 for nf in new_files
       
   320                 if nf.id.raw != nodemod.nullid
       
   321             }
   322             }
   322             for p, n in files.items():
   323             for p, n in files.items():
   323                 # We intentionally set NULLs for any file parentage
   324                 # We intentionally set NULLs for any file parentage
   324                 # information so it'll get demand-computed later. We
   325                 # information so it'll get demand-computed later. We
   325                 # used to do it right here, and it was _very_ slow.
   326                 # used to do it right here, and it was _very_ slow.