[Request] [+- ] D8742: merge: return 'commitinfo' from manifestmerge() and calculateupdates() (API)
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Tue Jul 14 12:32:45 UTC 2020
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
commitinfo will be used to pass information which is required on commit phase
from the merge phase.
One common example is, merge chooses filenode from second parent and we need to
tell commit to choose that. Right now this one and related cases are not very
neatly implement and there is no clear line on how to pass on such information.
Upcoming patches will try to work on in this area and make things easier.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8742
AFFECTED FILES
hgext/convert/hg.py
hgext/largefiles/overrides.py
mercurial/merge.py
CHANGE DETAILS
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -565,6 +565,8 @@
diverge: mapping of source name -> list of dest name for divergent renames
renamedelete: mapping of source name -> list of destinations for files
deleted on one side and renamed on other.
+ commitinfo: dict containing data which should be used on commit
+ contains a filename -> info mapping
"""
if matcher is not None and matcher.always():
matcher = None
@@ -578,6 +580,10 @@
branch_copies1 = copies.branch_copies()
branch_copies2 = copies.branch_copies()
diverge = {}
+ # information from merge which is needed at commit time
+ # for example choosing filelog of which parent to commit
+ # TODO: use specific constants in future for this mapping
+ commitinfo = {}
if followcopies:
branch_copies1, branch_copies2, diverge = copies.mergecopies(
repo, wctx, p2, pa
@@ -671,6 +677,8 @@
(fl2, False),
b'remote is newer',
)
+ if branchmerge:
+ commitinfo[f] = b'other'
elif nol and n2 == a: # remote only changed 'x'
actions[f] = (
mergestatemod.ACTION_EXEC,
@@ -685,6 +693,8 @@
(fl1, False),
b'remote is newer',
)
+ if branchmerge:
+ commitinfo[f] = b'other'
else: # both changed something
actions[f] = (
mergestatemod.ACTION_MERGE,
@@ -846,7 +856,7 @@
renamedelete = branch_copies1.renamedelete
renamedelete.update(branch_copies2.renamedelete)
- return actions, diverge, renamedelete
+ return actions, diverge, renamedelete, commitinfo
def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
@@ -892,13 +902,13 @@
Also filters out actions which are unrequired if repository is sparse.
- Returns same 3 element tuple as manifestmerge().
+ Returns same 4 element tuple as manifestmerge().
"""
# Avoid cycle.
from . import sparse
if len(ancestors) == 1: # default
- actions, diverge, renamedelete = manifestmerge(
+ actions, diverge, renamedelete, commitinfo = manifestmerge(
repo,
wctx,
mctx,
@@ -928,7 +938,7 @@
diverge, renamedelete = None, None
for ancestor in ancestors:
repo.ui.note(_(b'\ncalculating bids for ancestor %s\n') % ancestor)
- actions, diverge1, renamedelete1 = manifestmerge(
+ actions, diverge1, renamedelete1, commitinfo = manifestmerge(
repo,
wctx,
mctx,
@@ -1011,7 +1021,7 @@
)
_resolvetrivial(repo, wctx, mctx, ancestors[0], actions)
- return prunedactions, diverge, renamedelete
+ return prunedactions, diverge, renamedelete, commitinfo
def _getcwd():
@@ -1735,7 +1745,7 @@
followcopies = False
### calculate phase
- actionbyfile, diverge, renamedelete = calculateupdates(
+ actionbyfile, diverge, renamedelete, commitinfo = calculateupdates(
repo,
wc,
p2,
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -543,12 +543,12 @@
origfn, repo, p1, p2, pas, branchmerge, force, acceptremote, *args, **kwargs
):
overwrite = force and not branchmerge
- actions, diverge, renamedelete = origfn(
+ actions, diverge, renamedelete, commitinfo = origfn(
repo, p1, p2, pas, branchmerge, force, acceptremote, *args, **kwargs
)
if overwrite:
- return actions, diverge, renamedelete
+ return actions, diverge, renamedelete, commitinfo
# Convert to dictionary with filename as key and action as value.
lfiles = set()
@@ -620,7 +620,7 @@
actions[lfile] = (b'g', largs, b'replaces standin')
actions[standin] = (b'r', None, b'replaced by non-standin')
- return actions, diverge, renamedelete
+ return actions, diverge, renamedelete, commitinfo
@eh.wrapfunction(mergestatemod, b'recordupdates')
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -217,7 +217,8 @@
"""
anc = [p1ctx.ancestor(p2ctx)]
# Calculate what files are coming from p2
- actions, diverge, rename = mergemod.calculateupdates(
+ # TODO: this might be achieved using commitinfo
+ actions, diverge, rename, commitinfo = mergemod.calculateupdates(
self.repo,
p1ctx,
p2ctx,
To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200714/46e228a1/attachment-0001.html>
More information about the Mercurial-patches
mailing list