Skip to content

Commit 47c500a

Browse files
Remove parents from Apply struct
With the new per_rev_filter function, we no longer need parents in Apply
1 parent 690ff17 commit 47c500a

File tree

3 files changed

+23
-49
lines changed

3 files changed

+23
-49
lines changed

josh-core/src/filter/mod.rs

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ pub struct Apply<'a> {
7171
pub author: Option<(String, String)>,
7272
pub committer: Option<(String, String)>,
7373
pub message: Option<String>,
74-
pub parents: Option<Vec<git2::Oid>>,
7574
}
7675

7776
impl<'a> Clone for Apply<'a> {
@@ -81,7 +80,6 @@ impl<'a> Clone for Apply<'a> {
8180
author: self.author.clone(),
8281
committer: self.committer.clone(),
8382
message: self.message.clone(),
84-
parents: self.parents.clone(),
8583
}
8684
}
8785
}
@@ -93,7 +91,6 @@ impl<'a> Apply<'a> {
9391
author: None,
9492
committer: None,
9593
message: None,
96-
parents: None,
9794
}
9895
}
9996

@@ -108,7 +105,6 @@ impl<'a> Apply<'a> {
108105
author,
109106
committer,
110107
message,
111-
parents: None,
112108
}
113109
}
114110

@@ -131,7 +127,6 @@ impl<'a> Apply<'a> {
131127
author,
132128
committer,
133129
message,
134-
parents: None,
135130
})
136131
}
137132

@@ -141,7 +136,6 @@ impl<'a> Apply<'a> {
141136
author: Some(author),
142137
committer: self.committer,
143138
message: self.message,
144-
parents: self.parents,
145139
}
146140
}
147141

@@ -151,7 +145,6 @@ impl<'a> Apply<'a> {
151145
author: self.author,
152146
committer: Some(committer),
153147
message: self.message,
154-
parents: self.parents,
155148
}
156149
}
157150

@@ -161,7 +154,6 @@ impl<'a> Apply<'a> {
161154
author: self.author,
162155
committer: self.committer,
163156
message: Some(message),
164-
parents: self.parents,
165157
}
166158
}
167159

@@ -171,17 +163,6 @@ impl<'a> Apply<'a> {
171163
author: self.author,
172164
committer: self.committer,
173165
message: self.message,
174-
parents: self.parents,
175-
}
176-
}
177-
178-
pub fn with_parents(self, parents: Vec<git2::Oid>) -> Self {
179-
Apply {
180-
tree: self.tree,
181-
author: self.author,
182-
committer: self.committer,
183-
message: self.message,
184-
parents: Some(parents),
185166
}
186167
}
187168

@@ -866,16 +847,7 @@ fn apply_to_commit2(
866847
}
867848
}
868849

