comparison mercurial/merge.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 d4ba4d51f85f
children 9e6e12e1a87e
comparison
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
11 import errno 11 import errno
12 import stat 12 import stat
13 import struct 13 import struct
14 14
15 from .i18n import _ 15 from .i18n import _
16 from .node import ( 16 from .node import nullrev
17 addednodeid,
18 modifiednodeid,
19 nullid,
20 nullrev,
21 )
22 from .thirdparty import attr 17 from .thirdparty import attr
23 from .utils import stringutil 18 from .utils import stringutil
24 from . import ( 19 from . import (
25 copies, 20 copies,
26 encoding, 21 encoding,
777 if b'.hgsubstate' in m1 and wctx.rev() is None: 772 if b'.hgsubstate' in m1 and wctx.rev() is None:
778 # Check whether sub state is modified, and overwrite the manifest 773 # Check whether sub state is modified, and overwrite the manifest
779 # to flag the change. If wctx is a committed revision, we shouldn't 774 # to flag the change. If wctx is a committed revision, we shouldn't
780 # care for the dirty state of the working directory. 775 # care for the dirty state of the working directory.
781 if any(wctx.sub(s).dirty() for s in wctx.substate): 776 if any(wctx.sub(s).dirty() for s in wctx.substate):
782 m1[b'.hgsubstate'] = modifiednodeid 777 m1[b'.hgsubstate'] = repo.nodeconstants.modifiednodeid
783 778
784 # Don't use m2-vs-ma optimization if: 779 # Don't use m2-vs-ma optimization if:
785 # - ma is the same as m1 or m2, which we're just going to diff again later 780 # - ma is the same as m1 or m2, which we're just going to diff again later
786 # - The caller specifically asks for a full diff, which is useful during bid 781 # - The caller specifically asks for a full diff, which is useful during bid
787 # merge. 782 # merge.
942 ) 937 )
943 if branchmerge: 938 if branchmerge:
944 mresult.addcommitinfo( 939 mresult.addcommitinfo(
945 f, b'merge-removal-candidate', b'yes' 940 f, b'merge-removal-candidate', b'yes'
946 ) 941 )
947 elif n1 == addednodeid: 942 elif n1 == repo.nodeconstants.addednodeid:
948 # This file was locally added. We should forget it instead of 943 # This file was locally added. We should forget it instead of
949 # deleting it. 944 # deleting it.
950 mresult.addfile( 945 mresult.addfile(
951 f, 946 f,
952 mergestatemod.ACTION_FORGET, 947 mergestatemod.ACTION_FORGET,
1783 fsmonitorenabled = False 1778 fsmonitorenabled = False
1784 1779
1785 if ( 1780 if (
1786 fsmonitorwarning 1781 fsmonitorwarning
1787 and not fsmonitorenabled 1782 and not fsmonitorenabled
1788 and p1node == nullid 1783 and p1node == repo.nullid
1789 and num_gets >= fsmonitorthreshold 1784 and num_gets >= fsmonitorthreshold
1790 and pycompat.sysplatform.startswith((b'linux', b'darwin')) 1785 and pycompat.sysplatform.startswith((b'linux', b'darwin'))
1791 ): 1786 ):
1792 repo.ui.warn( 1787 repo.ui.warn(
1793 _( 1788 _(
1911 if ancestor is not None: 1906 if ancestor is not None:
1912 pas = [repo[ancestor]] 1907 pas = [repo[ancestor]]
1913 else: 1908 else:
1914 if repo.ui.configlist(b'merge', b'preferancestor') == [b'*']: 1909 if repo.ui.configlist(b'merge', b'preferancestor') == [b'*']:
1915 cahs = repo.changelog.commonancestorsheads(p1.node(), p2.node()) 1910 cahs = repo.changelog.commonancestorsheads(p1.node(), p2.node())
1916 pas = [repo[anc] for anc in (sorted(cahs) or [nullid])] 1911 pas = [repo[anc] for anc in (sorted(cahs) or [repo.nullid])]
1917 else: 1912 else:
1918 pas = [p1.ancestor(p2, warn=branchmerge)] 1913 pas = [p1.ancestor(p2, warn=branchmerge)]
1919 1914
1920 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), bytes(p1), bytes(p2) 1915 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), bytes(p1), bytes(p2)
1921 1916
2110 for nf in sorted(fl): 2105 for nf in sorted(fl):
2111 repo.ui.warn(b" %s\n" % nf) 2106 repo.ui.warn(b" %s\n" % nf)
2112 2107
2113 ### apply phase 2108 ### apply phase
2114 if not branchmerge: # just jump to the new rev 2109 if not branchmerge: # just jump to the new rev
2115 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, b'' 2110 fp1, fp2, xp1, xp2 = fp2, repo.nullid, xp2, b''
2116 # If we're doing a partial update, we need to skip updating 2111 # If we're doing a partial update, we need to skip updating
2117 # the dirstate. 2112 # the dirstate.
2118 always = matcher is None or matcher.always() 2113 always = matcher is None or matcher.always()
2119 updatedirstate = updatedirstate and always and not wc.isinmemory() 2114 updatedirstate = updatedirstate and always and not wc.isinmemory()
2120 if updatedirstate: 2115 if updatedirstate:
2279 ) 2274 )
2280 2275
2281 if keepconflictparent and stats.unresolvedcount: 2276 if keepconflictparent and stats.unresolvedcount:
2282 pother = ctx.node() 2277 pother = ctx.node()
2283 else: 2278 else:
2284 pother = nullid 2279 pother = repo.nullid
2285 parents = ctx.parents() 2280 parents = ctx.parents()
2286 if keepparent and len(parents) == 2 and base in parents: 2281 if keepparent and len(parents) == 2 and base in parents:
2287 parents.remove(base) 2282 parents.remove(base)
2288 pother = parents[0].node() 2283 pother = parents[0].node()
2289 # Never set both parents equal to each other 2284 # Never set both parents equal to each other
2290 if pother == pctx.node(): 2285 if pother == pctx.node():
2291 pother = nullid 2286 pother = repo.nullid
2292 2287
2293 if wctx.isinmemory(): 2288 if wctx.isinmemory():
2294 wctx.setparents(pctx.node(), pother) 2289 wctx.setparents(pctx.node(), pother)
2295 # fix up dirstate for copies and renames 2290 # fix up dirstate for copies and renames
2296 copies.graftcopies(wctx, ctx, base) 2291 copies.graftcopies(wctx, ctx, base)