[reporootlog] report the repo root to the scm wrappers
Summary:
The SCM wrappers do not have a reliable and easy way of detecting the repo root. For instance, if someone does hg log /full/path/to/repo/content, we cannot actually determine that /full/path/to/repo is the repo root. We have to somehow integrate an overly large portion of mercurial's commmand parsing infrastrastructure to accomplish this.
However, since mercurial knows the repo root, just extract that knowledge and send it down to the client.
Test Plan:
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' --config 'extensions.reporootlog=work/facebook-hg-rpms/fb-hgext/hgext3rd/reporootlog.py' work/facebook-hg-rpms/smoketest.sh
chg: enabled by /etc/mercurial/usechg
<snipped for brevity>
internal stats file: /tmp/scm-internal-stats5BoW29
hg profiling mode: LSPROFILER
stats: {
"int": {
"builddate": 1469712764,
"cachehitratio": 50,
"consumed": 302,
"diffcachehitratio": -1,
"elapsed": 130,
"errorcode": 0,
"filesnotincachehitratio": -1,
"time": 1469819716
},
"normal": {
"chg": "true",
"command": "log",
"evolution": "createmarkers",
"evolutionext": "-*- empty -*-",
"fastmanifest": "-*- empty -*-",
"filesystem": "",
"fsmonitor_ext": "-*- not present -*-",
"fsmonitor_mode": "on",
"fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers --config extensions.reporootlog=work\/facebook-hg-rpms\/fb-hgext\/hgext3rd\/reporootlog.py work\/facebook-hg-rpms\/smoketest.sh",
"generaldelta": "false",
"host": "dev8692.prn1",
"iftype": "disconnected",
"interactive": "true",
"kernel": "4.0.9-30_fbk4_2311_gd3e5a5c",
"metrics_type": "fastmanifest-filesnotincachehitratio",
"msg": "",
"parent": "\/bin\/bash",
"remotefilelog": "false",
"repo": "work\/facebook-hg-rpms",
"scm": "hg",
"sid": "",
"source": "hg",
"sqldirstate": "false",
"sqldirstate_enabled": "-*- not present -*-",
"sqldirstate_loaded": "-*- empty -*-",
"sqldirstate_upgrade": "True",
"sshclient": "localhost",
"tw_job_cluster": "",
"tw_job_name": "",
"tw_job_user": "",
"tw_oncall_team": "",
"tw_task_id": "",
"user": "ttung",
"version": "3.8.4+443-d0746b"
}
}
[dev8692]:~>
```
Without this change, the repo would be "unknown-repo":
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' work/facebook-hg-rpms/smoketest.sh 2>&1 | grep repo
"fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers work\/facebook-hg-rpms\/smoketest.sh",
"repo": "unknown-repo",
[dev8692]:~>
```
Reviewers: #mercurial, rmcelroy, quark
Reviewed By: quark
Subscribers: quark, mitrandir, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3643342
Tasks: 11194713
Signature: t1:3643342:1470163958:8d56291dad575c7ea7186cf5d00420798c5303ab
2016-08-02 21:59:52 +03:00
|
|
|
# reporootlog.py - log the repo root
|
|
|
|
#
|
|
|
|
# Copyright 2016 Facebook, Inc.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
2017-03-25 01:22:31 +03:00
|
|
|
"""this extension logs different pieces of information that will be used
|
2016-09-09 18:04:03 +03:00
|
|
|
by SCM wrappers
|
2017-03-12 22:01:45 +03:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
[logging]
|
|
|
|
# list of config options to log
|
|
|
|
configoptions = section1.option1,section2.option2
|
|
|
|
|
[reporootlog] report the repo root to the scm wrappers
Summary:
The SCM wrappers do not have a reliable and easy way of detecting the repo root. For instance, if someone does hg log /full/path/to/repo/content, we cannot actually determine that /full/path/to/repo is the repo root. We have to somehow integrate an overly large portion of mercurial's commmand parsing infrastrastructure to accomplish this.
However, since mercurial knows the repo root, just extract that knowledge and send it down to the client.
Test Plan:
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' --config 'extensions.reporootlog=work/facebook-hg-rpms/fb-hgext/hgext3rd/reporootlog.py' work/facebook-hg-rpms/smoketest.sh
chg: enabled by /etc/mercurial/usechg
<snipped for brevity>
internal stats file: /tmp/scm-internal-stats5BoW29
hg profiling mode: LSPROFILER
stats: {
"int": {
"builddate": 1469712764,
"cachehitratio": 50,
"consumed": 302,
"diffcachehitratio": -1,
"elapsed": 130,
"errorcode": 0,
"filesnotincachehitratio": -1,
"time": 1469819716
},
"normal": {
"chg": "true",
"command": "log",
"evolution": "createmarkers",
"evolutionext": "-*- empty -*-",
"fastmanifest": "-*- empty -*-",
"filesystem": "",
"fsmonitor_ext": "-*- not present -*-",
"fsmonitor_mode": "on",
"fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers --config extensions.reporootlog=work\/facebook-hg-rpms\/fb-hgext\/hgext3rd\/reporootlog.py work\/facebook-hg-rpms\/smoketest.sh",
"generaldelta": "false",
"host": "dev8692.prn1",
"iftype": "disconnected",
"interactive": "true",
"kernel": "4.0.9-30_fbk4_2311_gd3e5a5c",
"metrics_type": "fastmanifest-filesnotincachehitratio",
"msg": "",
"parent": "\/bin\/bash",
"remotefilelog": "false",
"repo": "work\/facebook-hg-rpms",
"scm": "hg",
"sid": "",
"source": "hg",
"sqldirstate": "false",
"sqldirstate_enabled": "-*- not present -*-",
"sqldirstate_loaded": "-*- empty -*-",
"sqldirstate_upgrade": "True",
"sshclient": "localhost",
"tw_job_cluster": "",
"tw_job_name": "",
"tw_job_user": "",
"tw_oncall_team": "",
"tw_task_id": "",
"user": "ttung",
"version": "3.8.4+443-d0746b"
}
}
[dev8692]:~>
```
Without this change, the repo would be "unknown-repo":
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' work/facebook-hg-rpms/smoketest.sh 2>&1 | grep repo
"fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers work\/facebook-hg-rpms\/smoketest.sh",
"repo": "unknown-repo",
[dev8692]:~>
```
Reviewers: #mercurial, rmcelroy, quark
Reviewed By: quark
Subscribers: quark, mitrandir, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3643342
Tasks: 11194713
Signature: t1:3643342:1470163958:8d56291dad575c7ea7186cf5d00420798c5303ab
2016-08-02 21:59:52 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
from mercurial import (
|
|
|
|
extensions,
|
|
|
|
localrepo,
|
|
|
|
)
|
|
|
|
|
|
|
|
def _localrepoinit(orig, self, baseui, path=None, create=False):
|
2016-09-08 19:39:55 +03:00
|
|
|
orig(self, baseui, path, create)
|
2017-07-18 20:09:28 +03:00
|
|
|
reponame = self.ui.config('paths', 'default')
|
2016-09-09 18:07:56 +03:00
|
|
|
if reponame:
|
|
|
|
reponame = os.path.basename(reponame)
|
2017-03-12 22:01:45 +03:00
|
|
|
configoptstolog = self.ui.configlist('logging', 'configoptions')
|
2016-09-09 18:07:56 +03:00
|
|
|
kwargs = {'repo': reponame}
|
2017-03-12 22:01:45 +03:00
|
|
|
for option in configoptstolog:
|
|
|
|
splitted = option.split('.')
|
|
|
|
if len(splitted) != 2:
|
|
|
|
continue
|
|
|
|
section, name = splitted
|
2017-07-21 08:09:22 +03:00
|
|
|
value = self.ui.config(section, name)
|
2017-03-12 22:01:45 +03:00
|
|
|
if value is not None:
|
|
|
|
kwargs[name] = value
|
|
|
|
|
2017-04-25 11:09:28 +03:00
|
|
|
obsstore_size = 0
|
|
|
|
try:
|
|
|
|
obsstore_size = self.svfs.stat('obsstore').st_size
|
|
|
|
except Exception:
|
|
|
|
# just ignore exception, it's better than failing the whole command
|
|
|
|
pass
|
|
|
|
|
|
|
|
kwargs['obsstore_size'] = obsstore_size
|
|
|
|
|
2016-09-09 18:04:03 +03:00
|
|
|
self.ui.log("logginghelper",
|
[reporootlog] report the repo root to the scm wrappers
Summary:
The SCM wrappers do not have a reliable and easy way of detecting the repo root. For instance, if someone does hg log /full/path/to/repo/content, we cannot actually determine that /full/path/to/repo is the repo root. We have to somehow integrate an overly large portion of mercurial's commmand parsing infrastrastructure to accomplish this.
However, since mercurial knows the repo root, just extract that knowledge and send it down to the client.
Test Plan:
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' --config 'extensions.reporootlog=work/facebook-hg-rpms/fb-hgext/hgext3rd/reporootlog.py' work/facebook-hg-rpms/smoketest.sh
chg: enabled by /etc/mercurial/usechg
<snipped for brevity>
internal stats file: /tmp/scm-internal-stats5BoW29
hg profiling mode: LSPROFILER
stats: {
"int": {
"builddate": 1469712764,
"cachehitratio": 50,
"consumed": 302,
"diffcachehitratio": -1,
"elapsed": 130,
"errorcode": 0,
"filesnotincachehitratio": -1,
"time": 1469819716
},
"normal": {
"chg": "true",
"command": "log",
"evolution": "createmarkers",
"evolutionext": "-*- empty -*-",
"fastmanifest": "-*- empty -*-",
"filesystem": "",
"fsmonitor_ext": "-*- not present -*-",
"fsmonitor_mode": "on",
"fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers --config extensions.reporootlog=work\/facebook-hg-rpms\/fb-hgext\/hgext3rd\/reporootlog.py work\/facebook-hg-rpms\/smoketest.sh",
"generaldelta": "false",
"host": "dev8692.prn1",
"iftype": "disconnected",
"interactive": "true",
"kernel": "4.0.9-30_fbk4_2311_gd3e5a5c",
"metrics_type": "fastmanifest-filesnotincachehitratio",
"msg": "",
"parent": "\/bin\/bash",
"remotefilelog": "false",
"repo": "work\/facebook-hg-rpms",
"scm": "hg",
"sid": "",
"source": "hg",
"sqldirstate": "false",
"sqldirstate_enabled": "-*- not present -*-",
"sqldirstate_loaded": "-*- empty -*-",
"sqldirstate_upgrade": "True",
"sshclient": "localhost",
"tw_job_cluster": "",
"tw_job_name": "",
"tw_job_user": "",
"tw_oncall_team": "",
"tw_task_id": "",
"user": "ttung",
"version": "3.8.4+443-d0746b"
}
}
[dev8692]:~>
```
Without this change, the repo would be "unknown-repo":
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' work/facebook-hg-rpms/smoketest.sh 2>&1 | grep repo
"fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers work\/facebook-hg-rpms\/smoketest.sh",
"repo": "unknown-repo",
[dev8692]:~>
```
Reviewers: #mercurial, rmcelroy, quark
Reviewed By: quark
Subscribers: quark, mitrandir, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3643342
Tasks: 11194713
Signature: t1:3643342:1470163958:8d56291dad575c7ea7186cf5d00420798c5303ab
2016-08-02 21:59:52 +03:00
|
|
|
"", # ui.log requires a format string as args[0].
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
def uisetup(ui):
|
|
|
|
extensions.wrapfunction(localrepo.localrepository,
|
|
|
|
'__init__', _localrepoinit)
|