869-
let filtered_parent_ids = commit
870-
.parents()
871-
.map(|x| transaction.get(filter, x.id()))
872-
.collect::<Option<Vec<_>>>();
873-
let filtered_parent_ids = some_or!(filtered_parent_ids, { return Ok(None) });
874-
apply(
875-
transaction,
876-
nf,
877-
Apply::from_commit(commit)?.with_parents(filtered_parent_ids),
878-
)?
850+
apply(transaction, nf, Apply::from_commit(commit)?)?
879851
}
880852
Op::Squash(Some(ids)) => {
881853
if let Some(sq) = ids.get(&LazyRef::Resolved(commit.id())) {
@@ -1053,18 +1025,7 @@ fn apply_to_commit2(
10531025

10541026
return per_rev_filter(transaction, commit, filter, commit_filter, parent_filters);
10551027
}
1056-
_ => {
1057-
let filtered_parent_ids = commit
1058-
.parent_ids()
1059-
.map(|x| transaction.get(filter, x))
1060-
.collect::<Option<Vec<_>>>();
1061-
let filtered_parent_ids = some_or!(filtered_parent_ids, { return Ok(None) });
1062-
apply(
1063-
transaction,
1064-
filter,
1065-
Apply::from_commit(commit)?.with_parents(filtered_parent_ids),
1066-
)?
1067-
}
1028+
_ => apply(transaction, filter, Apply::from_commit(commit)?)?,
10681029
};
10691030

10701031
let tree_data = rewrite_data;
@@ -1538,11 +1499,7 @@ fn per_rev_filter(
15381499

15391500
let filtered_parent_ids: Vec<_> = normal_parents.into_iter().chain(extra_parents).collect();
15401501

1541-
let mut tree_data = apply(
1542-
transaction,
1543-
commit_filter,
1544-
Apply::from_commit(commit)?.with_parents(filtered_parent_ids.clone()),
1545-
)?;
1502+
let mut tree_data = apply(transaction, commit_filter, Apply::from_commit(commit)?)?;
15461503

15471504
if let Some((pin_subtract, pin_overlay)) = pin_details {
15481505
let with_exclude = tree::subtract(transaction, tree_data.tree().id(), pin_subtract)?;

tests/proxy/workspace_invalid_trailing_slash.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ Flushed credential cache
277277
| | `-- 8233465e92d353e2ef47c02dc568ea44a32339
278278
| |-- 70
279279
| | `-- 5dcb4e33bd0dd3f95d5831fc8dc8a41ca3e566
280+
| |-- 7b
281+
| | `-- 418ed7c356797b1a8eef3ff949632495d273c6
280282
| |-- 7d
281283
| | `-- 5816334652b9738e33e4ceaf925573c3414e0c
282284
| |-- 85
@@ -295,6 +297,8 @@ Flushed credential cache
295297
| | `-- 613be55337cdfab189935d8dbd1d4f427ef75e
296298
| |-- b7
297299
| | `-- 8eb888451be077531b50794384c2faec025765
300+
| |-- cd
301+
| | `-- 9ae8cb61e7d1aaa7b90766ff9aa9b3dc78c856
298302
| |-- db
299303
| | `-- 9120ba624b0afe79d37a5a262d8deb14e13707
300304
| |-- f0
@@ -308,4 +312,4 @@ Flushed credential cache
308312
|-- namespaces
309313
`-- tags
310314

311-
69 directories, 56 files
315+
71 directories, 58 files

tests/proxy/workspace_tags.t

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@
343343
| | `-- 2a35c53f4e5901c9cc083a94b417c15837cad8
344344
| |-- 22
345345
| | `-- b3eaf7b374287220ac787fd2bce5958b69115c
346+
| |-- 23
347+
| | `-- f7e90462b3fc5db0a26335139e1fe83d04d2cd
346348
| |-- 26
347349
| | `-- 6864a895cac573b04a44bd40ee3bd8fe458a5f
348350
| |-- 2c
@@ -377,18 +379,25 @@
377379
| | `-- 0f21b330a3d45f363fcde6bfb57eed22948cb6
378380
| |-- 83
379381
| | `-- 3812f1557e561166754add564fe32228dd1703
382+
| |-- 96
383+
| | `-- f5351b972284f81d7246836f82f6be06c6631f
380384
| |-- 98
381385
| | `-- 84cc2efe368ea0aa9d912fa596b26c5d75dbee
382386
| |-- 9c
383387
| | `-- f258b407cd9cdba97e16a293582b29d302b796
384388
| |-- 9f
385389
| | `-- 8daab1754f04fbe8aaac6fcbb44c8324df09eb
390+
| |-- a0
391+
| | `-- 28e4ad33176e7db6f3d4a5fc7e92257cfe213e
386392
| |-- a3
387393
| | `-- d19dcb2f51fa1efd55250f60df559c2b8270b8
388394
| |-- a4
389-
| | `-- 1772e0c7cdad1a13b7a7bc38c0d382a5a827ce
395+
| | |-- 1772e0c7cdad1a13b7a7bc38c0d382a5a827ce
396+
| | `-- 8223bf4fc7801a0322b4ecaa5ed6a2c5dce7f1
390397
| |-- b0
391398
| | `-- fdeb65d9b9069015ef9c0f735a4f6f2f28fe77
399+
| |-- b1
400+
| | `-- c1b15558aebbce0682f25933cb729e9acd209c
392401
| |-- b6
393402
| | `-- c8440fe2cd36638ddb6b3505c1e8f2202f6191
394403
| |-- b8
@@ -407,8 +416,12 @@
407416
| | `-- d2a4d6db7addc2b087dcdb3e63785d3315c00e
408417
| |-- d7
409418
| | `-- 330ea337031af43ba1cf6982a873a40b9170ac
419+
| |-- e2
420+
| | `-- 5d071c2db414f24473e3768c063dbcf8c55d04
410421
| |-- ea
411422
| | `-- 1ae75547e348b07cb28a721a06ef6580ff67f0
423+
| |-- ed
424+
| | `-- 8ae0c02d30bd34d7a8584cb0930d0d7a58df26
412425
| |-- f2
413426
| | |-- 257977b96d2272be155d6699046148e477e9fb
414427
| | `-- 7e0d18d976fd84da0a9e260989ecb6edaa593f
@@ -423,6 +436,6 @@
423436
|-- namespaces
424437
`-- tags
425438

426-
101 directories, 92 files
439+
107 directories, 99 files
427440

428441
$ cat ${TESTTMP}/josh-proxy.out

0 commit comments

Comments
 (0)