changeset 40951:e993a86cfcb8

absorb: don't prompt to apply changes when there are none to apply Differential Revision: https://phab.mercurial-scm.org/D5428
author Danny Hooper <hooper@google.com>
date Thu, 13 Dec 2018 20:39:25 -0800
parents 52fbf8a9907c
children 811f772b44aa
files hgext/absorb.py tests/test-absorb.t
diffstat 2 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/absorb.py	Fri Dec 14 21:00:33 2018 +0300
+++ b/hgext/absorb.py	Thu Dec 13 20:39:25 2018 -0800
@@ -971,9 +971,10 @@
                      label='absorb.description')
         fm.end()
     if not opts.get('dry_run'):
-        if not opts.get('apply_changes'):
-            if ui.promptchoice("apply changes (yn)? $$ &Yes $$ &No", default=1):
-                raise error.Abort(_('absorb cancelled\n'))
+        if (not opts.get('apply_changes') and
+            state.ctxaffected and
+            ui.promptchoice("apply changes (yn)? $$ &Yes $$ &No", default=1)):
+            raise error.Abort(_('absorb cancelled\n'))
 
         state.apply()
         if state.commit():
--- a/tests/test-absorb.t	Fri Dec 14 21:00:33 2018 +0300
+++ b/tests/test-absorb.t	Thu Dec 13 20:39:25 2018 -0800
@@ -129,6 +129,20 @@
   nothing applied
   [1]
 
+The prompt is not given if there are no changes to be applied, even if there
+are some changes that won't be applied:
+
+  $ hg absorb
+  showing changes for a
+          @@ -0,2 +0,1 @@
+          -2b
+          -4d
+          +1
+  
+  0 changesets affected
+  nothing applied
+  [1]
+
 Insertaions:
 
   $ cat > a << EOF