mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
c0e7082b92
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
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# 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.
|
|
|
|
"""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.
|
|
"""
|
|
|
|
import os
|
|
from mercurial import (
|
|
extensions,
|
|
localrepo,
|
|
)
|
|
from mercurial.i18n import _
|
|
|
|
def _localrepoinit(orig, self, baseui, path=None, create=False):
|
|
result = orig(self, baseui, path, create)
|
|
kwargs = {'repo': path}
|
|
self.ui.log("reporootlog",
|
|
"", # ui.log requires a format string as args[0].
|
|
**kwargs)
|
|
|
|
def uisetup(ui):
|
|
extensions.wrapfunction(localrepo.localrepository,
|
|
'__init__', _localrepoinit)
|