comparison hgext/git/index.py @ 47012:d55b71393907

node: replace nullid and friends with nodeconstants class The introduction of 256bit hashes require changes to nullid and other constant magic values. Start pushing them down from repository and revlog where sensible. Differential Revision: https://phab.mercurial-scm.org/D9465
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 29 Mar 2021 01:52:06 +0200
parents 59fa3890d40a
children 7431f5ab0d2a
comparison
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
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 ( 8 from mercurial.node import sha1nodeconstants
9 nullhex,
10 nullid,
11 )
12 9
13 from mercurial import ( 10 from mercurial import (
14 encoding, 11 encoding,
15 error, 12 error,
16 pycompat, 13 pycompat,
279 # This walker is sure to visit all the revisions in history, but 276 # This walker is sure to visit all the revisions in history, but
280 # only once. 277 # only once.
281 for pos, commit in enumerate(walker): 278 for pos, commit in enumerate(walker):
282 if prog is not None: 279 if prog is not None:
283 prog.update(pos) 280 prog.update(pos)
284 p1 = p2 = nullhex 281 p1 = p2 = sha1nodeconstants.nullhex
285 if len(commit.parents) > 2: 282 if len(commit.parents) > 2:
286 raise error.ProgrammingError( 283 raise error.ProgrammingError(
287 ( 284 (
288 b"git support can't handle octopus merges, " 285 b"git support can't handle octopus merges, "
289 b"found a commit with %d parents :(" 286 b"found a commit with %d parents :("
316 patchgen = commit.tree.diff_to_tree( 313 patchgen = commit.tree.diff_to_tree(
317 swap=True, flags=_DIFF_FLAGS 314 swap=True, flags=_DIFF_FLAGS
318 ) 315 )
319 new_files = (p.delta.new_file for p in patchgen) 316 new_files = (p.delta.new_file for p in patchgen)
320 files = { 317 files = {
321 nf.path: nf.id.hex for nf in new_files if nf.id.raw != nullid 318 nf.path: nf.id.hex
319 for nf in new_files
320 if nf.id.raw != sha1nodeconstants.nullid
322 } 321 }
323 for p, n in files.items(): 322 for p, n in files.items():
324 # We intentionally set NULLs for any file parentage 323 # We intentionally set NULLs for any file parentage
325 # information so it'll get demand-computed later. We 324 # information so it'll get demand-computed later. We
326 # used to do it right here, and it was _very_ slow. 325 # used to do it right here, and it was _very_ slow.