Patchwork [3,of,4] absorb: add config that causes empty changesets to be created

login
register
mail settings
Submitter Manuel Jacob
Date July 1, 2020, 9:39 p.m.
Message ID <b54d68403a5435161e29.1593639542@tmp>
Download mbox | patch
Permalink /patch/46608/
State New
Headers show

Comments

Manuel Jacob - July 1, 2020, 9:39 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1590997361 -7200
#      Mon Jun 01 09:42:41 2020 +0200
# Node ID b54d68403a5435161e294b9227bfb5059a25b3f0
# Parent  45fa02da6fd1c3b40350329d80d6fe03c83f9a30
# EXP-Topic createempty
absorb: add config that causes empty changesets to be created

The design and the motivation for the new absorb.createempty config is the same
as for the rebase.createempty config.

Patch

diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -70,6 +70,7 @@ 
 configitem(b'absorb', b'add-noise', default=True)
 configitem(b'absorb', b'amend-flag', default=None)
 configitem(b'absorb', b'max-stack-size', default=50)
+configitem(b'absorb', b'createempty', default=False)
 
 colortable = {
     b'absorb.description': b'yellow',
@@ -782,8 +783,10 @@ 
                 # nothing changed, nothing commited
                 nextp1 = ctx
                 continue
-            if ctx.files() and self._willbecomenoop(
-                memworkingcopy, ctx, nextp1
+            if (
+                not self.ui.configbool(b'absorb', b'createempty')
+                and ctx.files()
+                and self._willbecomenoop(memworkingcopy, ctx, nextp1)
             ):
                 # changeset is no longer necessary
                 self.replacemap[ctx.node()] = None
diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -490,6 +490,71 @@ 
      +3
   
 
+The absorb.createempty config causes empty changesets to get committed:
+
+  $ cd ..
+  $ hg init repo4a
+  $ cd repo4a
+  $ cat > a <<EOF
+  > 1
+  > 2
+  > EOF
+  $ hg commit -m a12 -A a
+  $ cat > b <<EOF
+  > 1
+  > 2
+  > EOF
+  $ hg commit -m b12 -A b
+  $ echo 3 >> b
+  $ hg commit -m b3
+  $ echo 4 >> b
+  $ hg commit -m b4
+  $ echo 1 > b
+  $ echo 3 >> a
+  $ hg absorb -pn
+  showing changes for a
+          @@ -2,0 +2,1 @@
+  bfafb49 +3
+  showing changes for b
+          @@ -1,3 +1,0 @@
+  1154859 -2
+  30970db -3
+  a393a58 -4
+  
+  4 changesets affected
+  a393a58 b4
+  30970db b3
+  1154859 b12
+  bfafb49 a12
+  $ hg absorb -av --config absorb.createempty=True | 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
+  $ hg log -T '{rev} {desc}\n' -Gp
+  @  7 b4
+  |
+  o  6 b3
+  |
+  o  5 b12
+  |  diff --git a/b b/b
+  |  new file mode 100644
+  |  --- /dev/null
+  |  +++ b/b
+  |  @@ -0,0 +1,1 @@
+  |  +1
+  |
+  o  4 a12
+     diff --git a/a b/a
+     new file mode 100644
+     --- /dev/null
+     +++ b/a
+     @@ -0,0 +1,3 @@
+     +1
+     +2
+     +3
+  
+
 Use revert to make the current change and its parent disappear.
 This should move us to the non-obsolete ancestor.