mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-16 00:56:23 +00:00
Remove the std::Option around UnpublishedOperation::data
The Option is unnecessary now since `UnpublishedOperation` doesn't implement the Drop trait (the `MustClose` member implements it instead).
This commit is contained in:
parent
962b188b76
commit
c4cbf25545
1 changed files with 14 additions and 13 deletions
|
@ -173,7 +173,7 @@ struct NewRepoData {
|
||||||
#[must_use = "Either publish() or leave_unpublished() must be called to finish the operation."]
|
#[must_use = "Either publish() or leave_unpublished() must be called to finish the operation."]
|
||||||
pub struct UnpublishedOperation {
|
pub struct UnpublishedOperation {
|
||||||
repo_loader: RepoLoader,
|
repo_loader: RepoLoader,
|
||||||
data: Option<NewRepoData>,
|
data: NewRepoData,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnpublishedOperation {
|
impl UnpublishedOperation {
|
||||||
|
@ -183,20 +183,22 @@ impl UnpublishedOperation {
|
||||||
view: View,
|
view: View,
|
||||||
index: Box<dyn ReadonlyIndex>,
|
index: Box<dyn ReadonlyIndex>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let data = Some(NewRepoData {
|
UnpublishedOperation {
|
||||||
operation,
|
repo_loader,
|
||||||
view,
|
data: NewRepoData {
|
||||||
index,
|
operation,
|
||||||
});
|
view,
|
||||||
UnpublishedOperation { repo_loader, data }
|
index,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn operation(&self) -> &Operation {
|
pub fn operation(&self) -> &Operation {
|
||||||
&self.data.as_ref().unwrap().operation
|
&self.data.operation
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn publish(mut self) -> Arc<ReadonlyRepo> {
|
pub fn publish(self) -> Arc<ReadonlyRepo> {
|
||||||
let data = self.data.take().unwrap();
|
let data = self.data;
|
||||||
{
|
{
|
||||||
let _lock = self.repo_loader.op_heads_store().lock();
|
let _lock = self.repo_loader.op_heads_store().lock();
|
||||||
self.repo_loader
|
self.repo_loader
|
||||||
|
@ -207,9 +209,8 @@ impl UnpublishedOperation {
|
||||||
.create_from(data.operation, data.view, data.index)
|
.create_from(data.operation, data.view, data.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn leave_unpublished(mut self) -> Arc<ReadonlyRepo> {
|
pub fn leave_unpublished(self) -> Arc<ReadonlyRepo> {
|
||||||
let data = self.data.take().unwrap();
|
|
||||||
self.repo_loader
|
self.repo_loader
|
||||||
.create_from(data.operation, data.view, data.index)
|
.create_from(self.data.operation, self.data.view, self.data.index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue