Patchwork [3,of,3] crecord: check for untracked arguments

login
register
mail settings
Submitter timeless@mozdev.org
Date April 6, 2016, 6:24 p.m.
Message ID <1c96ffe42ca6a2303a97.1459967073@waste.org>
Download mbox | patch
Permalink /patch/14397/
State Accepted
Headers show

Comments

timeless@mozdev.org - April 6, 2016, 6:24 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1459966776 0
#      Wed Apr 06 18:19:36 2016 +0000
# Node ID 1c96ffe42ca6a2303a97df226d682db6a9e2c199
# Parent  c32a62f336f89877deb1753ac1c1eb104b656839
crecord: check for untracked arguments

hg commit tracked untracked -- fails complaining about untracked

prior to this commit,
hg commit -i tracked untracked -- did not fail

This is corrected by calling the refactored localrepo.checkcommitpatterns
Augie Fackler - April 7, 2016, 1:09 a.m.
On Wed, Apr 06, 2016 at 01:24:33PM -0500, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1459966776 0
> #      Wed Apr 06 18:19:36 2016 +0000
> # Node ID 1c96ffe42ca6a2303a97df226d682db6a9e2c199
> # Parent  c32a62f336f89877deb1753ac1c1eb104b656839
> crecord: check for untracked arguments

queued, thanks


>
> hg commit tracked untracked -- fails complaining about untracked
>
> prior to this commit,
> hg commit -i tracked untracked -- did not fail
>
> This is corrected by calling the refactored localrepo.checkcommitpatterns
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -135,12 +135,24 @@
>          """
>
>          checkunfinished(repo, commit=True)
> -        merge = len(repo[None].parents()) > 1
> +        wctx = repo[None]
> +        merge = len(wctx.parents()) > 1
>          if merge:
>              raise error.Abort(_('cannot partially commit a merge '
>                                 '(use "hg commit" instead)'))
>
> +        def fail(f, msg):
> +            raise error.Abort('%s: %s' % (f, msg))
> +
> +        force = opts.get('force')
> +        if not force:
> +            vdirs = []
> +            match.explicitdir = vdirs.append
> +            match.bad = fail
> +
>          status = repo.status(match=match)
> +        if not force:
> +            repo.checkcommitargs(wctx, vdirs, match, status, fail)
>          diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True)
>          diffopts.nodates = True
>          diffopts.git = True
> 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
> @@ -59,6 +59,14 @@
>
>
>
> +Abort for untracked
> +
> +  $ touch untracked
> +  $ hg commit -i -m should-fail empty-rw untracked
> +  abort: untracked: file not tracked!
> +  [255]
> +  $ rm untracked
> +
>  Record empty file
>
>    $ hg commit -i -d '0 0' -m empty empty-rw<<EOF
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -135,12 +135,24 @@ 
         """
 
         checkunfinished(repo, commit=True)
-        merge = len(repo[None].parents()) > 1
+        wctx = repo[None]
+        merge = len(wctx.parents()) > 1
         if merge:
             raise error.Abort(_('cannot partially commit a merge '
                                '(use "hg commit" instead)'))
 
+        def fail(f, msg):
+            raise error.Abort('%s: %s' % (f, msg))
+
+        force = opts.get('force')
+        if not force:
+            vdirs = []
+            match.explicitdir = vdirs.append
+            match.bad = fail
+
         status = repo.status(match=match)
+        if not force:
+            repo.checkcommitargs(wctx, vdirs, match, status, fail)
         diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True)
         diffopts.nodates = True
         diffopts.git = True
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
@@ -59,6 +59,14 @@ 
   
   
 
+Abort for untracked
+
+  $ touch untracked
+  $ hg commit -i -m should-fail empty-rw untracked
+  abort: untracked: file not tracked!
+  [255]
+  $ rm untracked
+
 Record empty file
 
   $ hg commit -i -d '0 0' -m empty empty-rw<<EOF