Skip to content

Commit 0071731

Browse files
zzl0facebook-github-bot
authored andcommitted
histedit: abort when attempting to fold subtree commits
Summary: Currently, `histedit` does not combine the subtree metadata when it folds subtree commits, so the subtree metadata can be lost. I’m not sure that simply merging the metadata would fully solve the issue. Until we have a proper fix, this diff aborts `histedit` whenever a user tries to fold subtree commits. Reviewed By: muirdm Differential Revision: D75897810 fbshipit-source-id: 3a29885d97a414afe646142ef82dd36299a4204a
1 parent d421a4c commit 0071731

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

eden/scm/sapling/ext/histedit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
visibility,
259259
)
260260
from sapling.i18n import _
261+
from sapling.utils import subtreeutil
261262

262263
# pyre-fixme[11]: Annotation `pickle` is not defined as a type.
263264
pickle = util.pickle
@@ -1173,11 +1174,23 @@ def _histedit(ui, repo, state, *freeargs, **opts):
11731174
# goal == goalnew
11741175
_newhistedit(ui, repo, state, revs, freeargs, opts)
11751176

1177+
_abort_if_fold_subtree_commits(state)
11761178
_continuehistedit(ui, repo, state)
11771179
_finishhistedit(ui, repo, state, fm)
11781180
fm.end()
11791181

11801182

1183+
def _abort_if_fold_subtree_commits(state):
1184+
for action in state.actions:
1185+
if isinstance(action, fold):
1186+
extra = action.repo[action.node].extra()
1187+
if subtreeutil.get_subtree_metadata(extra):
1188+
raise error.Abort(
1189+
_("histedit cannot fold/roll subtree commits"),
1190+
hint=_("use '@prog@ fold' to combine subtree commits"),
1191+
)
1192+
1193+
11811194
def _continuehistedit(ui, repo, state):
11821195
"""This function runs after either:
11831196
- bootstrapcontinue (if the goal is 'continue')

eden/scm/tests/test-subtree-histedit.t

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,19 @@ test histedit to fold subtree merge commits
5151
> pick 23b8d4a76647 merge B from foo to foo2
5252
> f c90acfc6d9e6 merge C from foo to foo3
5353
> EOF
54-
tofix: the combined commits should have two subtree merge metadata
54+
abort: histedit cannot fold/roll subtree commits
55+
(use 'hg fold' to combine subtree commits)
56+
[255]
57+
$ hg histedit 23b8d4a76647 --commands - <<EOF
58+
> pick 23b8d4a76647 merge B from foo to foo2
59+
> r c90acfc6d9e6 merge C from foo to foo3
60+
> EOF
61+
abort: histedit cannot fold/roll subtree commits
62+
(use 'hg fold' to combine subtree commits)
63+
[255]
64+
$ hg fold --from 23b8d4a76647
65+
2 changesets folded
66+
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
5567
$ hg subtree inspect -r .
5668
{
5769
"merges": [
@@ -60,6 +72,12 @@ tofix: the combined commits should have two subtree merge metadata
6072
"from_commit": "c4fbbcdf676b67867d7a51393f12109974c5da59",
6173
"from_path": "foo",
6274
"to_path": "foo2"
75+
},
76+
{
77+
"version": 1,
78+
"from_commit": "4701d37a062f216cc8ae6cebe85ce64a59cf6fc1",
79+
"from_path": "foo",
80+
"to_path": "foo3"
6381
}
6482
]
6583
}

0 commit comments

Comments
 (0)