# HG changeset patch # User Martin von Zweigbergk # Date 2019-02-15 18:49:12 # Node ID 83d294c71f1ed95a267d7acdb85b0e3f61e9a554 # Parent 0ae89ab3f0251949972713de32abce00ad6e5741 uncommit: inform user if the commit is empty after uncommit Differential Revision: https://phab.mercurial-scm.org/D5969 diff --git a/hgext/uncommit.py b/hgext/uncommit.py --- a/hgext/uncommit.py +++ b/hgext/uncommit.py @@ -64,11 +64,11 @@ def _commitfiltered(repo, ctx, match, ke if not exclude: return None - files = (initialfiles - exclude) # return the p1 so that we don't create an obsmarker later if not keepcommit: return ctx.p1().node() + files = (initialfiles - exclude) # Filter copies copied = copiesmod.pathcopies(base, ctx) copied = dict((dst, src) for dst, src in copied.iteritems() @@ -83,6 +83,9 @@ def _commitfiltered(repo, ctx, match, ke copied=copied.get(path)) return mctx + if not files: + repo.ui.status(_("note: keeping empty commit\n")) + new = context.memctx(repo, parents=[base.node(), node.nullid], text=ctx.description(), diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t --- a/tests/test-uncommit.t +++ b/tests/test-uncommit.t @@ -158,6 +158,7 @@ Uncommit with dirty state abort: uncommitted changes [255] $ hg uncommit files + note: keeping empty commit $ cat files abcde foo @@ -281,6 +282,7 @@ Uncommit with draft parent Phase is preserved $ hg uncommit --keep --config phases.new-commit=secret + note: keeping empty commit $ hg phase -r . 15: draft $ hg commit --amend -m 'update ab again' @@ -317,6 +319,7 @@ Uncommit leaving an empty changeset > EOS $ hg up Q -q $ hg uncommit --keep + note: keeping empty commit $ hg log -G -T '{desc} FILES: {files}' @ Q FILES: |