# HG changeset patch # User Martin von Zweigbergk # Date 2022-02-08 06:54:38 # Node ID 93d6f0e7ba2f5fdb2f60e96a09e038a393fb50d7 # Parent d169e651066bc5b9ed81f78d5e675f66564c1d6d filemerge: move check for identical sides out of filemerge() `filemerge.filemerge()` returns `None` if no merge was necessary because the two sides were identical. I don't think it should be that function's responsibility to handle that case; we should ideally not even call `filemerge.filemerge()` if the two inputs identical. This patch therefore moves the check out to the caller (`mergestate.py`). The largefiles test changed because we now notice that the two sides made the same change, so we don't consider it a merge. Also note that the new message better matches the line above it in the test output. Differential Revision: https://phab.mercurial-scm.org/D12154 diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -989,10 +989,6 @@ def filemerge(repo, wctx, mynode, orig, Returns whether the merge is complete, the return value of the merge, and a boolean indicating whether the file was deleted from disk.""" - - if not fco.cmp(fcd): # files identical? - return None, False - ui = repo.ui fd = fcd.path() uipathfn = scmutil.getuipathfn(repo) diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py --- a/mercurial/mergestate.py +++ b/mercurial/mergestate.py @@ -421,6 +421,14 @@ class _mergestate_base(object): self._restore_backup(wctx[dfile], localkey, flags) else: wctx[dfile].remove(ignoremissing=True) + + if not fco.cmp(fcd): # files identical? + # If return value of merge is None, then there are no real conflict + del self._state[dfile] + self._results[dfile] = None, None + self._dirty = True + return None + merge_ret, deleted = filemerge.filemerge( self._repo, wctx, @@ -431,12 +439,6 @@ class _mergestate_base(object): fca, labels=self._labels, ) - if merge_ret is None: - # If return value of merge is None, then there are no real conflict - del self._state[dfile] - self._results[dfile] = None, None - self._dirty = True - return None if not merge_ret: self.mark(dfile, MERGE_RECORD_RESOLVED) diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t --- a/tests/test-largefiles-misc.t +++ b/tests/test-largefiles-misc.t @@ -962,7 +962,7 @@ Merge conflicts: what do you want to do? l getting changed largefiles 1 largefiles updated, 0 removed - 0 files updated, 4 files merged, 0 files removed, 0 files unresolved + 1 files updated, 3 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ cat f-different 1