##// END OF EJS Templates
rebase: always be graft-like, not merge-like, also for merges...
Martin von Zweigbergk -
r44815:77bb38be default
parent child Browse files
Show More
@@ -1678,22 +1678,6 b' def defineparents(repo, rev, destmap, st'
1678 elif p in state and state[p] > 0:
1678 elif p in state and state[p] > 0:
1679 np = state[p]
1679 np = state[p]
1680
1680
1681 # "bases" only record "special" merge bases that cannot be
1682 # calculated from changelog DAG (i.e. isancestor(p, np) is False).
1683 # For example:
1684 #
1685 # B' # rebase -s B -d D, when B was rebased to B'. dest for C
1686 # | C # is B', but merge base for C is B, instead of
1687 # D | # changelog.ancestor(C, B') == A. If changelog DAG and
1688 # | B # "state" edges are merged (so there will be an edge from
1689 # |/ # B to B'), the merge base is still ancestor(C, B') in
1690 # A # the merged graph.
1691 #
1692 # Also see https://bz.mercurial-scm.org/show_bug.cgi?id=1950#c8
1693 # which uses "virtual null merge" to explain this situation.
1694 if isancestor(p, np):
1695 bases[i] = nullrev
1696
1697 # If one parent becomes an ancestor of the other, drop the ancestor
1681 # If one parent becomes an ancestor of the other, drop the ancestor
1698 for j, x in enumerate(newps[:i]):
1682 for j, x in enumerate(newps[:i]):
1699 if x == nullrev:
1683 if x == nullrev:
@@ -1754,10 +1738,10 b' def defineparents(repo, rev, destmap, st'
1754 # But our merge base candidates (D and E in above case) could still be
1738 # But our merge base candidates (D and E in above case) could still be
1755 # better than the default (ancestor(F, Z) == null). Therefore still
1739 # better than the default (ancestor(F, Z) == null). Therefore still
1756 # pick one (so choose p1 above).
1740 # pick one (so choose p1 above).
1757 if sum(1 for b in set(bases) if b != nullrev) > 1:
1741 if sum(1 for b in set(bases) if b != nullrev and b not in newps) > 1:
1758 unwanted = [None, None] # unwanted[i]: unwanted revs if choose bases[i]
1742 unwanted = [None, None] # unwanted[i]: unwanted revs if choose bases[i]
1759 for i, base in enumerate(bases):
1743 for i, base in enumerate(bases):
1760 if base == nullrev:
1744 if base == nullrev or base in newps:
1761 continue
1745 continue
1762 # Revisions in the side (not chosen as merge base) branch that
1746 # Revisions in the side (not chosen as merge base) branch that
1763 # might contain "surprising" contents
1747 # might contain "surprising" contents
@@ -1781,42 +1765,40 b' def defineparents(repo, rev, destmap, st'
1781 )
1765 )
1782 )
1766 )
1783
1767
1784 # Choose a merge base that has a minimal number of unwanted revs.
1768 if any(revs is not None for revs in unwanted):
1785 l, i = min(
1769 # Choose a merge base that has a minimal number of unwanted revs.
1786 (len(revs), i)
1770 l, i = min(
1787 for i, revs in enumerate(unwanted)
1771 (len(revs), i)
1788 if revs is not None
1772 for i, revs in enumerate(unwanted)
1789 )
1773 if revs is not None
1790
1791 # The merge will include unwanted revisions. Abort now. Revisit this if
1792 # we have a more advanced merge algorithm that handles multiple bases.
1793 if l > 0:
1794 unwanteddesc = _(b' or ').join(
1795 (
1796 b', '.join(b'%d:%s' % (r, repo[r]) for r in revs)
1797 for revs in unwanted
1798 if revs is not None
1799 )
1800 )
1801 raise error.Abort(
1802 _(b'rebasing %d:%s will include unwanted changes from %s')
1803 % (rev, repo[rev], unwanteddesc)
1804 )
1774 )
1805
1775
1806 # newps[0] should match merge base if possible. Currently, if newps[i]
1776 # The merge will include unwanted revisions. Abort now. Revisit this if
1807 # is nullrev, the only case is newps[i] and newps[j] (j < i), one is
1777 # we have a more advanced merge algorithm that handles multiple bases.
1808 # the other's ancestor. In that case, it's fine to not swap newps here.
1778 if l > 0:
1809 # (see CASE-1 and CASE-2 above)
1779 unwanteddesc = _(b' or ').join(
1810 if i != 0:
1780 (
1811 if newps[i] != nullrev:
1781 b', '.join(b'%d:%s' % (r, repo[r]) for r in revs)
1812 newps[0], newps[i] = newps[i], newps[0]
1782 for revs in unwanted
1813 bases[0], bases[i] = bases[i], bases[0]
1783 if revs is not None
1784 )
1785 )
1786 raise error.Abort(
1787 _(b'rebasing %d:%s will include unwanted changes from %s')
1788 % (rev, repo[rev], unwanteddesc)
1789 )
1790
1791 # newps[0] should match merge base if possible. Currently, if newps[i]
1792 # is nullrev, the only case is newps[i] and newps[j] (j < i), one is
1793 # the other's ancestor. In that case, it's fine to not swap newps here.
1794 # (see CASE-1 and CASE-2 above)
1795 if i != 0:
1796 if newps[i] != nullrev:
1797 newps[0], newps[i] = newps[i], newps[0]
1798 bases[0], bases[i] = bases[i], bases[0]
1814
1799
1815 # "rebasenode" updates to new p1, use the corresponding merge base.
1800 # "rebasenode" updates to new p1, use the corresponding merge base.
1816 if bases[0] != nullrev:
1801 base = bases[0]
1817 base = bases[0]
1818 else:
1819 base = None
1820
1802
1821 repo.ui.debug(b" future parents are %d and %d\n" % tuple(newps))
1803 repo.ui.debug(b" future parents are %d and %d\n" % tuple(newps))
1822
1804
@@ -256,7 +256,7 b' Different destinations for merge changes'
256 > EOS
256 > EOS
257 rebasing 3:a4256619d830 "B" (B)
257 rebasing 3:a4256619d830 "B" (B)
258 rebasing 6:8e139e245220 "C" (C tip)
258 rebasing 6:8e139e245220 "C" (C tip)
259 o 8: 51e2ce92e06a C
259 o 8: d7d1169e9b1c C
260 |\
260 |\
261 | o 7: 2ed0c8546285 B
261 | o 7: 2ed0c8546285 B
262 | |\
262 | |\
@@ -68,11 +68,6 b' interesting conflict resolutions or addi'
68 that is mixed up with the actual merge stuff and there is in general no way to
68 that is mixed up with the actual merge stuff and there is in general no way to
69 separate them.
69 separate them.
70
70
71 Note: The dev branch contains _no_ changes to f-default. It might be unclear
72 how rebasing of ancestor merges should be handled, but the current behavior
73 with spurious prompts for conflicts in files that didn't change seems very
74 wrong.
75
76 $ hg init ancestor-merge
71 $ hg init ancestor-merge
77 $ cd ancestor-merge
72 $ cd ancestor-merge
78
73
@@ -133,16 +128,11 b' Full rebase all the way back from branch'
133 note: not rebasing 1:1d1a643d390e "dev: create branch", its destination already has all its changes
128 note: not rebasing 1:1d1a643d390e "dev: create branch", its destination already has all its changes
134 rebasing 2:ec2c14fb2984 "dev: f-dev stuff"
129 rebasing 2:ec2c14fb2984 "dev: f-dev stuff"
135 rebasing 4:4b019212aaf6 "dev: merge default"
130 rebasing 4:4b019212aaf6 "dev: merge default"
136 file 'f-default' was deleted in local [dest] but was modified in other [source].
131 note: not rebasing 4:4b019212aaf6 "dev: merge default", its destination already has all its changes
137 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
138 What do you want to do? c
139 rebasing 6:010ced67e558 "dev: merge default"
132 rebasing 6:010ced67e558 "dev: merge default"
133 note: not rebasing 6:010ced67e558 "dev: merge default", its destination already has all its changes
140 saved backup bundle to $TESTTMP/ancestor-merge/.hg/strip-backup/1d1a643d390e-4a6f6d17-rebase.hg
134 saved backup bundle to $TESTTMP/ancestor-merge/.hg/strip-backup/1d1a643d390e-4a6f6d17-rebase.hg
141 $ hg tglog
135 $ hg tglog
142 o 6: de147e4f69cf 'dev: merge default'
143 |
144 o 5: eda7b7f46f5d 'dev: merge default'
145 |
146 o 4: 3e075b1c0a40 'dev: f-dev stuff'
136 o 4: 3e075b1c0a40 'dev: f-dev stuff'
147 |
137 |
148 @ 3: e08089805d82 'default: f-other stuff'
138 @ 3: e08089805d82 'default: f-other stuff'
@@ -163,28 +153,8 b' Grafty cherry picking rebasing:'
163 > EOF
153 > EOF
164 rebasing 2:ec2c14fb2984 "dev: f-dev stuff"
154 rebasing 2:ec2c14fb2984 "dev: f-dev stuff"
165 rebasing 4:4b019212aaf6 "dev: merge default"
155 rebasing 4:4b019212aaf6 "dev: merge default"
166 file 'f-default' was deleted in local [dest] but was modified in other [source].
156 abort: rebasing 4:4b019212aaf6 will include unwanted changes from 1:1d1a643d390e
167 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
157 [255]
168 What do you want to do? c
169 rebasing 6:010ced67e558 "dev: merge default"
170 saved backup bundle to $TESTTMP/ancestor-merge-2/.hg/strip-backup/ec2c14fb2984-827d7a44-rebase.hg
171 $ hg tglog
172 o 7: de147e4f69cf 'dev: merge default'
173 |
174 o 6: eda7b7f46f5d 'dev: merge default'
175 |
176 o 5: 3e075b1c0a40 'dev: f-dev stuff'
177 |
178 o 4: e08089805d82 'default: f-other stuff'
179 |
180 o 3: 462860db70a1 'default: remove f-default'
181 |
182 o 2: f157ecfd2b6b 'default: f-default stuff'
183 |
184 | o 1: 1d1a643d390e 'dev: create branch' dev
185 |/
186 o 0: e90e8eb90b6f 'default: create f-default'
187
188 $ cd ..
158 $ cd ..
189
159
190
160
@@ -284,18 +254,7 b' rebase of merge of ancestors'
284 rebasing 6:4c5f12f25ebe "merge rebase ancestors" (tip)
254 rebasing 6:4c5f12f25ebe "merge rebase ancestors" (tip)
285 resolving manifests
255 resolving manifests
286 removing other
256 removing other
287 note: merging f9daf77ffe76+ and 4c5f12f25ebe using bids from ancestors a60552eb93fb and f59da8fc0fcf
288
289 calculating bids for ancestor a60552eb93fb
290 resolving manifests
257 resolving manifests
291
292 calculating bids for ancestor f59da8fc0fcf
293 resolving manifests
294
295 auction for merging merge bids
296 other: consensus for g
297 end of auction
298
299 getting other
258 getting other
300 committing files:
259 committing files:
301 other
260 other
General Comments 0
You need to be logged in to leave comments. Login now