D5969: uncommit: inform user if the commit is empty after uncommit

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Feb 20 15:16:36 EST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG949c4a3b7373: uncommit: inform user if the commit is empty after uncommit (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5969?vs=14108&id=14147

REVISION DETAIL
  https://phab.mercurial-scm.org/D5969

AFFECTED FILES
  hgext/uncommit.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -159,6 +159,7 @@
   abort: uncommitted changes
   [255]
   $ hg uncommit files
+  note: keeping empty commit
   $ cat files
   abcde
   foo
@@ -282,6 +283,7 @@
 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'
@@ -318,6 +320,7 @@
   > EOS
   $ hg up Q -q
   $ hg uncommit --keep
+  note: keeping empty commit
   $ hg log -G -T '{desc} FILES: {files}'
   @  Q FILES:
   |
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -69,11 +69,11 @@
     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()
@@ -88,6 +88,9 @@
                                   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(),



To: martinvonz, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel


More information about the Mercurial-devel mailing list