mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
logginghelper: use repo basename as repo name
Summary: When we don't provide a repo name, scm_telem_log will run `hg config` to try and get the path, and fall back to using the basename of the repo directory. However, this is a bit undesirable, because if we ran this code we already checked the path, so the repo URL isn't going to magically materialize once `hg config` asks for it, which means we make a completely redundant call to hg from scm_telem_log. By just doing this in logginghelper, we avoid this extra roundtrip. Reviewed By: StanislavGlebik Differential Revision: D21572027 fbshipit-source-id: 58e5ab2e3e525edef1ecde039cd968eab8d89172
This commit is contained in:
parent
e96c923fba
commit
6676a7a476
@ -31,6 +31,8 @@ def _localrepoinit(orig, self, baseui, path=None, create=False):
|
||||
reponame = self.ui.config("paths", "default")
|
||||
if reponame:
|
||||
reponame = os.path.basename(reponame).split("?")[0]
|
||||
if path and not reponame:
|
||||
reponame = os.path.basename(path)
|
||||
kwargs = {"repo": reponame}
|
||||
|
||||
# The configs being read here are user defined, so we need to suppress
|
||||
|
@ -96,3 +96,5 @@ Verify logging uses correct repo name
|
||||
> EOF
|
||||
$ python logverify.py | uniq
|
||||
repo: repo
|
||||
repo: client
|
||||
repo: repo
|
||||
|
39
eden/scm/tests/test-hgext-logginghelper.t
Normal file
39
eden/scm/tests/test-hgext-logginghelper.t
Normal file
@ -0,0 +1,39 @@
|
||||
#require jq
|
||||
#chg-compatible
|
||||
|
||||
$ . "$TESTDIR/library.sh"
|
||||
|
||||
$ enable logginghelper
|
||||
$ enable sampling
|
||||
$ setconfig sampling.key.logginghelper=logginghelper
|
||||
|
||||
$ hg init repo123
|
||||
$ cd repo123
|
||||
|
||||
$ export SCM_SAMPLING_FILEPATH="$TESTTMP/sample"
|
||||
|
||||
Check we got the repository name from the local path
|
||||
|
||||
$ hg status
|
||||
$ tr '\0' '\n' < "$SCM_SAMPLING_FILEPATH" | jq -r .data.repo
|
||||
repo123
|
||||
$ rm "$SCM_SAMPLING_FILEPATH"
|
||||
|
||||
Check that it doesn't matter where we are in the repo
|
||||
|
||||
$ mkdir foobar
|
||||
$ cd foobar
|
||||
$ hg status
|
||||
$ tr '\0' '\n' < "$SCM_SAMPLING_FILEPATH" | jq -r .data.repo
|
||||
repo123
|
||||
$ rm "$SCM_SAMPLING_FILEPATH"
|
||||
$ cd ..
|
||||
|
||||
Check we got the repository name from the remote path
|
||||
|
||||
$ setconfig paths.default=ssh://foo.com//bar/repo456
|
||||
|
||||
$ hg status
|
||||
$ tr '\0' '\n' < "$SCM_SAMPLING_FILEPATH" | jq -r .data.repo
|
||||
repo456
|
||||
$ rm "$SCM_SAMPLING_FILEPATH"
|
Loading…
Reference in New Issue
Block a user