Patchwork [2,of,2] commit: add ability to print file status after each successful invocation

login
register
mail settings
Submitter Anton Shestakov
Date May 4, 2019, 4:46 a.m.
Message ID <f95f3e733b24730f8ad5.1556945218@df1>
Download mbox | patch
Permalink /patch/39939/
State Accepted
Headers show

Comments

Anton Shestakov - May 4, 2019, 4:46 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1556863876 -28800
#      Fri May 03 14:11:16 2019 +0800
# Node ID f95f3e733b24730f8ad5874150c2eefb9123a482
# Parent  49d7c0579df397ff05941d09ce97967e6ca9d53e
# EXP-Topic post-commit-status
commit: add ability to print file status after each successful invocation

When commands.commit.post-status is enabled, `hg commit` will effectively run
`hg status -mardu` after committing. It can help catch mistakes like not
committing all needed files or not adding unknown files that should've been
part of the just created commit.
Augie Fackler - May 4, 2019, 2:34 p.m.
> On May 4, 2019, at 00:46, Anton Shestakov <av6@dwimlabs.net> wrote:
> 
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1556863876 -28800
> #      Fri May 03 14:11:16 2019 +0800
> # Node ID f95f3e733b24730f8ad5874150c2eefb9123a482
> # Parent  49d7c0579df397ff05941d09ce97967e6ca9d53e
> # EXP-Topic post-commit-status
> commit: add ability to print file status after each successful invocation

sure, queued, thanks
via Mercurial-devel - May 4, 2019, 4:29 p.m.
I feel like this feature goes against the idea of orthogonal commands and
that it could easily be achieved with a hook. Is it a common enough request
to have it in core? OTOH, it's a very simple feature, so I'm not too
concerned with having it in core.

*From: *Augie Fackler <raf@durin42.com>
*Date: *Sat, May 4, 2019 at 7:40 AM
*To: *Anton Shestakov
*Cc: * <mercurial-devel@mercurial-scm.org>


>
> > On May 4, 2019, at 00:46, Anton Shestakov <av6@dwimlabs.net> wrote:
> >
> > # HG changeset patch
> > # User Anton Shestakov <av6@dwimlabs.net>
> > # Date 1556863876 -28800
> > #      Fri May 03 14:11:16 2019 +0800
> > # Node ID f95f3e733b24730f8ad5874150c2eefb9123a482
> > # Parent  49d7c0579df397ff05941d09ce97967e6ca9d53e
> > # EXP-Topic post-commit-status
> > commit: add ability to print file status after each successful invocation
>
> sure, queued, thanks
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Pierre-Yves David - May 4, 2019, 8:35 p.m.
On 5/4/19 6:29 PM, Martin von Zweigbergk via Mercurial-devel wrote:
> I feel like this feature goes against the idea of orthogonal commands 
> and that it could easily be achieved with a hook. Is it a common enough 
> request to have it in core? OTOH, it's a very simple feature, so I'm not 
> too concerned with having it in core.

It would have to be a shell hooks, since we don't have a stable python 
API hooks. If this is a shell hook it means an extra Mercurila 
invocation and second full status call. These are can be pretty expensive.

> 
> *From: *Augie Fackler <raf@durin42.com <mailto:raf@durin42.com>>
> *Date: *Sat, May 4, 2019 at 7:40 AM
> *To: *Anton Shestakov
> *Cc: * <mercurial-devel@mercurial-scm.org 
> <mailto:mercurial-devel@mercurial-scm.org>>
> 
> 
> 
>      > On May 4, 2019, at 00:46, Anton Shestakov <av6@dwimlabs.net
>     <mailto:av6@dwimlabs.net>> wrote:
>      >
>      > # HG changeset patch
>      > # User Anton Shestakov <av6@dwimlabs.net <mailto:av6@dwimlabs.net>>
>      > # Date 1556863876 -28800
>      > #      Fri May 03 14:11:16 2019 +0800
>      > # Node ID f95f3e733b24730f8ad5874150c2eefb9123a482
>      > # Parent  49d7c0579df397ff05941d09ce97967e6ca9d53e
>      > # EXP-Topic post-commit-status
>      > commit: add ability to print file status after each successful
>     invocation
> 
>     sure, queued, thanks
> 
>     _______________________________________________
>     Mercurial-devel mailing list
>     Mercurial-devel@mercurial-scm.org
>     <mailto:Mercurial-devel@mercurial-scm.org>
>     https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> 
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Augie Fackler - May 4, 2019, 10:05 p.m.
> On May 4, 2019, at 16:35, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:
> 
> 
> 
> On 5/4/19 6:29 PM, Martin von Zweigbergk via Mercurial-devel wrote:
>> I feel like this feature goes against the idea of orthogonal commands and that it could easily be achieved with a hook. Is it a common enough request to have it in core? OTOH, it's a very simple feature, so I'm not too concerned with having it in core.
> 
> It would have to be a shell hooks, since we don't have a stable python API hooks. If this is a shell hook it means an extra Mercurila invocation and second full status call. These are can be pretty expensive.

Yep - that was my reasoning, which maybe I should have mentioned. It seems like a pretty cheap thing to maintain for the amount of win it is.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1735,6 +1735,10 @@  def _docommit(ui, repo, *pats, **opts):
 
     cmdutil.commitstatus(repo, node, branch, bheads, opts)
 
+    if not ui.quiet and ui.configbool('commands', 'commit.post-status'):
+        status(ui, repo, modified=True, added=True, removed=True, deleted=True,
+               unknown=True, subrepos=opts.get('subrepos'))
+
 @command('config|showconfig|debugconfig',
     [('u', 'untrusted', None, _('show untrusted configuration options')),
      ('e', 'edit', None, _('edit user config')),
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -202,6 +202,9 @@  coreconfigitem('color', 'pagermode',
     default=dynamicdefault,
 )
 _registerdiffopts(section='commands', configprefix='commit.interactive.')
+coreconfigitem('commands', 'commit.post-status',
+    default=False,
+)
 coreconfigitem('commands', 'grep.all-files',
     default=False,
 )
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -438,6 +438,10 @@  effect and style see :hg:`help color`.
 ``commands``
 ------------
 
+``commit.post-status``
+    Show status of files in the working directory after successful commit.
+    (default: False)
+
 ``resolve.confirm``
     Confirm before performing action if no filename is passed.
     (default: False)
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -838,3 +838,42 @@  at the end
   second line
 
   $ cd ..
+
+testing commands.commit.post-status config option
+
+  $ hg init ci-post-st
+  $ cd ci-post-st
+  $ echo '[commands]' > .hg/hgrc
+  $ echo 'commit.post-status = 1' >> .hg/hgrc
+
+  $ echo 'ignored-file' > .hgignore
+  $ hg ci -qAm 0
+
+  $ echo 'c' > clean-file
+  $ echo 'a' > added-file
+  $ echo '?' > unknown-file
+  $ echo 'i' > ignored-file
+  $ hg add clean-file added-file
+  $ hg ci -m 1 clean-file
+  A added-file
+  ? unknown-file
+  $ hg st -mardu
+  A added-file
+  ? unknown-file
+
+  $ touch modified-file
+  $ hg add modified-file
+  $ hg ci -m 2 modified-file -q
+
+  $ echo 'm' > modified-file
+  $ hg ci --amend -m 'reworded' -X 're:'
+  saved backup bundle to $TESTTMP/ci-post-st/.hg/strip-backup/*-amend.hg (glob)
+  M modified-file
+  A added-file
+  ? unknown-file
+  $ hg st -mardu
+  M modified-file
+  A added-file
+  ? unknown-file
+
+  $ cd ..