[PATCH 2 of 3] absorb: preserve branch-closing changesets even if empty

Manuel Jacob me at manueljacob.de
Tue Jun 16 13:58:13 UTC 2020


# HG changeset patch
# User Manuel Jacob <me at manueljacob.de>
# Date 1591002453 -7200
#      Mon Jun 01 11:07:33 2020 +0200
# Node ID 9a645c5fcc8551cb95e62ce1c538a902f3b7a4ca
# Parent  658889a51a83ba348575179ec210bd7a40f79ff0
# EXP-Topic absorb-empty
absorb: preserve branch-closing changesets even if empty

This makes the behavior consistent with 'hg commit', which allows to create
otherwise empty changesets if they close the branch. A lost branch closure can
inadvertently re-open a branch, so it should be preserved.

diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -889,6 +889,8 @@
             pctx = parents[0]
         if ctx.branch() != pctx.branch():
             return False
+        if ctx.extra().get(b'close'):
+            return False
         # ctx changes more files (not a subset of memworkingcopy)
         if not set(ctx.files()).issubset(set(memworkingcopy)):
             return False
diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -553,3 +553,37 @@
       b |  0
       2 files changed, 1 insertions(+), 0 deletions(-)
   
+
+  $ cd ..
+  $ hg init repo7
+  $ cd repo7
+  $ echo a1 > a
+  $ touch b
+  $ hg commit -m a -A a b
+  $ echo b > b
+  $ hg commit -m foo --close-branch  # will become empty
+  $ echo c > c
+  $ hg commit -m reopen -A c -q
+  $ hg commit -m bar --close-branch  # is already empty
+  $ echo a2 > a
+  $ echo -n '' > b
+  $ hg absorb --apply-changes --verbose | grep became
+  0:0cde1ae39321: 1 file(s) changed, became 4:fc7fcdd90fdb
+  1:651b953d5764: 2 file(s) changed, became 5:0c9de988ecdc
+  2:76017bba73f6: 2 file(s) changed, became 6:d53ac896eb25
+  3:c7c1d67efc1d: 2 file(s) changed, became 7:66520267fe96
+  $ hg up null -q  # to make visible closed heads
+  $ hg log -T '{rev} {desc}\n' -G --stat
+  _  7 bar
+  |
+  o  6 reopen
+  |   c |  1 +
+  |   1 files changed, 1 insertions(+), 0 deletions(-)
+  |
+  _  5 foo
+  |
+  o  4 a
+      a |  1 +
+      b |  0
+      2 files changed, 1 insertions(+), 0 deletions(-)
+  




More information about the Mercurial-devel mailing list