+33
-40
Diff
round #0
+17
-17
cli/tests/test_squash_command.rs
+17
-17
cli/tests/test_squash_command.rs
···
1166
1166
let output = work_dir.run_jj(["squash", "--from=a", "--into=b", "--restore-descendants"]);
1167
1167
insta::assert_snapshot!(output, @r"
1168
1168
------- stderr -------
1169
-
Rebased 2 descendant commits (while preserving their content)
1170
-
Working copy (@) now at: kpqxywon 7fa445c9 f | (no description set)
1169
+
Rebased 5 descendant commits (while preserving their content)
1170
+
Working copy (@) now at: kpqxywon 27d75f43 f | (no description set)
1171
1171
Parent commit (@-) : yostqsxw 102e6106 e | (no description set)
1172
-
Parent commit (@-) : mzvwutvl a2ff7c27 c | (no description set)
1172
+
Parent commit (@-) : mzvwutvl 86d2ecde c | (no description set)
1173
1173
[EOF]
1174
1174
");
1175
1175
insta::assert_snapshot!(run_log(), @r"
1176
-
@ 7fa445c9e606 f
1176
+
@ 27d75f43e860 f
1177
1177
โโโฎ A f
1178
-
โ โ a2ff7c27dbba c
1178
+
โ โ 86d2ecdec2d7 c
1179
1179
โ โ A c
1180
-
โ โ 2bf81678391c b
1180
+
โ โ 7c3b32b0545d b
1181
1181
โ โ A a
1182
1182
โ โ A b
1183
1183
โ โ 102e61065eb2 e
···
1222
1222
]);
1223
1223
insta::assert_snapshot!(output, @r"
1224
1224
------- stderr -------
1225
-
Rebased 2 descendant commits (while preserving their content)
1226
-
Working copy (@) now at: kpqxywon 30c1ec1b f | (no description set)
1225
+
Rebased 5 descendant commits (while preserving their content)
1226
+
Working copy (@) now at: kpqxywon a6c6eeb5 f | (no description set)
1227
1227
Parent commit (@-) : yostqsxw c20a2a7a e | (no description set)
1228
-
Parent commit (@-) : mzvwutvl 601223f5 c | (no description set)
1228
+
Parent commit (@-) : mzvwutvl 5230f5a0 c | (no description set)
1229
1229
[EOF]
1230
1230
");
1231
1231
insta::assert_snapshot!(run_log(), @r"
1232
-
@ 30c1ec1b6264 f
1232
+
@ a6c6eeb5767f f
1233
1233
โโโฎ A f
1234
-
โ โ 601223f5faa8 c
1234
+
โ โ 5230f5a06e69 c
1235
1235
โ โ A c
1236
-
โ โ 28223a4af36c b
1236
+
โ โ 5d6fef1e0e34 b
1237
1237
โ โ A a
1238
1238
โ โ A b
1239
1239
โ โ c20a2a7a24ba e
···
1474
1474
let output = work_dir.run_jj(["squash", "--from=a", "--into=e", "--restore-descendants"]);
1475
1475
insta::assert_snapshot!(output, @r"
1476
1476
------- stderr -------
1477
-
Rebased 1 descendant commits (while preserving their content)
1478
-
Working copy (@) now at: kpqxywon 94ad7042 f | (no description set)
1479
-
Parent commit (@-) : yostqsxw 582d640e e | (no description set)
1477
+
Rebased 5 descendant commits (while preserving their content)
1478
+
Working copy (@) now at: kpqxywon e92b3f0f f | (no description set)
1479
+
Parent commit (@-) : yostqsxw 78651b37 e | (no description set)
1480
1480
Parent commit (@-) : mzvwutvl 2214436c c | (no description set)
1481
1481
[EOF]
1482
1482
");
1483
1483
insta::assert_snapshot!(run_log(), @r"
1484
-
@ 94ad70428c4a f
1484
+
@ e92b3f0fb9fe f
1485
1485
โโโฎ A f
1486
1486
โ โ 2214436c3fa7 c
1487
1487
โ โ A c
1488
1488
โ โ a469c893f362 b
1489
1489
โ โ A a
1490
1490
โ โ A b
1491
-
โ โ 582d640e331f e
1491
+
โ โ 78651b37e114 e
1492
1492
โ โ A e
1493
1493
โ โ 93671eb30330 d
1494
1494
โโโฏ A a
+16
-23
lib/src/rewrite.rs
+16
-23
lib/src/rewrite.rs
···
1170
1170
}
1171
1171
1172
1172
let mut rewritten_destination = destination.clone();
1173
-
if sources.iter().any(|source| {
1174
-
repo.index()
1175
-
.is_ancestor(source.commit.id(), destination.id())
1176
-
}) {
1173
+
if !restore_descendants
1174
+
&& sources.iter().any(|source| {
1175
+
repo.index()
1176
+
.is_ancestor(source.commit.id(), destination.id())
1177
+
})
1178
+
{
1177
1179
// If we're moving changes to a descendant, first rebase descendants onto the
1178
1180
// rewritten sources. Otherwise it will likely already have the content
1179
1181
// changes we're moving, so applying them will have no effect and the
1180
1182
// changes will disappear.
1181
-
if restore_descendants {
1182
-
repo.reparent_descendants_with_progress(|old_commit, rebased_commit| {
1183
-
if old_commit.id() != destination.id() {
1184
-
return;
1185
-
}
1186
-
rewritten_destination = rebased_commit;
1187
-
})?;
1188
-
} else {
1189
-
let options = RebaseOptions::default();
1190
-
repo.rebase_descendants_with_options(&options, |old_commit, rebased_commit| {
1191
-
if old_commit.id() != destination.id() {
1192
-
return;
1193
-
}
1194
-
rewritten_destination = match rebased_commit {
1195
-
RebasedCommit::Rewritten(commit) => commit,
1196
-
RebasedCommit::Abandoned { .. } => panic!("all commits should be kept"),
1197
-
};
1198
-
})?;
1199
-
}
1183
+
let options = RebaseOptions::default();
1184
+
repo.rebase_descendants_with_options(&options, |old_commit, rebased_commit| {
1185
+
if old_commit.id() != destination.id() {
1186
+
return;
1187
+
}
1188
+
rewritten_destination = match rebased_commit {
1189
+
RebasedCommit::Rewritten(commit) => commit,
1190
+
RebasedCommit::Abandoned { .. } => panic!("all commits should be kept"),
1191
+
};
1192
+
})?;
1200
1193
}
1201
1194
// Apply the selected changes onto the destination
1202
1195
let mut destination_tree = rewritten_destination.tree()?;
History
1 round
0 comments
ilyagr.bsky.social
submitted
#0
1 commit
expand
collapse
no-restore-descendants
no conflicts, ready to merge