Patchwork [5,of,9,V2] commit: abort if --addremove is specified, but fails

login
register
mail settings
Submitter Matt Harbison
Date Nov. 30, 2014, 5:52 a.m.
Message ID <31e3071ecdb395687559.1417326753@Envy>
Download mbox | patch
Permalink /patch/6900/
State Superseded
Commit 72c23fa4f52f04595f3958f7401b7ed290ad0b08
Headers show

Comments

Matt Harbison - Nov. 30, 2014, 5:52 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1417032982 18000
#      Wed Nov 26 15:16:22 2014 -0500
# Node ID 31e3071ecdb39568755995b21e4961a7e77cee49
# Parent  9559f266ac03e53d20b2a2035bf5e417f37b79d3
commit: abort if --addremove is specified, but fails

This will be required when subrepo support is added, in order to ensure
consistent commits when a subrepo flavor doesn't support addremove.
Martin von Zweigbergk - Dec. 2, 2014, 11:28 p.m.
On Sat Nov 29 2014 at 9:53:38 PM Matt Harbison <matt_harbison@yahoo.com>
wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1417032982 18000
> #      Wed Nov 26 15:16:22 2014 -0500
> # Node ID 31e3071ecdb39568755995b21e4961a7e77cee49
> # Parent  9559f266ac03e53d20b2a2035bf5e417f37b79d3
> commit: abort if --addremove is specified, but fails
>
> This will be required when subrepo support is added, in order to ensure
> consistent commits when a subrepo flavor doesn't support addremove.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2200,7 +2200,8 @@
>      # extract addremove carefully -- this function can be called from a
> command
>      # that doesn't support addremove
>      if opts.get('addremove'):
> -        scmutil.addremove(repo, matcher, opts)
> +        if scmutil.addremove(repo, matcher, opts) != 0:
> +            raise util.Abort(_("addremove failed"))


Do you think something like "failed to mark new/missing files as
added/removed" makes more sense to the user? (Taken from 'hg commit
--help'.)
Matt Harbison - Dec. 3, 2014, 3:11 a.m.
Martin von Zweigbergk wrote:
>
>
> On Sat Nov 29 2014 at 9:53:38 PM Matt Harbison <matt_harbison@yahoo.com
> <mailto:matt_harbison@yahoo.com>> wrote:
>
>     # HG changeset patch
>     # User Matt Harbison <matt_harbison@yahoo.com>
>     # Date 1417032982 18000
>     #      Wed Nov 26 15:16:22 2014 -0500
>     # Node ID 31e3071ecdb39568755995b21e4961__a7e77cee49
>     # Parent  9559f266ac03e53d20b2a2035bf5e4__17f37b79d3
>     commit: abort if --addremove is specified, but fails
>
>     This will be required when subrepo support is added, in order to ensure
>     consistent commits when a subrepo flavor doesn't support addremove.
>
>     diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>     --- a/mercurial/cmdutil.py
>     +++ b/mercurial/cmdutil.py
>     @@ -2200,7 +2200,8 @@
>           # extract addremove carefully -- this function can be called
>     from a command
>           # that doesn't support addremove
>           if opts.get('addremove'):
>     -        scmutil.addremove(repo, matcher, opts)
>     +        if scmutil.addremove(repo, matcher, opts) != 0:
>     +            raise util.Abort(_("addremove failed"))
>
>
> Do you think something like "failed to mark new/missing files as
> added/removed" makes more sense to the user? (Taken from 'hg commit
> --help'.)

I like it much better than what I had.  I'll steal it unless someone 
else chimes in with something better or shorter.

--Matt

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2200,7 +2200,8 @@ 
     # extract addremove carefully -- this function can be called from a command
     # that doesn't support addremove
     if opts.get('addremove'):
-        scmutil.addremove(repo, matcher, opts)
+        if scmutil.addremove(repo, matcher, opts) != 0:
+            raise util.Abort(_("addremove failed"))
 
     return commitfunc(ui, repo, message, matcher, opts)
 
diff --git a/tests/test-addremove.t b/tests/test-addremove.t
--- a/tests/test-addremove.t
+++ b/tests/test-addremove.t
@@ -64,4 +64,19 @@ 
   $ hg addremove -s 50
   adding b
   adding c
+
+  $ rm c
+#if windows
+  $ hg ci -A -m "c" nonexistant
+  nonexistant: The system cannot find the file specified
+  abort: addremove failed
+  [255]
+#else
+  $ hg ci -A -m "c" nonexistant
+  nonexistant: No such file or directory
+  abort: addremove failed
+  [255]
+#endif
+  $ hg st
+  ! c
   $ cd ..