2014-11-04 10:03:09 +03:00
|
|
|
# Copyright 2014 Facebook Inc.
|
|
|
|
#
|
2017-06-15 14:20:52 +03:00
|
|
|
"""upload useful diagnostics and give instructions for asking for help
|
2014-11-04 10:03:09 +03:00
|
|
|
|
2017-06-15 14:20:52 +03:00
|
|
|
[rage]
|
|
|
|
# Name of the rpm binary
|
|
|
|
rpmbin = rpm
|
|
|
|
"""
|
|
|
|
|
|
|
|
from functools import partial
|
2014-11-04 10:03:09 +03:00
|
|
|
from mercurial.i18n import _
|
2017-03-07 12:27:12 +03:00
|
|
|
from mercurial import (
|
|
|
|
bookmarks,
|
|
|
|
commands,
|
|
|
|
debugcommands,
|
|
|
|
encoding,
|
|
|
|
error,
|
2017-05-22 23:38:37 +03:00
|
|
|
registrar,
|
2017-03-07 12:27:12 +03:00
|
|
|
util,
|
|
|
|
)
|
2017-01-03 16:59:55 +03:00
|
|
|
from mercurial import pycompat, 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,
|
2017-11-01 22:11:34 +03:00
|
|
|
fbsparse as sparse,
|
2016-07-08 15:15:42 +03:00
|
|
|
)
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
from phabricator import (
|
|
|
|
arcconfig,
|
|
|
|
conduit,
|
|
|
|
)
|
|
|
|
import os, socket, re, tempfile, time, traceback
|
2014-11-04 10:03:09 +03:00
|
|
|
|
2017-10-31 06:48:06 +03:00
|
|
|
from remotefilelog import (
|
|
|
|
constants,
|
|
|
|
shallowutil
|
|
|
|
)
|
|
|
|
|
2014-11-04 10:03:09 +03:00
|
|
|
cmdtable = {}
|
2017-05-22 23:38:37 +03:00
|
|
|
command = registrar.command(cmdtable)
|
2014-11-04 10:03:09 +03:00
|
|
|
|
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.
|
2017-01-20 17:23:56 +03:00
|
|
|
''' % (repo.root, socket.gethostname(), encoding.environ.get('LOGNAME'),
|
2017-01-03 16:59:55 +03:00
|
|
|
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]
|
2017-08-31 00:05:55 +03:00
|
|
|
ui.write(
|
2017-08-31 21:11:59 +03:00
|
|
|
_('Task created: https://our.intern.facebook.com/intern/tasks/?t=%s\n')
|
2017-08-31 00:05:55 +03:00
|
|
|
% tasknum)
|
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
|
|
|
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
|
|
|
""" """
|
2017-01-03 16:59:55 +03:00
|
|
|
for p in encoding.environ.get('PATH', '/bin').split(pycompat.ospathsep):
|
2016-05-03 18:12:06 +03:00
|
|
|
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)
|
2017-03-07 12:27:12 +03:00
|
|
|
markers = hgcmd(debugcommands.debugobsolete, rev=[])
|
2016-04-28 21:13:28 +03:00
|
|
|
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)
|
|
|
|
|
2017-06-15 14:20:52 +03:00
|
|
|
def rpminfo(ui):
|
2016-05-03 18:12:06 +03:00
|
|
|
"""FBONLY: Information about RPM packages"""
|
|
|
|
result = set()
|
2017-06-15 14:20:52 +03:00
|
|
|
rpmbin = ui.config('rage', 'rpmbin', 'rpm')
|
2016-05-03 18:12:06 +03:00
|
|
|
for name in ['hg', 'hg.real']:
|
|
|
|
path = which(name)
|
|
|
|
if not path:
|
|
|
|
continue
|
2017-06-15 14:20:52 +03:00
|
|
|
result.add(shcmd('%s -qf %s' % (rpmbin, path), check=False))
|
2016-05-03 18:12:06 +03:00
|
|
|
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)
|
2017-08-31 00:05:55 +03:00
|
|
|
try:
|
|
|
|
func(ui, _repo, *args, **opts)
|
|
|
|
finally:
|
|
|
|
return ui.popbuffer()
|
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') 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()),
|
2017-01-20 17:23:56 +03:00
|
|
|
('unixname', encoding.environ.get('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))),
|
2017-03-07 12:27:12 +03:00
|
|
|
# smartlog as the user sees it
|
|
|
|
('hg sl (filtered)', _failsafe(lambda: hgcmd(
|
|
|
|
smartlog.smartlog, template='{hsl}'))),
|
2016-09-29 21:19:52 +03:00
|
|
|
# unfiltered smartlog for recent hidden changesets
|
2017-03-07 12:27:12 +03:00
|
|
|
('hg sl (unfiltered)', _failsafe(lambda: hgcmd(
|
2017-01-24 04:56:38 +03:00
|
|
|
smartlog.smartlog, _repo=repo.unfiltered(), template='{hsl}'))),
|
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-11-25 03:23:21 +03:00
|
|
|
('hg blackbox -l60',
|
|
|
|
_failsafe(lambda: hgcmd(blackbox.blackbox, limit=60))),
|
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,
|
2017-04-11 17:19:26 +03:00
|
|
|
refresh=False, reset=False, import_rules=False,
|
|
|
|
clear_rules=False))),
|
2016-05-03 18:00:35 +03:00
|
|
|
('usechg', _failsafe(usechginfo)),
|
2017-06-15 14:20:52 +03:00
|
|
|
('rpm info', _failsafe(partial(rpminfo, ui))),
|
2017-04-19 13:18:04 +03:00
|
|
|
('klist', _failsafe(lambda: shcmd('klist', check=False))),
|
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
|
|
|
]
|
|
|
|
|
2017-10-31 06:48:06 +03:00
|
|
|
if util.safehasattr(repo, 'name'):
|
|
|
|
# Add the contents of both local and shared pack directories.
|
|
|
|
packlocs = {
|
|
|
|
'local': lambda category: shallowutil.getlocalpackpath(
|
|
|
|
repo.svfs.vfs.base, category),
|
|
|
|
'shared': lambda category: shallowutil.getcachepackpath(repo,
|
|
|
|
category),
|
|
|
|
}
|
|
|
|
|
|
|
|
for loc, getpath in packlocs.iteritems():
|
|
|
|
for category in constants.ALL_CATEGORIES:
|
|
|
|
path = getpath(category)
|
|
|
|
detailed.append((
|
|
|
|
"%s packs (%s)" % (loc, constants.getunits(category)),
|
|
|
|
"%s:\n%s" %
|
|
|
|
(path, _failsafe(lambda: shcmd("ls -lh %s" % path)))
|
|
|
|
))
|
|
|
|
|
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'):
|
2017-08-31 00:05:55 +03:00
|
|
|
ui.write('%s\n' % msg)
|
2015-12-03 05:44:42 +03:00
|
|
|
return
|
|
|
|
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
timeout = ui.configint('ssl', 'timeout', 5)
|
2017-10-19 16:03:48 +03:00
|
|
|
ca_certs = repo.ui.configpath('web', 'cacerts')
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
|
|
|
|
pasteurl = None
|
2015-03-08 22:22:25 +03:00
|
|
|
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
try:
|
|
|
|
resp = conduit.call_conduit('paste.create', {
|
|
|
|
'content': msg,
|
|
|
|
'title': 'hg rage for %s' % _failsafe(lambda: repo.root),
|
|
|
|
'language': 'hgrage'
|
2017-10-19 16:03:48 +03:00
|
|
|
}, timeout=timeout, ca_certs=ca_certs)
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
pasteurl = resp.get('uri')
|
2017-09-11 13:27:39 +03:00
|
|
|
except arcconfig.ArcConfigError:
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
ui.warn(_('arcconfig configuration problem.\n'))
|
2017-09-11 13:27:39 +03:00
|
|
|
except conduit.ClientError:
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
ui.warn(_('Error talking to phabricator.\n'))
|
2017-09-11 13:27:39 +03:00
|
|
|
except ValueError:
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
ui.warn(_('Bad response from phabricator.\n'))
|
|
|
|
|
|
|
|
if pasteurl:
|
|
|
|
if opts.get('oncall'):
|
|
|
|
createtask(ui, repo, 'rage info: %s' % pasteurl)
|
|
|
|
else:
|
|
|
|
ui.write(_('Please post your problem and the following link at'
|
|
|
|
' %s for help:\n%s\n')
|
|
|
|
% (ui.config('ui', 'supportcontact'), pasteurl))
|
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
|
|
|
else:
|
rage: use conduit instead of arc cli
Summary:
The arc cli often depends on some checked-in code. If the repo is in a bad
state (when `hg rage` is most often needed), then arc may fail to load. A
less flaky approach is to create the paste by calling conduit directly instead
of relying on the arc cli.
* The paste now has a title – it's "hg rage for path/to/repo".
* If the paste creation fails, then the rage content is saved to a temp file.
Test Plan:
Confirmed that the paste and the temp files had the `hg rage` content:
* Success:
```
$ hg rage
Please post your problem and the following link at xxx (xxx) for help:
xxx/P58168469
```
* Failures:
```
# Missing "hosts" in ~/.arcconfig:
$ hg rage
arcconfig configuration problem.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-fMVgGr
# Bad "user" in ~/.arcconfig:
$ hg rage
Error talking to phabricator.
No paste was created.
Saved contents to /var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-HeWjHA
# Off the corporate network:
$ hg rage
Bad response from phabricator.
No paste was created.
Saved contents to/var/folders/jr/_rg2cglx58z6_fnksmnlmc2w71b1w9/T/hg-rage-x4IBMT
```
Reviewers: #mercurial, medson, rmcelroy, mitrandir
Reviewed By: medson, rmcelroy, mitrandir
Subscribers: #mercurial, mitrandir, rmcelroy, medson, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D5793911
Tasks: T19966776
Signature: 5793911:1504883514:29dc2c388819ba0d570a69f97eacb77884a2f983
2017-09-09 01:11:06 +03:00
|
|
|
ui.warn(_('No paste was created.\n'))
|
|
|
|
fd, tmpname = tempfile.mkstemp(prefix='hg-rage-')
|
|
|
|
with os.fdopen(fd, r'w') as tmpfp:
|
|
|
|
tmpfp.write(msg)
|
|
|
|
ui.warn(_('Saved contents to %s\n') % tmpname)
|