diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4866,8 +4866,7 @@ if node: node = scmutil.revsingle(repo, node).node() - - if not node: + else: if ui.configbool(b'commands', b'merge.require-rev'): raise error.Abort( _( @@ -4877,6 +4876,9 @@ ) node = repo[destutil.destmerge(repo)].node() + if node is None: + raise error.Abort(_(b'merging with the working copy has no effect')) + if opts.get(b'preview'): # find nodes that are ancestors of p2 but not of p1 p1 = repo.lookup(b'.') diff --git a/tests/test-merge2.t b/tests/test-merge2.t --- a/tests/test-merge2.t +++ b/tests/test-merge2.t @@ -50,4 +50,8 @@ adding b created new head + $ hg merge 'wdir()' + abort: merging with the working copy has no effect + [255] + $ cd ..