mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
clidispatch: pass repo path to config contructor in from_raw_path
Summary: We weren't passing a repo path when initially loading the repo's config in `clidispatch`. This meant that the resulting `ConfigSet` didn't contain values from the shared-repo `.hgrc.dynamic`. Evidently, some other code path in Python would eventually add these values, but this meant that pure-Rust commands could not see config values set via dynamicconfig. Passing the path fixes the problem. Reviewed By: DurhamG Differential Revision: D26508980 fbshipit-source-id: 65f187d18098a08c81325e78cb02a8ed854c739a
This commit is contained in:
parent
bbb0f7af67
commit
c94dfbcc38
@ -7,7 +7,7 @@
|
||||
|
||||
use crate::errors;
|
||||
use anyhow::Result;
|
||||
use configparser::{config::ConfigSet, hg::ConfigSetHgExt};
|
||||
use configparser::config::ConfigSet;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
@ -107,29 +107,27 @@ impl Repo {
|
||||
{
|
||||
let path = path.into();
|
||||
assert!(path.is_absolute());
|
||||
let mut config = configparser::hg::load::<String, String>(None, None)?;
|
||||
let mut errors = config.load_hgrc(path.join(".hg/hgrc"), "repository");
|
||||
if let Some(error) = errors.pop() {
|
||||
Err(error.into())
|
||||
} else {
|
||||
let shared_path = read_sharedpath(&path)?;
|
||||
let dot_hg_path = path.join(".hg");
|
||||
let shared_dot_hg_path = shared_path.join(".hg");
|
||||
let store_path = shared_dot_hg_path.join("store");
|
||||
let repo_name = config
|
||||
.get("remotefilelog", "reponame")
|
||||
.map(|v| v.to_string());
|
||||
Ok(Repo {
|
||||
path,
|
||||
config,
|
||||
bundle_path: None,
|
||||
shared_path,
|
||||
store_path,
|
||||
dot_hg_path,
|
||||
shared_dot_hg_path,
|
||||
repo_name,
|
||||
})
|
||||
}
|
||||
|
||||
let shared_path = read_sharedpath(&path)?;
|
||||
let dot_hg_path = path.join(".hg");
|
||||
let shared_dot_hg_path = shared_path.join(".hg");
|
||||
let store_path = shared_dot_hg_path.join("store");
|
||||
|
||||
let config = configparser::hg::load::<String, String>(Some(&dot_hg_path), None)?;
|
||||
let repo_name = config
|
||||
.get("remotefilelog", "reponame")
|
||||
.map(|v| v.to_string());
|
||||
|
||||
Ok(Repo {
|
||||
path,
|
||||
config,
|
||||
bundle_path: None,
|
||||
shared_path,
|
||||
store_path,
|
||||
dot_hg_path,
|
||||
shared_dot_hg_path,
|
||||
repo_name,
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the store path.
|
||||
|
@ -9,13 +9,14 @@ Invalid syntax: no value
|
||||
> novaluekey
|
||||
> EOF
|
||||
$ hg showconfig
|
||||
hg: parse error: "$TESTTMP/.hg/hgrc":
|
||||
hg: parse errors: "$TESTTMP/.hg/hgrc":
|
||||
--> 1:11
|
||||
|
|
||||
1 | novaluekey\xe2\x90\x8a (esc)
|
||||
| ^---
|
||||
|
|
||||
= expected equal_sign
|
||||
|
||||
[255]
|
||||
|
||||
Invalid syntax: no key
|
||||
@ -24,13 +25,14 @@ Invalid syntax: no key
|
||||
> =nokeyvalue
|
||||
> EOF
|
||||
$ hg showconfig
|
||||
hg: parse error: "$TESTTMP/.hg/hgrc":
|
||||
hg: parse errors: "$TESTTMP/.hg/hgrc":
|
||||
--> 1:1
|
||||
|
|
||||
1 | =nokeyvalue\xe2\x90\x8a (esc)
|
||||
| ^---
|
||||
|
|
||||
= expected EOI, new_line, config_name, left_bracket, comment_line, or directive
|
||||
|
||||
[255]
|
||||
|
||||
Test hint about invalid syntax from leading white space
|
||||
@ -39,13 +41,14 @@ Test hint about invalid syntax from leading white space
|
||||
> key=value
|
||||
> EOF
|
||||
$ hg showconfig
|
||||
hg: parse error: "$TESTTMP/.hg/hgrc":
|
||||
hg: parse errors: "$TESTTMP/.hg/hgrc":
|
||||
--> 1:2
|
||||
|
|
||||
1 | key=value\xe2\x90\x8a (esc)
|
||||
| ^---
|
||||
|
|
||||
= expected EOI or new_line
|
||||
|
||||
[255]
|
||||
|
||||
$ cat > .hg/hgrc << EOF
|
||||
@ -53,13 +56,14 @@ Test hint about invalid syntax from leading white space
|
||||
> key=value
|
||||
> EOF
|
||||
$ hg showconfig
|
||||
hg: parse error: "$TESTTMP/.hg/hgrc":
|
||||
hg: parse errors: "$TESTTMP/.hg/hgrc":
|
||||
--> 1:2
|
||||
|
|
||||
1 | [section]\xe2\x90\x8a (esc)
|
||||
| ^---
|
||||
|
|
||||
= expected EOI or new_line
|
||||
|
||||
[255]
|
||||
|
||||
Reset hgrc
|
||||
|
@ -80,13 +80,7 @@ However, we can't prevent it from loading extensions and configs:
|
||||
$ mkdir -p badrepo/.hg
|
||||
$ echo 'invalid-syntax' > badrepo/.hg/hgrc
|
||||
$ hg log -b -Rbadrepo default
|
||||
hg: parse error: "$TESTTMP/a/badrepo/.hg/hgrc":
|
||||
--> 1:15
|
||||
|
|
||||
1 | invalid-syntax\xe2\x90\x8a (esc)
|
||||
| ^---
|
||||
|
|
||||
= expected equal_sign
|
||||
abort: unable to read repo config to get repo name
|
||||
[255]
|
||||
|
||||
(XXX: Rust io::Error does not contain path information)
|
||||
|
Loading…
Reference in New Issue
Block a user