Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 45299:0c849f0166c2
merge: introduce hasconflicts() on mergeresult object
This and upcoming patches will improve the mergeresult object making it more
powerful and provide clean APIs for various things. Doing this will clean up the
core merge code which is present in `update()` a bit.
Differential Revision: https://phab.mercurial-scm.org/D8816
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 02 Aug 2020 10:12:21 -0700 |
parents | c515c54f6530 |
children | f4a2b329717b |
comparison
equal
deleted
inserted
replaced
45298:c515c54f6530 | 45299:0c849f0166c2 |
---|---|
578 def commitinfo(self): | 578 def commitinfo(self): |
579 return self._commitinfo | 579 return self._commitinfo |
580 | 580 |
581 def setactions(self, actions): | 581 def setactions(self, actions): |
582 self._actions = actions | 582 self._actions = actions |
583 | |
584 def hasconflicts(self): | |
585 """ tells whether this merge resulted in some actions which can | |
586 result in conflicts or not """ | |
587 for _f, (m, _unused, _unused) in pycompat.iteritems(self._actions): | |
588 if m not in ( | |
589 mergestatemod.ACTION_GET, | |
590 mergestatemod.ACTION_KEEP, | |
591 mergestatemod.ACTION_EXEC, | |
592 mergestatemod.ACTION_REMOVE, | |
593 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE, | |
594 ): | |
595 return True | |
596 | |
597 return False | |
583 | 598 |
584 | 599 |
585 def manifestmerge( | 600 def manifestmerge( |
586 repo, | 601 repo, |
587 wctx, | 602 wctx, |
1807 ) | 1822 ) |
1808 | 1823 |
1809 actionbyfile = mresult.actions | 1824 actionbyfile = mresult.actions |
1810 | 1825 |
1811 if updatecheck == UPDATECHECK_NO_CONFLICT: | 1826 if updatecheck == UPDATECHECK_NO_CONFLICT: |
1812 for f, (m, args, msg) in pycompat.iteritems(actionbyfile): | 1827 if mresult.hasconflicts(): |
1813 if m not in ( | 1828 msg = _(b"conflicting changes") |
1814 mergestatemod.ACTION_GET, | 1829 hint = _(b"commit or update --clean to discard changes") |
1815 mergestatemod.ACTION_KEEP, | 1830 raise error.Abort(msg, hint=hint) |
1816 mergestatemod.ACTION_EXEC, | |
1817 mergestatemod.ACTION_REMOVE, | |
1818 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE, | |
1819 ): | |
1820 msg = _(b"conflicting changes") | |
1821 hint = _(b"commit or update --clean to discard changes") | |
1822 raise error.Abort(msg, hint=hint) | |
1823 | 1831 |
1824 # Prompt and create actions. Most of this is in the resolve phase | 1832 # Prompt and create actions. Most of this is in the resolve phase |
1825 # already, but we can't handle .hgsubstate in filemerge or | 1833 # already, but we can't handle .hgsubstate in filemerge or |
1826 # subrepoutil.submerge yet so we have to keep prompting for it. | 1834 # subrepoutil.submerge yet so we have to keep prompting for it. |
1827 if b'.hgsubstate' in actionbyfile: | 1835 if b'.hgsubstate' in actionbyfile: |