Read about our upcoming Code of Conduct on this issue

Commit 4f3d5909 authored by Manuel Jacob's avatar Manuel Jacob
Browse files

absorb: consider rewrite.empty-successor configuration

This adds support for the recently added rewrite.empty-successor configuration.
parent 1efbfa9b36a7
......@@ -50,6 +50,7 @@ from mercurial import (
phases,
pycompat,
registrar,
rewriteutil,
scmutil,
util,
)
......@@ -782,8 +783,10 @@ class fixupstate(object):
# nothing changed, nothing commited
nextp1 = ctx
continue
if ctx.files() and self._willbecomenoop(
memworkingcopy, ctx, nextp1
if (
self.skip_empty_successor
and ctx.files()
and self._willbecomenoop(memworkingcopy, ctx, nextp1)
):
# changeset is no longer necessary
self.replacemap[ctx.node()] = None
......@@ -935,6 +938,10 @@ class fixupstate(object):
self.repo, replacements, operation=b'absorb', fixphase=True
)
@util.propertycache
def skip_empty_successor(self):
return rewriteutil.skip_empty_successor(self.ui, b'absorb')
def _parsechunk(hunk):
"""(crecord.uihunk or patch.recordhunk) -> (path, (a1, a2, [bline]))"""
......
......@@ -1896,7 +1896,7 @@ Alias definitions for revsets. See :hg:`help revsets` for details.
operations. If set to ``skip``, the successor is not created. If set to
``keep``, the empty successor is created and kept.
Currently, only the rebase command considers this configuration.
Currently, only the rebase and absorb commands consider this configuration.
(EXPERIMENTAL)
``storage``
......
......@@ -490,6 +490,71 @@ Remove lines may delete changesets:
+3
Setting config rewrite.empty-successor=keep 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 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
$ 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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment