Skip to content

Commit 39380e1

Browse files
quark-zjumeta-codesync[bot]
authored andcommitted
clidispatch: enable dotgit no-optional-locks for non-tty users
Summary: See the added comments. This prevents less informed developers not setting `SL_AUTOMATION=1` from breaking dotgit user experiences. Reviewed By: fzakaria Differential Revision: D98003016 fbshipit-source-id: 875ee94fe6ff7011aaf460649a6f17265b406b7a
1 parent c5bfc1d commit 39380e1

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

eden/scm/lib/clidispatch/src/configure_libraries.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,30 @@
2020
//! Check `lib/constructors` - it affects both `sl` and `eden`
2121
//! (via `lib/backingstore`).
2222
23+
use std::sync::atomic::Ordering;
24+
2325
use configmodel::Config;
2426
use configmodel::ConfigExt;
2527
use hgtime::HgTime;
2628
use io::IO;
29+
use io::IsTty;
2730
use repo::CoreRepo;
2831

2932
use crate::OptionalRepo;
3033
use crate::dispatch::Dispatcher;
3134
use crate::dispatch::Result;
3235

3336
impl Dispatcher {
34-
pub(crate) fn configure_libraries(&self, _io: &IO) -> Result<()> {
37+
pub(crate) fn configure_libraries(&self, io: &IO) -> Result<()> {
3538
let config = self.config();
3639
indexedlog::config::configure(config)?;
3740
gitcompat::GlobalGit::set_default_config(config);
3841
initialize_hgtime(config)?;
3942
initialize_blackbox(&self.optional_repo)?;
4043

44+
let is_tty = io.output().is_tty();
45+
configure_working_copy(is_tty);
46+
4147
Ok(())
4248
}
4349
}
@@ -87,3 +93,19 @@ fn initialize_hgtime(config: &dyn Config) -> Result<()> {
8793
}
8894
Ok(())
8995
}
96+
97+
fn configure_working_copy(is_tty: bool) {
98+
// Many automation runs `sl status` without `SL_AUTOMATION=1`
99+
// (e.g. D97984219, D97218795). They can cause serious UX issues
100+
// like 40% user-typed `checkout` commands are failing
101+
// (e.g. https://fburl.com/workplace/avjspdkk).
102+
//
103+
// Let's just set `no-optional-locks` for non-tty users.
104+
if !is_tty && !is_test() {
105+
workingcopy::config::DOTGIT_NO_OPTIONAL_LOCKS.store(true, Ordering::Release);
106+
}
107+
}
108+
109+
fn is_test() -> bool {
110+
std::env::var_os("TESTTMP").is_some()
111+
}

0 commit comments

Comments
 (0)