Mercurial > hg
changeset 44983:1b757f385549
absorb: preserve branch-changing changesets even if empty
This makes the behavior consistent with 'hg commit', which allows to create
otherwise empty changesets if the branch changes compared to the parent. A
branch change can denote important information, so it should be preserved.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Mon, 01 Jun 2020 10:33:00 +0200 |
parents | bacf6c7ef01b |
children | bfef35bb4ecb |
files | hgext/absorb.py tests/test-absorb.t |
diffstat | 2 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/absorb.py Mon Jun 22 15:19:35 2020 +0530 +++ b/hgext/absorb.py Mon Jun 01 10:33:00 2020 +0200 @@ -887,6 +887,8 @@ if len(parents) != 1: return False pctx = parents[0] + if ctx.branch() != pctx.branch(): + return False # ctx changes more files (not a subset of memworkingcopy) if not set(ctx.files()).issubset(set(memworkingcopy)): return False
--- a/tests/test-absorb.t Mon Jun 22 15:19:35 2020 +0530 +++ b/tests/test-absorb.t Mon Jun 01 10:33:00 2020 +0200 @@ -525,3 +525,31 @@ a: 1 of 1 chunk(s) applied $ hg id bfafb49242db tip + + $ cd .. + $ hg init repo6 + $ cd repo6 + $ echo a1 > a + $ touch b + $ hg commit -m a -A a b + $ hg branch foo -q + $ echo b > b + $ hg commit -m foo # will become empty + $ hg branch bar -q + $ hg commit -m bar # is already empty + $ echo a2 > a + $ printf '' > b + $ hg absorb --apply-changes --verbose | grep became + 0:0cde1ae39321: 1 file(s) changed, became 3:fc7fcdd90fdb + 1:795dfb1adcef: 2 file(s) changed, became 4:a8740537aa53 + 2:b02935f68891: 2 file(s) changed, became 5:59533e01c707 + $ hg log -T '{rev} (branch: {branch}) {desc}\n' -G --stat + @ 5 (branch: bar) bar + | + o 4 (branch: foo) foo + | + o 3 (branch: default) a + a | 1 + + b | 0 + 2 files changed, 1 insertions(+), 0 deletions(-) +