comparison mercurial/merge.py @ 45557:2c86b9587740

merge: make low-level update() private (API) We have very few callers left that call the low-level `merge.update()` function. I think it's time to make it private. I'll remove the remaining callers in coming patches, except for one call from the `rebase` module. I hope to eventually fix that too, but it's more complex because it requires teaching `merge.graft()` to work with a dirty working copy. Differential Revision: https://phab.mercurial-scm.org/D9065
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 21 Sep 2020 11:12:58 -0700
parents 2b339c6c6e99
children c1b603cdc95a
comparison
equal deleted inserted replaced
45556:03726f5b6092 45557:2c86b9587740
1692 UPDATECHECK_NONE = b'none' 1692 UPDATECHECK_NONE = b'none'
1693 UPDATECHECK_LINEAR = b'linear' 1693 UPDATECHECK_LINEAR = b'linear'
1694 UPDATECHECK_NO_CONFLICT = b'noconflict' 1694 UPDATECHECK_NO_CONFLICT = b'noconflict'
1695 1695
1696 1696
1697 def update( 1697 def _update(
1698 repo, 1698 repo,
1699 node, 1699 node,
1700 branchmerge, 1700 branchmerge,
1701 force, 1701 force,
1702 ancestor=None, 1702 ancestor=None,
2043 """Merge another topological branch into the working copy. 2043 """Merge another topological branch into the working copy.
2044 2044
2045 force = whether the merge was run with 'merge --force' (deprecated) 2045 force = whether the merge was run with 'merge --force' (deprecated)
2046 """ 2046 """
2047 2047
2048 return update( 2048 return _update(
2049 ctx.repo(), 2049 ctx.repo(),
2050 ctx.rev(), 2050 ctx.rev(),
2051 labels=labels, 2051 labels=labels,
2052 branchmerge=True, 2052 branchmerge=True,
2053 force=force, 2053 force=force,
2060 """Do a clean update to the given commit. 2060 """Do a clean update to the given commit.
2061 2061
2062 This involves updating to the commit and discarding any changes in the 2062 This involves updating to the commit and discarding any changes in the
2063 working copy. 2063 working copy.
2064 """ 2064 """
2065 return update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc) 2065 return _update(ctx.repo(), ctx.rev(), branchmerge=False, force=True, wc=wc)
2066 2066
2067 2067
2068 def revert_to(ctx, matcher=None, wc=None): 2068 def revert_to(ctx, matcher=None, wc=None):
2069 """Revert the working copy to the given commit. 2069 """Revert the working copy to the given commit.
2070 2070
2071 The working copy will keep its current parent(s) but its content will 2071 The working copy will keep its current parent(s) but its content will
2072 be the same as in the given commit. 2072 be the same as in the given commit.
2073 """ 2073 """
2074 2074
2075 return update( 2075 return _update(
2076 ctx.repo(), 2076 ctx.repo(),
2077 ctx.rev(), 2077 ctx.rev(),
2078 branchmerge=False, 2078 branchmerge=False,
2079 force=True, 2079 force=True,
2080 updatedirstate=False, 2080 updatedirstate=False,
2121 mergeancestor = ( 2121 mergeancestor = (
2122 repo.changelog.isancestor(pctx.node(), ctx.node()) 2122 repo.changelog.isancestor(pctx.node(), ctx.node())
2123 or pctx.rev() == base.rev() 2123 or pctx.rev() == base.rev()
2124 ) 2124 )
2125 2125
2126 stats = update( 2126 stats = _update(
2127 repo, 2127 repo,
2128 ctx.node(), 2128 ctx.node(),
2129 True, 2129 True,
2130 True, 2130 True,
2131 base.node(), 2131 base.node(),
2164 if ctx.p2() is not None: 2164 if ctx.p2() is not None:
2165 raise error.ProgrammingError( 2165 raise error.ProgrammingError(
2166 b"must specify parent of merge commit to back out" 2166 b"must specify parent of merge commit to back out"
2167 ) 2167 )
2168 parent = ctx.p1() 2168 parent = ctx.p1()
2169 return update( 2169 return _update(
2170 ctx.repo(), 2170 ctx.repo(),
2171 parent, 2171 parent,
2172 branchmerge=True, 2172 branchmerge=True,
2173 force=True, 2173 force=True,
2174 ancestor=ctx.node(), 2174 ancestor=ctx.node(),