2014-11-04 10:03:09 +03:00
|
|
|
# Copyright 2014 Facebook Inc.
|
|
|
|
#
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
"""upload useful diagnostics and give instructions for asking for help"""
|
2014-11-04 10:03:09 +03:00
|
|
|
|
|
|
|
from mercurial.i18n import _
|
2016-01-08 05:30:24 +03:00
|
|
|
from mercurial import cmdutil, util, commands, bookmarks, ui, extensions, error
|
2016-04-28 21:13:28 +03:00
|
|
|
from mercurial import scmutil
|
2014-12-13 01:35:47 +03:00
|
|
|
from hgext import blackbox
|
2016-07-08 15:15:42 +03:00
|
|
|
from hgext3rd import (
|
|
|
|
smartlog,
|
|
|
|
sparse,
|
|
|
|
)
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
import os, socket, re, time, traceback
|
2014-11-04 10:03:09 +03:00
|
|
|
|
|
|
|
cmdtable = {}
|
|
|
|
command = cmdutil.command(cmdtable)
|
|
|
|
|
rage: silence exceptions when reading details
Summary:
rage is a basic tool to collect diagnostic information that should not break.
To ensure it works all the time, this patch:
- unbreaks hg rage from upstream change dad6404ccd
- wraps every non-trivial functions with `try`, `catch`
- adds a naive test about `hg rage --preview`
Test Plan:
Run `test-rage.t`. Comment out `import blackbox` and check:
```
hg blackbox -l20:
---------------------------
(Failed. See footnote [1])
[1]: global name 'blackbox' is not defined
Traceback (most recent call last):
File "/home/quark/fb-hgext/rage.py", line 22, in _failsafe
return func()
File "/home/quark/fb-hgext/rage.py", line 97, in <lambda>
_failsafe(lambda: hgcmd(blackbox.blackbox, limit=20))),
NameError: global name 'blackbox' is not defined
```
Reviewers: #sourcecontrol, wez, ttung, durham
Reviewed By: durham
Subscribers: durham, wez, mjpieters
Differential Revision: https://phabricator.fb.com/D2928778
Tasks: 10028490
Signature: t1:2928778:1455240651:d39ceed5d045e279160690e0a93a4e326d307db3
2016-02-12 00:00:33 +03:00
|
|
|
_failsafeerrors = []
|
|
|
|
|
|
|
|
def _failsafe(func):
|
|
|
|
try:
|
|
|
|
return func()
|
|
|
|
except Exception as ex:
|
|
|
|
index = len(_failsafeerrors) + 1
|
|
|
|
message = "[%d]: %s\n%s\n" % (index, str(ex), traceback.format_exc())
|
|
|
|
_failsafeerrors.append(message)
|
|
|
|
return '(Failed. See footnote [%d])' % index
|
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
def shcmd(cmd, input=None, check=True, keeperr=True):
|
|
|
|
_, _, _, p = util.popen4(cmd)
|
|
|
|
out, err = p.communicate(input)
|
|
|
|
if check and p.returncode:
|
|
|
|
raise error.Abort(cmd + ' error: ' + err)
|
|
|
|
elif keeperr:
|
|
|
|
out += err
|
|
|
|
return out
|
|
|
|
|
|
|
|
def createtask(ui, repo, defaultdesc):
|
|
|
|
"""FBONLY: create task for source control oncall"""
|
|
|
|
prompt = '''Title: [hg rage] %s on %s by %s
|
2015-03-08 22:22:25 +03:00
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
Description:
|
|
|
|
%s
|
2015-03-08 22:22:25 +03:00
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
HG: Edit task title and description. Lines beginning with 'HG:' are removed."
|
|
|
|
HG: First line is the title followed by the description.
|
|
|
|
HG: Feel free to add relevant information.
|
|
|
|
''' % (repo.root, socket.gethostname(), os.getenv('LOGNAME'), defaultdesc)
|
2015-03-08 22:22:25 +03:00
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
text = re.sub("(?m)^HG:.*(\n|$)", "", ui.edit(prompt, ui.username()))
|
|
|
|
lines = text.splitlines()
|
|
|
|
title = re.sub("(?m)^Title:\s+", "", lines[0])
|
|
|
|
desc = re.sub("(?m)^Description:\s+", "", '\n'.join(lines[1:]))
|
|
|
|
tag = 'hg rage'
|
|
|
|
oncall = 'source_control'
|
|
|
|
taskid = shcmd(' '.join([
|
|
|
|
'tasks',
|
|
|
|
'create',
|
|
|
|
'--title=' + util.shellquote(title),
|
|
|
|
'--pri=low',
|
|
|
|
'--assign=' + util.shellquote(oncall),
|
|
|
|
'--sub=' + util.shellquote(oncall),
|
|
|
|
'--tag=' + util.shellquote(tag),
|
|
|
|
'--desc=' + util.shellquote(desc),
|
|
|
|
])
|
|
|
|
)
|
|
|
|
tasknum = shcmd('tasks view ' + taskid).splitlines()[0].split()[0]
|
|
|
|
print('Task created: https://our.intern.facebook.com/intern/tasks/?t=%s'
|
|
|
|
% tasknum)
|
|
|
|
|
2016-05-03 18:12:06 +03:00
|
|
|
def which(name):
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
""" """
|
2016-05-03 18:12:06 +03:00
|
|
|
for p in os.environ.get('PATH', '/bin').split(os.pathsep):
|
|
|
|
path = os.path.join(p, name)
|
|
|
|
if os.path.exists(path):
|
|
|
|
return path
|
|
|
|
return None
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
|
|
|
|
rageopts = [('p', 'preview', None,
|
|
|
|
_('print diagnostic information without doing arc paste'))]
|
2016-05-03 18:12:06 +03:00
|
|
|
if which('oncalls'):
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
rageopts.append(('', 'oncall', None,
|
|
|
|
_('file a task for source control oncall')))
|
|
|
|
|
|
|
|
def localconfig(ui):
|
|
|
|
result = []
|
|
|
|
for section, name, value in ui.walkconfig():
|
|
|
|
source = ui.configsource(section, name)
|
|
|
|
if source.find('/etc/') == -1 and source.find('/default.d/') == -1:
|
|
|
|
result.append('%s.%s=%s # %s' % (section, name, value, source))
|
|
|
|
return result
|
|
|
|
|
2016-04-28 21:13:28 +03:00
|
|
|
def obsoleteinfo(repo, hgcmd):
|
|
|
|
"""Return obsolescence markers that are relevant to smartlog revset"""
|
|
|
|
unfi = repo.unfiltered()
|
|
|
|
revs = scmutil.revrange(unfi, ["smartlog()"])
|
|
|
|
hashes = '|'.join(unfi[rev].hex() for rev in revs)
|
|
|
|
markers = hgcmd(commands.debugobsolete, rev=[])
|
|
|
|
pat = re.compile('(^.*(?:'+hashes+').*$)', re.MULTILINE)
|
|
|
|
relevant = pat.findall(markers)
|
|
|
|
return "\n".join(relevant)
|
|
|
|
|
2016-05-03 18:00:35 +03:00
|
|
|
def usechginfo():
|
|
|
|
"""FBONLY: Information about whether chg is enabled"""
|
|
|
|
files = {
|
|
|
|
'system': '/etc/mercurial/usechg',
|
|
|
|
'user': os.path.expanduser('~/.usechg'),
|
|
|
|
}
|
|
|
|
result = []
|
|
|
|
for name, path in files.items():
|
|
|
|
if os.path.exists(path):
|
|
|
|
with open(path) as f:
|
|
|
|
value = f.read().strip()
|
|
|
|
else:
|
|
|
|
value = '(not set)'
|
|
|
|
result.append('%s: %s' % (name, value))
|
|
|
|
return '\n'.join(result)
|
|
|
|
|
2016-05-03 18:12:06 +03:00
|
|
|
def rpminfo():
|
|
|
|
"""FBONLY: Information about RPM packages"""
|
|
|
|
result = set()
|
|
|
|
for name in ['hg', 'hg.real']:
|
|
|
|
path = which(name)
|
|
|
|
if not path:
|
|
|
|
continue
|
|
|
|
result.add(shcmd('rpm -qf %s' % path, check=False))
|
|
|
|
return ''.join(result)
|
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
@command('^rage', rageopts , _('hg rage'))
|
|
|
|
def rage(ui, repo, *pats, **opts):
|
|
|
|
"""collect useful diagnostics for asking help from the source control team
|
2015-03-08 22:22:25 +03:00
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
The rage command collects useful diagnostic information.
|
2015-03-08 22:22:25 +03:00
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
By default, the information will be uploaded to Phabricator and
|
|
|
|
instructions about how to ask for help will be printed.
|
2015-03-08 22:22:25 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
def format(pair, basic=True):
|
|
|
|
if basic:
|
|
|
|
fmt = "%s: %s\n"
|
|
|
|
else:
|
|
|
|
fmt = "%s:\n---------------------------\n%s\n"
|
|
|
|
return fmt % pair
|
|
|
|
|
|
|
|
def hgcmd(func, *args, **opts):
|
2016-09-29 21:19:52 +03:00
|
|
|
_repo = repo
|
|
|
|
if '_repo' in opts:
|
|
|
|
_repo = opts['_repo']
|
|
|
|
del opts['_repo']
|
|
|
|
ui.pushbuffer(error=True)
|
|
|
|
func(ui, _repo, *args, **opts)
|
2015-03-08 22:22:25 +03:00
|
|
|
return ui.popbuffer()
|
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
if opts.get('oncall') and opts.get('preview'):
|
|
|
|
raise error.Abort('--preview and --oncall cannot be used together')
|
2015-03-08 22:22:25 +03:00
|
|
|
|
|
|
|
basic = [
|
|
|
|
('date', time.ctime()),
|
2015-12-03 05:44:42 +03:00
|
|
|
('unixname', os.getenv('LOGNAME')),
|
2015-03-08 22:22:25 +03:00
|
|
|
('hostname', socket.gethostname()),
|
rage: silence exceptions when reading details
Summary:
rage is a basic tool to collect diagnostic information that should not break.
To ensure it works all the time, this patch:
- unbreaks hg rage from upstream change dad6404ccd
- wraps every non-trivial functions with `try`, `catch`
- adds a naive test about `hg rage --preview`
Test Plan:
Run `test-rage.t`. Comment out `import blackbox` and check:
```
hg blackbox -l20:
---------------------------
(Failed. See footnote [1])
[1]: global name 'blackbox' is not defined
Traceback (most recent call last):
File "/home/quark/fb-hgext/rage.py", line 22, in _failsafe
return func()
File "/home/quark/fb-hgext/rage.py", line 97, in <lambda>
_failsafe(lambda: hgcmd(blackbox.blackbox, limit=20))),
NameError: global name 'blackbox' is not defined
```
Reviewers: #sourcecontrol, wez, ttung, durham
Reviewed By: durham
Subscribers: durham, wez, mjpieters
Differential Revision: https://phabricator.fb.com/D2928778
Tasks: 10028490
Signature: t1:2928778:1455240651:d39ceed5d045e279160690e0a93a4e326d307db3
2016-02-12 00:00:33 +03:00
|
|
|
('repo location', _failsafe(lambda: repo.root)),
|
|
|
|
('active bookmark',
|
|
|
|
_failsafe(lambda: bookmarks._readactive(repo, repo._bookmarks))),
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
('hg version', _failsafe(
|
|
|
|
lambda: __import__('mercurial.__version__').__version__.version)),
|
|
|
|
('obsstore size', _failsafe(
|
|
|
|
lambda: str(repo.vfs.stat('store/obsstore').st_size))),
|
2015-03-08 22:22:25 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
ui._colormode = None
|
|
|
|
|
|
|
|
detailed = [
|
rage: silence exceptions when reading details
Summary:
rage is a basic tool to collect diagnostic information that should not break.
To ensure it works all the time, this patch:
- unbreaks hg rage from upstream change dad6404ccd
- wraps every non-trivial functions with `try`, `catch`
- adds a naive test about `hg rage --preview`
Test Plan:
Run `test-rage.t`. Comment out `import blackbox` and check:
```
hg blackbox -l20:
---------------------------
(Failed. See footnote [1])
[1]: global name 'blackbox' is not defined
Traceback (most recent call last):
File "/home/quark/fb-hgext/rage.py", line 22, in _failsafe
return func()
File "/home/quark/fb-hgext/rage.py", line 97, in <lambda>
_failsafe(lambda: hgcmd(blackbox.blackbox, limit=20))),
NameError: global name 'blackbox' is not defined
```
Reviewers: #sourcecontrol, wez, ttung, durham
Reviewed By: durham
Subscribers: durham, wez, mjpieters
Differential Revision: https://phabricator.fb.com/D2928778
Tasks: 10028490
Signature: t1:2928778:1455240651:d39ceed5d045e279160690e0a93a4e326d307db3
2016-02-12 00:00:33 +03:00
|
|
|
('df -h', _failsafe(lambda: shcmd('df -h', check=False))),
|
2016-09-29 21:19:52 +03:00
|
|
|
# unfiltered smartlog for recent hidden changesets
|
|
|
|
('hg sl', _failsafe(lambda: hgcmd(
|
|
|
|
smartlog.smartlog, _repo=repo.unfiltered(), template='{sl}'))),
|
2015-03-08 22:22:25 +03:00
|
|
|
('first 20 lines of "hg status"',
|
rage: silence exceptions when reading details
Summary:
rage is a basic tool to collect diagnostic information that should not break.
To ensure it works all the time, this patch:
- unbreaks hg rage from upstream change dad6404ccd
- wraps every non-trivial functions with `try`, `catch`
- adds a naive test about `hg rage --preview`
Test Plan:
Run `test-rage.t`. Comment out `import blackbox` and check:
```
hg blackbox -l20:
---------------------------
(Failed. See footnote [1])
[1]: global name 'blackbox' is not defined
Traceback (most recent call last):
File "/home/quark/fb-hgext/rage.py", line 22, in _failsafe
return func()
File "/home/quark/fb-hgext/rage.py", line 97, in <lambda>
_failsafe(lambda: hgcmd(blackbox.blackbox, limit=20))),
NameError: global name 'blackbox' is not defined
```
Reviewers: #sourcecontrol, wez, ttung, durham
Reviewed By: durham
Subscribers: durham, wez, mjpieters
Differential Revision: https://phabricator.fb.com/D2928778
Tasks: 10028490
Signature: t1:2928778:1455240651:d39ceed5d045e279160690e0a93a4e326d307db3
2016-02-12 00:00:33 +03:00
|
|
|
_failsafe(lambda:
|
|
|
|
'\n'.join(hgcmd(commands.status).splitlines()[:20]))),
|
2016-08-05 21:17:45 +03:00
|
|
|
('last 40 lines of interesting blackbox.log',
|
|
|
|
_failsafe(lambda: shcmd('grep -Fv FM: %s | tail -n 40'
|
|
|
|
% util.shellquote(ui._bbfp.name)))),
|
2016-06-01 19:36:48 +03:00
|
|
|
('hg summary', _failsafe(lambda: hgcmd(commands.summary))),
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
('hg config (local)', _failsafe(lambda: '\n'.join(localconfig(ui)))),
|
|
|
|
('hg sparse',
|
|
|
|
_failsafe(
|
|
|
|
lambda: hgcmd(
|
|
|
|
sparse.sparse, include=False, exclude=False, delete=False,
|
|
|
|
force=False, enable_profile=False, disable_profile=False,
|
|
|
|
refresh=False, reset=False))),
|
2016-05-03 18:00:35 +03:00
|
|
|
('usechg', _failsafe(usechginfo)),
|
2016-05-03 18:12:06 +03:00
|
|
|
('rpm info', _failsafe(rpminfo)),
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
('ifconfig', _failsafe(lambda: shcmd('ifconfig'))),
|
|
|
|
('airport', _failsafe(
|
|
|
|
lambda: shcmd('/System/Library/PrivateFrameworks/Apple80211.' +
|
|
|
|
'framework/Versions/Current/Resources/airport ' +
|
|
|
|
'--getinfo', check=False))),
|
2016-04-28 21:13:28 +03:00
|
|
|
('hg debugobsolete <smartlog>',
|
|
|
|
_failsafe(lambda: obsoleteinfo(repo, hgcmd))),
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
('hg config (all)', _failsafe(lambda: hgcmd(commands.config))),
|
2015-03-08 22:22:25 +03:00
|
|
|
]
|
|
|
|
|
2016-06-07 21:40:24 +03:00
|
|
|
# This is quite slow, so we don't want to do it by default
|
|
|
|
if ui.configbool("rage", "fastmanifestcached", False):
|
|
|
|
detailed.append(
|
|
|
|
('hg sl -r "fastmanifestcached()"',
|
|
|
|
_failsafe(lambda: hgcmd(smartlog.smartlog,
|
|
|
|
rev=["fastmanifestcached()"]))),
|
|
|
|
)
|
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
msg = '\n'.join(map(format, basic)) + '\n' +\
|
|
|
|
'\n'.join(map(lambda x: format(x, False), detailed))
|
|
|
|
if _failsafeerrors:
|
|
|
|
msg += '\n' + '\n'.join(_failsafeerrors)
|
|
|
|
|
2015-12-03 05:44:42 +03:00
|
|
|
if opts.get('preview'):
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
print(msg)
|
2015-12-03 05:44:42 +03:00
|
|
|
return
|
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
pasteurl = shcmd('arc paste --lang hgrage', msg).split()[1]
|
2015-03-08 22:22:25 +03:00
|
|
|
|
Refactoring rage.py
Summary:
A couple of clean-ups for rage.py. They are small and easy to review so I'm doing it in one diff:
- Change the default behavior to print instructions asking for help in the support group.
Since only about 20 hg rage (not counting test ones) tasks are created last year.
The old behavior of creating tasks is still accessible by using the `--oncall` flag.
- Collect more information:
- `hg sparse`
- `hg version`
- `obsstore size`
- `rpm -q mercurial`
- network information
- short `hg config` only including local configs
- Adjust the order of detailed message, move hg config down since it's very long.
- Remove atexit error printer. Instead, put them in rage info directly.
- Fix code style: remove underscores in variable names, remove unnecessary indentation.
- Mark it FBONLY since it uses `tasks` and `oncalls` which are not available outside.
Test Plan:
Make sure these all work as expected:
hg rage
hg rage --preview
hg rage --oncall
Reviewers: #sourcecontrol, ttung, rmcelroy
Reviewed By: rmcelroy
Subscribers: ikostia, ttung, rmcelroy, simonfar, mjpieters, sid0
Differential Revision: https://phabricator.fb.com/D3138673
Tasks: 10654995, 10332733
Signature: t1:3138673:1461070413:4547d8b7e438035d6af73a49094c10eab725af0d
2016-04-19 16:04:42 +03:00
|
|
|
if opts.get('oncall'):
|
|
|
|
createtask(ui, repo, 'rage info: %s' % pasteurl)
|
|
|
|
else:
|
|
|
|
print('Please post your problem and the following link at'
|
|
|
|
' %s for help:\n%s'
|
|
|
|
% (ui.config('ui', 'supportcontact'), pasteurl))
|