Patchwork [1,of,2,V2] commit: return 1 for interactive commit with no changes (issue5397)

login
register
mail settings
Submitter Philippe Pepiot
Date Oct. 14, 2016, 7:55 a.m.
Message ID <9eb1db967e9db678e067.1476431757@sh71.tls.logilab.fr>
Download mbox | patch
Permalink /patch/17083/
State Accepted
Headers show

Comments

Philippe Pepiot - Oct. 14, 2016, 7:55 a.m.
# HG changeset patch
# User Philippe Pepiot <philippe.pepiot@logilab.fr>
# Date 1476431558 -7200
#      Fri Oct 14 09:52:38 2016 +0200
# Node ID 9eb1db967e9db678e06723b26966b06f060ef36e
# Parent  b85fa6bf298be07804a74d8fdec0d19fdbc6d740
commit: return 1 for interactive commit with no changes (issue5397)

For consistency with non interactive commit

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1648,9 +1648,11 @@  def commit(ui, repo, *pats, **opts):
 def _docommit(ui, repo, *pats, **opts):
     if opts.get('interactive'):
         opts.pop('interactive')
-        cmdutil.dorecord(ui, repo, commit, None, False,
-                        cmdutil.recordfilter, *pats, **opts)
-        return
+        ret = cmdutil.dorecord(ui, repo, commit, None, False,
+                               cmdutil.recordfilter, *pats, **opts)
+        # ret can be 0 (no changes to record) or the value returned by
+        # commit(), 1 if nothing changed or None on success.
+        return 1 if ret == 0 else ret
 
     if opts.get('subrepos'):
         if opts.get('amend'):
diff --git a/tests/test-commit-interactive-curses.t b/tests/test-commit-interactive-curses.t
--- a/tests/test-commit-interactive-curses.t
+++ b/tests/test-commit-interactive-curses.t
@@ -37,6 +37,7 @@  Committing some changes but stopping on 
   > EOF
   $ hg commit -i  -m "a" -d "0 0"
   no changes to record
+  [1]
   $ hg tip
   changeset:   -1:000000000000
   tag:         tip
@@ -60,6 +61,7 @@  Committing some changes
 Check that commit -i works with no changes
   $ hg commit -i
   no changes to record
+  [1]
 
 Committing only one file
 
diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t
--- a/tests/test-commit-interactive.t
+++ b/tests/test-commit-interactive.t
@@ -29,6 +29,7 @@  Select no files
   examine changes to 'empty-rw'? [Ynesfdaq?] n
   
   no changes to record
+  [1]
 
   $ hg tip -p
   changeset:   -1:000000000000
@@ -1376,6 +1377,7 @@  Removing changes from patch
   record this change to 'editedfile'? [Ynesfdaq?] e
   
   no changes to record
+  [1]
   $ cat editedfile
   This change will not be committed
   This is the second line
@@ -1487,6 +1489,7 @@  session
   record this change to 'editedfile'? [Ynesfdaq?] n
   
   no changes to record
+  [1]
 
 
 random text in random positions is still an error