comparison mercurial/merge.py @ 45499:19590b126764

merge: use in-memory mergestate when using in-memory context This is my version of Augie's D8568. It makes it so we don't touch the mergestate on disk when using an in-memory context. The reason that I want this is not the same as the reason that Augie write his patch (though I agree with that reason too). My hope is to make in-memory rebase not fall back to on-disk rebase when there are conflict. I plan to do that by adding a `overlayworkingctx.reflect_in_workingcopy()`. The idea is that that will update the working copy, the dirstate and the mergestate as necessary. Differential Revision: https://phab.mercurial-scm.org/D9040
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 15 Sep 2020 16:10:16 -0700
parents 2c10876bb320
children 32ce4cbaec4b
comparison
equal deleted inserted replaced
45498:cc5f811b1f15 45499:19590b126764
1396 """ 1396 """
1397 1397
1398 _prefetchfiles(repo, mctx, mresult) 1398 _prefetchfiles(repo, mctx, mresult)
1399 1399
1400 updated, merged, removed = 0, 0, 0 1400 updated, merged, removed = 0, 0, 0
1401 ms = mergestatemod.mergestate.clean(repo) 1401 ms = wctx.mergestate(clean=True)
1402 ms.start(wctx.p1().node(), mctx.node(), labels) 1402 ms.start(wctx.p1().node(), mctx.node(), labels)
1403 1403
1404 for f, op in pycompat.iteritems(mresult.commitinfo): 1404 for f, op in pycompat.iteritems(mresult.commitinfo):
1405 # the other side of filenode was choosen while merging, store this in 1405 # the other side of filenode was choosen while merging, store this in
1406 # mergestate so that it can be reused on commit 1406 # mergestate so that it can be reused on commit
1609 # driver has changed, and we want to be able to bypass it when overwrite is 1609 # driver has changed, and we want to be able to bypass it when overwrite is
1610 # True 1610 # True
1611 usemergedriver = not overwrite and mergeactions and ms.mergedriver 1611 usemergedriver = not overwrite and mergeactions and ms.mergedriver
1612 1612
1613 if usemergedriver: 1613 if usemergedriver:
1614 if wctx.isinmemory():
1615 raise error.InMemoryMergeConflictsError(
1616 b"in-memory merge does not support mergedriver"
1617 )
1618 ms.commit() 1614 ms.commit()
1619 proceed = driverpreprocess(repo, ms, wctx, labels=labels) 1615 proceed = driverpreprocess(repo, ms, wctx, labels=labels)
1620 # the driver might leave some files unresolved 1616 # the driver might leave some files unresolved
1621 unresolvedf = set(ms.unresolved()) 1617 unresolvedf = set(ms.unresolved())
1622 if not proceed: 1618 if not proceed:
1893 overwrite = force and not branchmerge 1889 overwrite = force and not branchmerge
1894 ### check phase 1890 ### check phase
1895 if not overwrite: 1891 if not overwrite:
1896 if len(pl) > 1: 1892 if len(pl) > 1:
1897 raise error.Abort(_(b"outstanding uncommitted merge")) 1893 raise error.Abort(_(b"outstanding uncommitted merge"))
1898 ms = mergestatemod.mergestate.read(repo) 1894 ms = wc.mergestate()
1899 if list(ms.unresolved()): 1895 if list(ms.unresolved()):
1900 raise error.Abort( 1896 raise error.Abort(
1901 _(b"outstanding merge conflicts"), 1897 _(b"outstanding merge conflicts"),
1902 hint=_(b"use 'hg resolve' to resolve"), 1898 hint=_(b"use 'hg resolve' to resolve"),
1903 ) 1899 )