aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-vcs/src/driver/hg.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-23 12:10:44 +0900
committernsfisis <nsfisis@gmail.com>2026-02-23 12:14:11 +0900
commitd8ecb21a7931ec6f1d7b447d0c15f53de32bfc45 (patch)
tree0da1e0c2ec988905b98939b524b72217e83019de /crates/mozart-vcs/src/driver/hg.rs
parent0080efea9386d46f65d1862fcb90eb44999d9761 (diff)
downloadphp-mozart-d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45.tar.gz
php-mozart-d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45.tar.zst
php-mozart-d8ecb21a7931ec6f1d7b447d0c15f53de32bfc45.zip
refactor(vcs): convert VcsDriver trait to native async
Replace manual tokio::runtime::Handle::current().block_on() calls with native async/await throughout all VCS drivers. Introduce AnyVcsDriver enum for static dispatch to avoid dyn trait with async methods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-vcs/src/driver/hg.rs')
-rw-r--r--crates/mozart-vcs/src/driver/hg.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/mozart-vcs/src/driver/hg.rs b/crates/mozart-vcs/src/driver/hg.rs
index 7bfb07e..f884c50 100644
--- a/crates/mozart-vcs/src/driver/hg.rs
+++ b/crates/mozart-vcs/src/driver/hg.rs
@@ -49,7 +49,7 @@ impl HgDriver {
}
impl VcsDriver for HgDriver {
- fn initialize(&mut self) -> Result<()> {
+ async fn initialize(&mut self) -> Result<()> {
let cache_dir = self.config.cache_dir.join("hg");
std::fs::create_dir_all(&cache_dir)?;
let repo_dir = cache_dir.join(crate::util::git::GitUtil::sanitize_url(&self.url));
@@ -83,7 +83,7 @@ impl VcsDriver for HgDriver {
self.root_identifier.as_deref().unwrap_or("default")
}
- fn branches(&mut self) -> Result<&BTreeMap<String, String>> {
+ async fn branches(&mut self) -> Result<&BTreeMap<String, String>> {
if self.branches.is_none() {
let repo_dir = self.get_repo_dir()?.clone();
let mut branches = BTreeMap::new();
@@ -121,7 +121,7 @@ impl VcsDriver for HgDriver {
Ok(self.branches.as_ref().unwrap())
}
- fn tags(&mut self) -> Result<&BTreeMap<String, String>> {
+ async fn tags(&mut self) -> Result<&BTreeMap<String, String>> {
if self.tags.is_none() {
let repo_dir = self.get_repo_dir()?.clone();
let output = self.hg_util.execute(&["tags", "-q"], Some(&repo_dir))?;
@@ -142,18 +142,21 @@ impl VcsDriver for HgDriver {
Ok(self.tags.as_ref().unwrap())
}
- fn composer_information(&mut self, identifier: &str) -> Result<Option<serde_json::Value>> {
+ async fn composer_information(
+ &mut self,
+ identifier: &str,
+ ) -> Result<Option<serde_json::Value>> {
if let Some(cached) = self.info_cache.get(identifier) {
return Ok(cached.clone());
}
- let content = self.file_content("composer.json", identifier)?;
+ let content = self.file_content("composer.json", identifier).await?;
let value = content.and_then(|c| serde_json::from_str(&c).ok());
self.info_cache
.insert(identifier.to_string(), value.clone());
Ok(value)
}
- fn file_content(&self, file: &str, identifier: &str) -> Result<Option<String>> {
+ async fn file_content(&self, file: &str, identifier: &str) -> Result<Option<String>> {
let repo_dir = self.get_repo_dir()?;
let output = self
.hg_util
@@ -165,7 +168,7 @@ impl VcsDriver for HgDriver {
}
}
- fn change_date(&self, identifier: &str) -> Result<Option<String>> {
+ async fn change_date(&self, identifier: &str) -> Result<Option<String>> {
let repo_dir = self.get_repo_dir()?;
let output = self.hg_util.execute(
&["log", "-r", identifier, "--template", "{date|isodatesec}"],
@@ -179,7 +182,7 @@ impl VcsDriver for HgDriver {
}
}
- fn dist(&self, _identifier: &str) -> Result<Option<DistReference>> {
+ async fn dist(&self, _identifier: &str) -> Result<Option<DistReference>> {
Ok(None)
}
@@ -195,7 +198,7 @@ impl VcsDriver for HgDriver {
&self.url
}
- fn cleanup(&mut self) -> Result<()> {
+ async fn cleanup(&mut self) -> Result<()> {
Ok(())
}
}