sapling/hgext3rd/rage.py

303 lines
10 KiB
Python
Raw Normal View History

# Copyright 2014 Facebook Inc.
#
"""upload useful diagnostics and give instructions for asking for help
[rage]
# Name of the rpm binary
rpmbin = rpm
"""
from functools import partial
from mercurial.i18n import _
from mercurial import (
bookmarks,
commands,
debugcommands,
encoding,
error,
registrar,
util,
)
from mercurial import pycompat, scmutil
from hgext import blackbox
from hgext3rd import (
smartlog,
2017-11-01 22:11:34 +03:00
fbsparse as sparse,
)
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
rage: include contents of packdirs Example output: ``` shared packs (files): --------------------------- /var/cache/hgcache/fbsource/packs: total 64K drwxrwsr-x. 2 phillco svnuser 36K Oct 26 14:09 manifests ... shared packs (trees): --------------------------- /var/cache/hgcache/fbsource/packs/manifests: total 741M -r--r--r--. 1 phillco svnuser 1.8K Oct 9 00:37 0a0d759b468bf3766b1596d133d7dcf5c55db702.dataidx -r--r--r--. 1 phillco svnuser 77K Oct 9 00:37 0a0d759b468bf3766b1596d133d7dcf5c55db702.datapack -r--r--r--. 1 phillco svnuser 33K Oct 9 12:54 0b233c54960ad32a75238334b18bdb8176b95dae.dataidx -r--r--r--. 1 phillco svnuser 1.7M Oct 9 12:54 0b233c54960ad32a75238334b18bdb8176b95dae.datapack -r--r--r--. 1 phillco svnuser 74K Oct 8 23:40 0b33a64b257bee2583ded9d38f13404f52a33670.dataidx ... local packs (files): --------------------------- /data/users/phillco/fbsource/.hg/store/packs/: total 856K drwxrwsr-x. 2 phillco svnuser 856K Oct 26 14:14 manifests local packs (trees): --------------------------- /data/users/phillco/fbsource/.hg/store/packs/manifests: total 27M -r--r--r--. 1 phillco svnuser 1.2K Oct 3 13:37 000004931915fa871abb373503d0e8656f543d59.dataidx -r--r--r--. 1 phillco svnuser 4.4K Oct 3 13:37 000004931915fa871abb373503d0e8656f543d59.datapack -r--r--r--. 1 phillco svnuser 1.2K Oct 3 13:34 0009e3182c6268d64a3c6d9cb79ba74a0f5e3fa2.dataidx -r--r--r--. 1 phillco svnuser 3.1K Oct 3 13:34 0009e3182c6268d64a3c6d9cb79ba74a0f5e3fa2.datapack ... ``` Differential Revision: https://phab.mercurial-scm.org/D1261
2017-10-31 06:48:06 +03:00
from remotefilelog import (
constants,
shallowutil
)
cmdtable = {}
command = registrar.command(cmdtable)
_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
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
Description:
%s
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(), encoding.environ.get('LOGNAME'),
defaultdesc)
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]
ui.write(
2017-08-31 21:11:59 +03:00
_('Task created: https://our.intern.facebook.com/intern/tasks/?t=%s\n')
% tasknum)
def which(name):
""" """
for p in encoding.environ.get('PATH', '/bin').split(pycompat.ospathsep):
path = os.path.join(p, name)
if os.path.exists(path):
return path
return None
rageopts = [('p', 'preview', None,
_('print diagnostic information without doing arc paste'))]
if which('oncalls'):
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
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(debugcommands.debugobsolete, rev=[])
pat = re.compile('(^.*(?:'+hashes+').*$)', re.MULTILINE)
relevant = pat.findall(markers)
return "\n".join(relevant)
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)
def rpminfo(ui):
"""FBONLY: Information about RPM packages"""
result = set()
rpmbin = ui.config('rage', 'rpmbin', 'rpm')
for name in ['hg', 'hg.real']:
path = which(name)
if not path:
continue
result.add(shcmd('%s -qf %s' % (rpmbin, path), check=False))
return ''.join(result)
@command('^rage', rageopts , _('hg rage'))
def rage(ui, repo, *pats, **opts):
"""collect useful diagnostics for asking help from the source control team
The rage command collects useful diagnostic information.
By default, the information will be uploaded to Phabricator and
instructions about how to ask for help will be printed.
"""
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):
_repo = repo
if '_repo' in opts:
_repo = opts['_repo']
del opts['_repo']
ui.pushbuffer(error=True)
try:
func(ui, _repo, *args, **opts)
finally:
return ui.popbuffer()
if opts.get('oncall') and opts.get('preview'):
raise error.Abort('--preview and --oncall cannot be used together')
basic = [
('date', time.ctime()),
('unixname', encoding.environ.get('LOGNAME')),
('hostname', socket.gethostname()),
('repo location', _failsafe(lambda: repo.root)),
('active bookmark',
_failsafe(lambda: bookmarks._readactive(repo, repo._bookmarks))),
('hg version', _failsafe(
lambda: __import__('mercurial.__version__').__version__.version)),
('obsstore size', _failsafe(
lambda: str(repo.vfs.stat('store/obsstore').st_size))),
]
ui._colormode = None
detailed = [
('df -h', _failsafe(lambda: shcmd('df -h', check=False))),
# smartlog as the user sees it
('hg sl (filtered)', _failsafe(lambda: hgcmd(
smartlog.smartlog, template='{hsl}'))),
# unfiltered smartlog for recent hidden changesets
('hg sl (unfiltered)', _failsafe(lambda: hgcmd(
smartlog.smartlog, _repo=repo.unfiltered(), template='{hsl}'))),
('first 20 lines of "hg status"',
_failsafe(lambda:
'\n'.join(hgcmd(commands.status).splitlines()[:20]))),
('hg blackbox -l60',
_failsafe(lambda: hgcmd(blackbox.blackbox, limit=60))),
('hg summary', _failsafe(lambda: hgcmd(commands.summary))),
('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, import_rules=False,
clear_rules=False))),
('usechg', _failsafe(usechginfo)),
('rpm info', _failsafe(partial(rpminfo, ui))),
('klist', _failsafe(lambda: shcmd('klist', check=False))),
('ifconfig', _failsafe(lambda: shcmd('ifconfig'))),
('airport', _failsafe(
lambda: shcmd('/System/Library/PrivateFrameworks/Apple80211.' +
'framework/Versions/Current/Resources/airport ' +
'--getinfo', check=False))),
('hg debugobsolete <smartlog>',
_failsafe(lambda: obsoleteinfo(repo, hgcmd))),
('hg config (all)', _failsafe(lambda: hgcmd(commands.config))),
]
rage: include contents of packdirs Example output: ``` shared packs (files): --------------------------- /var/cache/hgcache/fbsource/packs: total 64K drwxrwsr-x. 2 phillco svnuser 36K Oct 26 14:09 manifests ... shared packs (trees): --------------------------- /var/cache/hgcache/fbsource/packs/manifests: total 741M -r--r--r--. 1 phillco svnuser 1.8K Oct 9 00:37 0a0d759b468bf3766b1596d133d7dcf5c55db702.dataidx -r--r--r--. 1 phillco svnuser 77K Oct 9 00:37 0a0d759b468bf3766b1596d133d7dcf5c55db702.datapack -r--r--r--. 1 phillco svnuser 33K Oct 9 12:54 0b233c54960ad32a75238334b18bdb8176b95dae.dataidx -r--r--r--. 1 phillco svnuser 1.7M Oct 9 12:54 0b233c54960ad32a75238334b18bdb8176b95dae.datapack -r--r--r--. 1 phillco svnuser 74K Oct 8 23:40 0b33a64b257bee2583ded9d38f13404f52a33670.dataidx ... local packs (files): --------------------------- /data/users/phillco/fbsource/.hg/store/packs/: total 856K drwxrwsr-x. 2 phillco svnuser 856K Oct 26 14:14 manifests local packs (trees): --------------------------- /data/users/phillco/fbsource/.hg/store/packs/manifests: total 27M -r--r--r--. 1 phillco svnuser 1.2K Oct 3 13:37 000004931915fa871abb373503d0e8656f543d59.dataidx -r--r--r--. 1 phillco svnuser 4.4K Oct 3 13:37 000004931915fa871abb373503d0e8656f543d59.datapack -r--r--r--. 1 phillco svnuser 1.2K Oct 3 13:34 0009e3182c6268d64a3c6d9cb79ba74a0f5e3fa2.dataidx -r--r--r--. 1 phillco svnuser 3.1K Oct 3 13:34 0009e3182c6268d64a3c6d9cb79ba74a0f5e3fa2.datapack ... ``` Differential Revision: https://phab.mercurial-scm.org/D1261
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)))
))
# 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()"]))),
)
msg = '\n'.join(map(format, basic)) + '\n' +\
'\n'.join(map(lambda x: format(x, False), detailed))
if _failsafeerrors:
msg += '\n' + '\n'.join(_failsafeerrors)
if opts.get('preview'):
ui.write('%s\n' % msg)
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)
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
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'
}, 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')
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'))
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'))
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))
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)