Mercurial > hg
comparison hgext/rebase.py @ 44214:3d2de64c49d2
rebase: define base in only place in defineparents()
Just a little refactoring to prepare for the next patch.
Differential Revision: https://phab.mercurial-scm.org/D7906
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 15 Jan 2020 22:24:16 -0800 |
parents | d4c1501225c4 |
children | 830eae18b2f3 |
comparison
equal
deleted
inserted
replaced
44213:5323cdb8ae33 | 44214:3d2de64c49d2 |
---|---|
1737 # impossible. With multi-dest, the initial check does not cover complex | 1737 # impossible. With multi-dest, the initial check does not cover complex |
1738 # cases since we don't have abstractions to dry-run rebase cheaply. | 1738 # cases since we don't have abstractions to dry-run rebase cheaply. |
1739 if any(p != nullrev and isancestor(rev, p) for p in newps): | 1739 if any(p != nullrev and isancestor(rev, p) for p in newps): |
1740 raise error.Abort(_(b'source is ancestor of destination')) | 1740 raise error.Abort(_(b'source is ancestor of destination')) |
1741 | 1741 |
1742 # "rebasenode" updates to new p1, use the corresponding merge base. | |
1743 if bases[0] != nullrev: | |
1744 base = bases[0] | |
1745 else: | |
1746 base = None | |
1747 | |
1748 # Check if the merge will contain unwanted changes. That may happen if | 1742 # Check if the merge will contain unwanted changes. That may happen if |
1749 # there are multiple special (non-changelog ancestor) merge bases, which | 1743 # there are multiple special (non-changelog ancestor) merge bases, which |
1750 # cannot be handled well by the 3-way merge algorithm. For example: | 1744 # cannot be handled well by the 3-way merge algorithm. For example: |
1751 # | 1745 # |
1752 # F | 1746 # F |
1807 raise error.Abort( | 1801 raise error.Abort( |
1808 _(b'rebasing %d:%s will include unwanted changes from %s') | 1802 _(b'rebasing %d:%s will include unwanted changes from %s') |
1809 % (rev, repo[rev], unwanteddesc) | 1803 % (rev, repo[rev], unwanteddesc) |
1810 ) | 1804 ) |
1811 | 1805 |
1812 base = bases[i] | |
1813 | |
1814 # newps[0] should match merge base if possible. Currently, if newps[i] | 1806 # newps[0] should match merge base if possible. Currently, if newps[i] |
1815 # is nullrev, the only case is newps[i] and newps[j] (j < i), one is | 1807 # is nullrev, the only case is newps[i] and newps[j] (j < i), one is |
1816 # the other's ancestor. In that case, it's fine to not swap newps here. | 1808 # the other's ancestor. In that case, it's fine to not swap newps here. |
1817 # (see CASE-1 and CASE-2 above) | 1809 # (see CASE-1 and CASE-2 above) |
1818 if i != 0 and newps[i] != nullrev: | 1810 if i != 0: |
1819 newps[0], newps[i] = newps[i], newps[0] | 1811 if newps[i] != nullrev: |
1812 newps[0], newps[i] = newps[i], newps[0] | |
1813 bases[0], bases[i] = bases[i], bases[0] | |
1814 | |
1815 # "rebasenode" updates to new p1, use the corresponding merge base. | |
1816 if bases[0] != nullrev: | |
1817 base = bases[0] | |
1818 else: | |
1819 base = None | |
1820 | 1820 |
1821 repo.ui.debug(b" future parents are %d and %d\n" % tuple(newps)) | 1821 repo.ui.debug(b" future parents are %d and %d\n" % tuple(newps)) |
1822 | 1822 |
1823 return newps[0], newps[1], base | 1823 return newps[0], newps[1], base |
1824 | 1824 |