rhg: Sub-repositories are not supported
authorSimon Sapin <simon.sapin@octobus.net>
Tue, 09 Nov 2021 18:17:52 +0100
changeset 48547 7f633432ca92
parent 48546 5151b0f6519e
child 48548 c9abfb80b4e3
rhg: Sub-repositories are not supported Differential Revision: https://phab.mercurial-scm.org/D11940
rust/hg-core/src/repo.rs
rust/rhg/src/main.rs
tests/test-subrepo-deep-nested-change.t
tests/test-subrepo-missing.t
--- a/rust/hg-core/src/repo.rs	Tue Dec 07 17:48:50 2021 -0800
+++ b/rust/hg-core/src/repo.rs	Tue Nov 09 18:17:52 2021 +0100
@@ -417,6 +417,14 @@
         )
     }
 
+    pub fn has_subrepos(&self) -> Result<bool, DirstateError> {
+        if let Some(entry) = self.dirstate_map()?.get(HgPath::new(".hgsub"))? {
+            Ok(entry.state().is_tracked())
+        } else {
+            Ok(false)
+        }
+    }
+
     pub fn filelog(&self, path: &HgPath) -> Result<Filelog, HgError> {
         Filelog::open(self, path)
     }
--- a/rust/rhg/src/main.rs	Tue Dec 07 17:48:50 2021 -0800
+++ b/rust/rhg/src/main.rs	Tue Nov 09 18:17:52 2021 +0100
@@ -29,7 +29,7 @@
     repo: Result<&Repo, &NoRepoInCwdError>,
     config: &Config,
 ) -> Result<(), CommandError> {
-    check_unsupported(config, ui)?;
+    check_unsupported(config, repo, ui)?;
 
     let app = App::new("rhg")
         .global_setting(AppSettings::AllowInvalidUtf8)
@@ -643,6 +643,7 @@
 
 fn check_unsupported(
     config: &Config,
+    repo: Result<&Repo, &NoRepoInCwdError>,
     ui: &ui::Ui,
 ) -> Result<(), CommandError> {
     check_extensions(config)?;
@@ -653,6 +654,12 @@
         Err(CommandError::unsupported("$HG_PENDING"))?
     }
 
+    if let Ok(repo) = repo {
+        if repo.has_subrepos()? {
+            Err(CommandError::unsupported("sub-repositories"))?
+        }
+    }
+
     if config.has_non_empty_section(b"encode") {
         Err(CommandError::unsupported("[encode] config"))?
     }
--- a/tests/test-subrepo-deep-nested-change.t	Tue Dec 07 17:48:50 2021 -0800
+++ b/tests/test-subrepo-deep-nested-change.t	Tue Nov 09 18:17:52 2021 +0100
@@ -1,7 +1,3 @@
-TODO: fix rhg bugs that make this test fail when status is enabled
-  $ unset RHG_STATUS
-
-
   $ cat >> $HGRCPATH <<EOF
   > [extdiff]
   > # for portability:
--- a/tests/test-subrepo-missing.t	Tue Dec 07 17:48:50 2021 -0800
+++ b/tests/test-subrepo-missing.t	Tue Nov 09 18:17:52 2021 +0100
@@ -1,7 +1,3 @@
-TODO: fix rhg bugs that make this test fail when status is enabled
-  $ unset RHG_STATUS
-
-
   $ hg init repo
   $ cd repo
   $ hg init subrepo