mirror of
https://github.com/facebook/sapling.git
synced 2024-12-27 06:52:23 +03:00
configs: move hgrc.dynamic to always be in the shared repo
Summary: Instead of trying to maintain two hgrc.dynamic's for shared repositories, let's just always use the one in the shared repo. In the long term we may be able to get rid of the working-copy-specific hgrc entirely. This does remove the ability to dynamically configure individual working copies. That could be useful in cases where we have both eden and non-eden pointed at the same repository, but I don't think we rely on this at the moment. Reviewed By: quark-zju Differential Revision: D21333564 fbshipit-source-id: c1fb86af183ec6dc5d973cf45d71419bda5514fb
This commit is contained in:
parent
c326c5fc6b
commit
97d84e3b5d
@ -976,7 +976,7 @@ def _getlocal(ui, rpath):
|
||||
lui = ui.copy()
|
||||
|
||||
if path:
|
||||
uiconfig.loaddynamicconfig(lui, path)
|
||||
uiconfig.loaddynamicconfig(lui, os.path.join(path, ".hg"))
|
||||
|
||||
# Load the primary config after the dynamic one, so it overwrites it
|
||||
lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
|
||||
|
@ -440,7 +440,7 @@ class localrepository(object):
|
||||
# This list it to be filled by extension during repo setup
|
||||
self._phasedefaults = []
|
||||
try:
|
||||
uiconfig.loaddynamicconfig(self.ui, self.root)
|
||||
uiconfig.loaddynamicconfig(self.ui, self.path)
|
||||
# Load the primary config after the dynamic one, so it overwrites it
|
||||
self.ui.readconfig(self.localvfs.join("hgrc"), self.root)
|
||||
uiconfig.validatedynamicconfig(self.ui)
|
||||
|
@ -552,7 +552,11 @@ def parselist(value):
|
||||
|
||||
def loaddynamicconfig(ui, path):
|
||||
if ui.configbool("configs", "loaddynamicconfig", False):
|
||||
hgrcdyn = os.path.join(path, ".hg", "hgrc.dynamic")
|
||||
sharedpathfile = os.path.join(path, "sharedpath")
|
||||
if os.path.exists(sharedpathfile):
|
||||
path = open(sharedpathfile, "r").read()
|
||||
|
||||
hgrcdyn = os.path.join(path, "hgrc.dynamic")
|
||||
|
||||
if ui.configbool("configs", "autogeneratedynamicconfig", False):
|
||||
if not os.path.exists(hgrcdyn):
|
||||
|
@ -18,6 +18,7 @@ pub struct Repo {
|
||||
bundle_path: Option<PathBuf>,
|
||||
shared_path: PathBuf,
|
||||
dot_hg_path: PathBuf,
|
||||
shared_dot_hg_path: PathBuf,
|
||||
repo_name: Option<String>,
|
||||
}
|
||||
|
||||
@ -103,6 +104,7 @@ impl Repo {
|
||||
} else {
|
||||
let shared_path = read_sharedpath(&path)?;
|
||||
let dot_hg_path = path.join(".hg");
|
||||
let shared_dot_hg_path = shared_path.join(".hg");
|
||||
let repo_name = config
|
||||
.get("remotefilelog", "reponame")
|
||||
.map(|v| v.to_string());
|
||||
@ -112,6 +114,7 @@ impl Repo {
|
||||
bundle_path: None,
|
||||
shared_path,
|
||||
dot_hg_path,
|
||||
shared_dot_hg_path,
|
||||
repo_name,
|
||||
})
|
||||
}
|
||||
@ -133,6 +136,11 @@ impl Repo {
|
||||
&self.dot_hg_path
|
||||
}
|
||||
|
||||
/// Repo shared root path, with `.hg`. Equivalent to self.shared_path().join(".hg")
|
||||
pub fn shared_dot_hg_path(&self) -> &Path {
|
||||
&self.shared_dot_hg_path
|
||||
}
|
||||
|
||||
pub fn config(&self) -> &ConfigSet {
|
||||
&self.config
|
||||
}
|
||||
|
@ -280,8 +280,12 @@ pub fn debugdynamicconfig(_opts: DebugDynamicConfigOpts, _io: &mut IO, repo: Rep
|
||||
.map_or_else(|| "".to_string(), |s| s.to_string());
|
||||
let config = Generator::new(repo_name)?.execute()?;
|
||||
let config_str = config.to_string();
|
||||
let config_str = format!(
|
||||
"# Generated by `hg debugdynamicconfig` - DO NOT MODIFY\n{}",
|
||||
config_str
|
||||
);
|
||||
|
||||
let repo_path = repo.dot_hg_path();
|
||||
let repo_path = repo.shared_dot_hg_path();
|
||||
fs::write(repo_path.join("hgrc.dynamic"), config_str)?;
|
||||
Ok(0)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ Verify it can be manually generated
|
||||
|
||||
$ hg debugdynamicconfig
|
||||
$ cat .hg/hgrc.dynamic
|
||||
# Generated by `hg debugdynamicconfig` - DO NOT MODIFY
|
||||
[section]
|
||||
key=value
|
||||
|
||||
@ -30,6 +31,7 @@ Verify it can be automatically synchronously generated
|
||||
$ hg config section.key --config configs.autogeneratedynamicconfig=True
|
||||
value
|
||||
$ cat .hg/hgrc.dynamic
|
||||
# Generated by `hg debugdynamicconfig` - DO NOT MODIFY
|
||||
[section]
|
||||
key=value
|
||||
|
||||
@ -49,6 +51,7 @@ Verify it can be automatically asynchronously regenerated
|
||||
$ hg config section2.key2
|
||||
value2
|
||||
$ cat .hg/hgrc.dynamic
|
||||
# Generated by `hg debugdynamicconfig` - DO NOT MODIFY
|
||||
[section]
|
||||
key=value
|
||||
|
||||
@ -66,3 +69,26 @@ Validate dynamic config
|
||||
Config mismatch: section.key has 'value' (dynamic) vs 'valueX' (file)
|
||||
Config mismatch: section2.key2 has 'value2' (dynamic) vs 'None' (file)
|
||||
Config mismatch: section.key has 'value' (dynamic) vs 'valueX' (file)
|
||||
|
||||
Verify we generate and load from a shared repo
|
||||
|
||||
$ cd ..
|
||||
$ enable share
|
||||
$ hg init shared
|
||||
$ hg share shared shared_copy
|
||||
updating working directory
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ cd shared_copy
|
||||
$ hg debugdynamicconfig
|
||||
$ test -f .hg/hgrc.dynamic
|
||||
[1]
|
||||
$ cat ../shared/.hg/hgrc.dynamic
|
||||
# Generated by `hg debugdynamicconfig` - DO NOT MODIFY
|
||||
[section]
|
||||
key=value
|
||||
|
||||
[section2]
|
||||
key2=value2
|
||||
|
||||
$ hg config section.key
|
||||
value
|
||||
|
Loading…
Reference in New Issue
Block a user