[PATCH STABLE] commit: allow --interactive to work again when naming a directory (issue6131)

Matt Harbison mharbison72 at gmail.com
Mon May 6 23:00:05 EDT 2019


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1557195034 14400
#      Mon May 06 22:10:34 2019 -0400
# Branch stable
# Node ID 5a728ef1fc4688f89b80dbe91a302bdcaa175a70
# Parent  29798c9ba5c96d9a5b711614e6979beea927009a
commit: allow --interactive to work again when naming a directory (issue6131)

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -272,6 +272,15 @@ def dorecord(ui, repo, commitfunc, cmdsu
             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)
 
         overrides = {(b'ui', b'commitsubrepos'): True}
@@ -294,15 +303,6 @@ def dorecord(ui, repo, commitfunc, cmdsu
                     dirtyreason = wctx.sub(s).dirtyreason(True)
                     raise error.Abort(dirtyreason)
 
-        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
-
         if not force:
             repo.checkcommitpatterns(wctx, vdirs, match, status, fail)
         diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=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
@@ -775,12 +775,21 @@ Record end
   +10
   +11
   
+Interactive commit can name a directory instead of files (issue6131)
 
   $ mkdir subdir
+  $ echo a > subdir/a
+  $ yes | hg ci -d '16 0' -i subdir -Amsubdir
+  adding subdir/a
+  diff --git a/subdir/a b/subdir/a
+  new file mode 100644
+  examine changes to 'subdir/a'? [Ynesfdaq?] y
+  
+  @@ -0,0 +1,1 @@
+  +a
+  record this change to 'subdir/a'? [Ynesfdaq?] y
+  
   $ cd subdir
-  $ echo a > a
-  $ hg ci -d '16 0' -Amsubdir
-  adding subdir/a
 
   $ echo a >> a
   $ hg commit -i -d '16 0' -m subdir-change a <<EOF


More information about the Mercurial-devel mailing list