Patchwork [5,of,5,V2] absorb: make it explicit if empty changeset was created

login
register
mail settings
Submitter Manuel Jacob
Date July 12, 2020, 5:13 a.m.
Message ID <f0d1ae4b67fb74a63d62.1594530835@tmp>
Download mbox | patch
Permalink /patch/46704/
State Accepted
Headers show

Comments

Manuel Jacob - July 12, 2020, 5:13 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1590998131 -7200
#      Mon Jun 01 09:55:31 2020 +0200
# Node ID f0d1ae4b67fb74a63d62d8fc639c53ec83481702
# Parent  0d5a6db2d8e19b5c8cb3e78af2b2080b0f0f04e4
# EXP-Topic keep_empty_successor
absorb: make it explicit if empty changeset was created

If the config rewrite.empty-successor=skip is set, a message "became empty and
was dropped" is shown if the changeset became empty. If the config
rewrite.empty-successor=keep is set, absorb may create changesets even if they
became empty. It’s probably a good idea to make that explicit. Therefore the
message is changed to be a combination of both: "became empty and became ...".

Repeating the word "became" is not very elegant. This results from the fact
that "became" was and is overloaded to indicate both the change from non-empty
to empty and the successor relation. In the combinated message, both meanings
are used in one sentence.
Augie Fackler - July 15, 2020, 2:40 p.m.
On Sun, Jul 12, 2020 at 07:13:55AM +0200, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1590998131 -7200
> #      Mon Jun 01 09:55:31 2020 +0200
> # Node ID f0d1ae4b67fb74a63d62d8fc639c53ec83481702
> # Parent  0d5a6db2d8e19b5c8cb3e78af2b2080b0f0f04e4
> # EXP-Topic keep_empty_successor
> absorb: make it explicit if empty changeset was created

Queued, but consider a follow-up for my suggestion below if you like it.

>
> If the config rewrite.empty-successor=skip is set, a message "became empty and
> was dropped" is shown if the changeset became empty. If the config
> rewrite.empty-successor=keep is set, absorb may create changesets even if they
> became empty. It’s probably a good idea to make that explicit. Therefore the
> message is changed to be a combination of both: "became empty and became ...".
>
> Repeating the word "became" is not very elegant. This results from the fact
> that "became" was and is overloaded to indicate both the change from non-empty
> to empty and the successor relation. In the combinated message, both meanings
> are used in one sentence.
>

[...]

> diff --git a/tests/test-absorb.t b/tests/test-absorb.t
> --- a/tests/test-absorb.t
> +++ b/tests/test-absorb.t
> @@ -509,6 +509,7 @@
>    $ hg commit -m b3
>    $ echo 4 >> b
>    $ hg commit -m b4
> +  $ hg commit -m empty --config ui.allowemptycommit=True
>    $ echo 1 > b
>    $ echo 3 >> a
>    $ hg absorb -pn
> @@ -527,16 +528,19 @@
>    1154859 b12
>    bfafb49 a12
>    $ hg absorb -av --config rewrite.empty-successor=keep | grep became
> -  0:bfafb49242db: 1 file(s) changed, became 4:1a2de97fc652
> -  1:115485984805: 2 file(s) changed, became 5:0c930dfab74c
> -  2:30970dbf7b40: 2 file(s) changed, became 6:df6574ae635c
> -  3:a393a58b9a85: 2 file(s) changed, became 7:ad4bd3462c9e
> +  0:bfafb49242db: 1 file(s) changed, became 5:1a2de97fc652
> +  1:115485984805: 2 file(s) changed, became 6:0c930dfab74c
> +  2:30970dbf7b40: 2 file(s) changed, became empty and became 7:df6574ae635c
> +  3:a393a58b9a85: 2 file(s) changed, became empty and became 8:ad4bd3462c9e

Maybe "N:deadbeef: N file(s) changed, became M:f005ba11 (empty change)" instead?

> +  4:1bb0e8cff87a: 2 file(s) changed, became 9:2dbed75af996
>    $ hg log -T '{rev} {desc}\n' -Gp
> -  @  7 b4
> +  @  9 empty
> +  |
> +  o  8 b4
>    |
> -  o  6 b3
> +  o  7 b3
>    |
> -  o  5 b12
> +  o  6 b12
>    |  diff --git a/b b/b
>    |  new file mode 100644
>    |  --- /dev/null
> @@ -544,7 +548,7 @@
>    |  @@ -0,0 +1,1 @@
>    |  +1
>    |
> -  o  4 a12
> +  o  5 a12
>       diff --git a/a b/a
>       new file mode 100644
>       --- /dev/null
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -783,11 +783,10 @@ 
                 # nothing changed, nothing commited
                 nextp1 = ctx
                 continue
-            if (
-                self.skip_empty_successor
-                and ctx.files()
-                and self._willbecomenoop(memworkingcopy, ctx, nextp1)
-            ):
+            willbecomenoop = ctx.files() and self._willbecomenoop(
+                memworkingcopy, ctx, nextp1
+            )
+            if self.skip_empty_successor and willbecomenoop:
                 # changeset is no longer necessary
                 self.replacemap[ctx.node()] = None
                 msg = _(b'became empty and was dropped')
@@ -798,7 +797,14 @@ 
                 nextp1 = lastcommitted
                 self.replacemap[ctx.node()] = lastcommitted.node()
                 if memworkingcopy:
-                    msg = _(b'%d file(s) changed, became %s') % (
+                    if willbecomenoop:
+                        msg = _(
+                            b'%d file(s) changed, became empty '
+                            b'and became %s'
+                        )
+                    else:
+                        msg = _(b'%d file(s) changed, became %s')
+                    msg = msg % (
                         len(memworkingcopy),
                         self._ctx2str(lastcommitted),
                     )
diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -509,6 +509,7 @@ 
   $ hg commit -m b3
   $ echo 4 >> b
   $ hg commit -m b4
+  $ hg commit -m empty --config ui.allowemptycommit=True
   $ echo 1 > b
   $ echo 3 >> a
   $ hg absorb -pn
@@ -527,16 +528,19 @@ 
   1154859 b12
   bfafb49 a12
   $ hg absorb -av --config rewrite.empty-successor=keep | grep became
-  0:bfafb49242db: 1 file(s) changed, became 4:1a2de97fc652
-  1:115485984805: 2 file(s) changed, became 5:0c930dfab74c
-  2:30970dbf7b40: 2 file(s) changed, became 6:df6574ae635c
-  3:a393a58b9a85: 2 file(s) changed, became 7:ad4bd3462c9e
+  0:bfafb49242db: 1 file(s) changed, became 5:1a2de97fc652
+  1:115485984805: 2 file(s) changed, became 6:0c930dfab74c
+  2:30970dbf7b40: 2 file(s) changed, became empty and became 7:df6574ae635c
+  3:a393a58b9a85: 2 file(s) changed, became empty and became 8:ad4bd3462c9e
+  4:1bb0e8cff87a: 2 file(s) changed, became 9:2dbed75af996
   $ hg log -T '{rev} {desc}\n' -Gp
-  @  7 b4
+  @  9 empty
+  |
+  o  8 b4
   |
-  o  6 b3
+  o  7 b3
   |
-  o  5 b12
+  o  6 b12
   |  diff --git a/b b/b
   |  new file mode 100644
   |  --- /dev/null
@@ -544,7 +548,7 @@ 
   |  @@ -0,0 +1,1 @@
   |  +1
   |
-  o  4 a12
+  o  5 a12
      diff --git a/a b/a
      new file mode 100644
      --- /dev/null