[PATCH] commit: note when files are missing

Martin Geisler mg at aragost.com
Wed Apr 6 09:21:25 CDT 2011


# HG changeset patch
# User Martin Geisler <mg at aragost.com>
# Date 1302099672 -7200
# Node ID a7cd0eee396bbc49eed25e83cf2e1add2a963c73
# Parent  77b09a7fc8fc7b37cc5432bd3cdf134ffc3ea708
commit: note when files are missing

Before, you could experience the following strange interaction:

  $ hg commit
  nothing changed
  $ hg merge
  abort: outstanding uncommitted changes

which confused at least one user in #mercurial.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -894,7 +894,12 @@
 
     node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
     if not node:
-        ui.status(_("nothing changed\n"))
+        stat = repo.status(match=cmdutil.match(repo, pats, opts))
+        if stat[3]:
+            ui.status(_("nothing changed (%d missing files, see 'hg status')\n")
+                      % len(stat[3]))
+        else:
+            ui.status(_("nothing changed\n"))
         return 1
 
     ctx = repo[node]
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -32,7 +32,7 @@
   $ hg add bar
   $ rm bar
   $ hg commit -m commit-8
-  nothing changed
+  nothing changed (1 missing files, see 'hg status')
   [1]
   $ hg commit -m commit-8-2 bar
   abort: bar: file not found!


More information about the Mercurial-devel mailing list