mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 09:08:51 +00:00
repo: add generic Repo::base_repo() to access current operation from revset
This isn't fancy, but I couldn't find a better abstraction. Note that MutableRepo::base_repo() isn't removed as it has to return &Arc<_>, whereas <ReadonlyRepo as Repo>::base_repo() can't return &Arc<_>.
This commit is contained in:
parent
c6568787f3
commit
303564ca2b
1 changed files with 12 additions and 0 deletions
|
@ -98,6 +98,10 @@ use crate::view::RenameWorkspaceError;
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
|
|
||||||
pub trait Repo {
|
pub trait Repo {
|
||||||
|
/// Base repository that contains all committed data. Returns `self` if this
|
||||||
|
/// is a `ReadonlyRepo`,
|
||||||
|
fn base_repo(&self) -> &ReadonlyRepo;
|
||||||
|
|
||||||
fn store(&self) -> &Arc<Store>;
|
fn store(&self) -> &Arc<Store>;
|
||||||
|
|
||||||
fn op_store(&self) -> &Arc<dyn OpStore>;
|
fn op_store(&self) -> &Arc<dyn OpStore>;
|
||||||
|
@ -312,6 +316,10 @@ impl ReadonlyRepo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Repo for ReadonlyRepo {
|
impl Repo for ReadonlyRepo {
|
||||||
|
fn base_repo(&self) -> &ReadonlyRepo {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn store(&self) -> &Arc<Store> {
|
fn store(&self) -> &Arc<Store> {
|
||||||
self.loader.store()
|
self.loader.store()
|
||||||
}
|
}
|
||||||
|
@ -1821,6 +1829,10 @@ impl MutableRepo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Repo for MutableRepo {
|
impl Repo for MutableRepo {
|
||||||
|
fn base_repo(&self) -> &ReadonlyRepo {
|
||||||
|
&self.base_repo
|
||||||
|
}
|
||||||
|
|
||||||
fn store(&self) -> &Arc<Store> {
|
fn store(&self) -> &Arc<Store> {
|
||||||
self.base_repo.store()
|
self.base_repo.store()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue