@@ 121,6 121,13 @@ if util.safehasattr(registrar, 'configit
configitem(b'bugzilla', b'username', default=configitems.dynamicdefault)
+class Abort(error.Abort):
+ def __init__(self, *args, **kwargs):
+ if args and isinstance(args[0], str):
+ args[0] = args[0].encode()
+ return error.Abort.__init__(self, *args, **kwargs)
+
+
review_re = re.compile(r'[ra][=?]+(\w[^ ]+)')
BINARY_CACHE_FILENAME = ".bzexport.cache"
@@ 249,7 256,7 @@ def get_default_version(ui, api_server,
c = bzauth.load_configuration(ui, api_server, BINARY_CACHE_FILENAME)
versions = c['product'].get(product, {}).get('version')
if not versions:
- raise error.Abort(_("Product %s has no versions") % product)
+ raise Abort("Product %s has no versions" % product)
# Ugh! /configuration returns the versions in sorted order, which makes it
# impossible to determine the default. If there's something like
# "unspecified" in the list, prefer that for now, until bzapi gets fixed.
@@ 297,7 304,7 @@ def prompt_menu(ui, name, values,
if allow_none and choice == len(prompts) - 2:
return None
if choice == len(prompts) - 1:
- raise error.Abort("User requested abort while choosing %s" % name)
+ raise Abort("User requested abort while choosing %s" % name)
return values[choice]
@@ 362,7 369,7 @@ def find_users(ui, api_server, user_cach
try:
users = bz.find_users(auth, search_string)
except Exception as e:
- raise error.Abort(str(e))
+ raise Abort(str(e))
name = None
real_names = list(map(lambda user: "%s <%s>" % (user["real_name"], user["email"])
if user["real_name"] else user["email"], users["users"]))
@@ 547,12 554,12 @@ def extract_fields(text, template, templ
# Pull out the new keyword values.
m = pattern.match(text)
if not m:
- raise error.Abort("Edited form has invalid format")
+ raise Abort("Edited form has invalid format")
new_fields = fields.copy()
for field, value in zip(template_fields, m.groups()):
if value == '<required>':
- raise error.Abort("Required field %s not filled in" % (field,))
+ raise Abort("Required field %s not filled in" % field)
elif value == '<none>' or value == '':
if isinstance(fields[field], list):
new_fields[field] = []
@@ 702,7 709,7 @@ instead use it for reviewers.)'''
rev = bug = None
if opts['new']:
if len(args) > 1:
- raise error.Abort(_("Too many arguments!"))
+ raise Abort("Too many arguments!")
elif len(args) > 0:
rev = stringify(args[0])
elif len(args) < 2:
@@ 734,7 741,7 @@ instead use it for reviewers.)'''
# numbers.
bug = args[0]
if ' ' in bug:
- raise error.Abort(_("Invalid arguments. Can only pass revision and/or bug number"))
+ raise Abort("Invalid arguments. Can only pass revision and/or bug number")
ui.debug("interpreting '%s' as a bug alias. Fingers crossed.\n")
else:
# Assume a revset.
@@ 743,7 750,7 @@ instead use it for reviewers.)'''
# With zero args we'll guess at both, and if we fail we'll
# fail later.
elif len(args) > 2:
- raise error.Abort(_("Too many arguments!"))
+ raise Abort("Too many arguments!")
else:
# Just right.
rev = stringify(args[0])
@@ 1009,7 1016,7 @@ def obsolete_old_patches(ui, auth, bugid
bug_attachments = bz.get_attachments(auth, bugid)
attachments = bug_attachments['bugs'].get(bugid, [])
except Exception as e:
- raise error.Abort(e.message)
+ raise Abort(e.message)
patches = [p for p in attachments
if (p["is_patch"]
@@ 1029,7 1036,7 @@ def obsolete_old_patches(ui, auth, bugid
if not ui.config(b'bzexport', b'dry-run', False):
bz.obsolete_attachment(auth, p)
except Exception as e:
- raise error.Abort(e.message)
+ raise Abort(e.message)
return True
@@ 1040,7 1047,7 @@ def flag_type_id(ui, api_server, config_
"""
configuration = bzauth.load_configuration(ui, api_server, config_cache_filename)
if not configuration or not configuration["flag_type"]:
- raise error.Abort(_("Could not find configuration object"))
+ raise Abort("Could not find configuration object")
# Get the set of flag ids used for this product::component
prodflags = configuration['product'][product]['component'][component]['flag_type']
@@ 1049,7 1056,7 @@ def flag_type_id(ui, api_server, config_
flag_ids = [id for id in prodflags if flagdefs[str(id)]['name'] == flag_name]
if len(flag_ids) != 1:
- raise error.Abort(_("Could not find unique %s flag id") % flag_name)
+ raise Abort("Could not find unique %s flag id" % flag_name)
return flag_ids[0]
@@ 1201,7 1208,7 @@ def create_bug(ui, values, bzinfo, opts)
severity=values['SEVERITY'],
**create_opts)
except Exception as e:
- raise error.Abort(_("error creating bug: %s" % str(e)))
+ raise Abort("error creating bug: %s" % str(e))
for user in values['CC']:
ui.write(("CC'ing %s\n" % user).encode())
@@ 1286,7 1293,7 @@ def bzexport(ui, repo, *args, **opts):
if not ui.config(b'bzexport', b'dry-run', False):
bz.update_bug(auth, result['id'], params)
except Exception as e:
- raise error.Abort(e.message)
+ raise Abort(e.message)
newbug_opts_for_phexport = []
for opt in newbug_opts:
@@ 1375,7 1382,7 @@ def phexport(ui, repo, *args, **opts):
bz.update_bug(auth, result['id'], params)
except Exception as e:
import pdb; pdb.set_trace()
- raise error.Abort(str(e))
+ raise Abort(str(e))
def parse_description(ui, desc, commit_message, bug, create_new_bug,
auto_review=False):
@@ 1439,11 1446,11 @@ def parse_description(ui, desc, commit_m
def _bzexport_bugzilla(ui, repo, opts, rev, bug):
auth, api_server, bugzilla = bzinfo = bugzilla_info(ui, opts.get('ffprofile'))
if not bugzilla:
- raise error.Abort(_('not using bugzilla for this repo; set [bzexport] use-bugzilla = True'))
+ raise Abort("not using bugzilla for this repo; set [bzexport] use-bugzilla = True")
description_from_patch, contents = load_patch(ui, repo, rev, opts)
if description_from_patch is None:
- raise error.Abort(_('unable to find %s') % rev)
+ raise Abort("unable to find %s" % rev)
filename = opts['patch_id'] or patch_id(ui, repo, rev)
@@ 1495,7 1502,7 @@ def _bzexport_bugzilla(ui, repo, opts, r
search_strings.extend(values.get(key, []))
users = validate_users(ui, api_server, auth, search_strings, multi_user_prompt, 'reviewer')
if users is None:
- raise error.Abort("Invalid users")
+ raise Abort("Invalid users")
if 'REVIEWERS' in values:
values['REVIEWERS'] = select_users(users, values['REVIEWERS'])
@@ 1512,12 1519,12 @@ def _bzexport_bugzilla(ui, repo, opts, r
if bug is not None:
ui.write(("Bug %s given but creation of new bug requested.\n" % bug).encode())
if ui.prompt("Continue and create a new bug anyway? (y/n)") != "y":
- raise error.Abort("User aborted")
+ raise Abort("User aborted")
bug = create_bug(ui, values, bzinfo, opts)
else:
if bug is None:
- raise error.Abort(_("No bug number specified and no bug number "
- "listed in changeset message!"))
+ raise Abort("No bug number specified and no bug number "
+ "listed in changeset message!")
for reviewer in values['REVIEWERS']:
ui.write(("Requesting review from " + reviewer + "\n").encode())
@@ 1561,7 1568,7 @@ def _bzexport_bugzilla(ui, repo, opts, r
comment=values['ATTACHCOMMENT'],
**extra_args)
except Exception as e:
- raise error.Abort('error uploading attachment: %s' % e.message)
+ raise Abort("error uploading attachment: %s" % e.message)
attachid = result['attachments'].keys()[0]
attachment_url = parse.urljoin(bugzilla,
@@ 1612,7 1619,7 @@ def fill_values_from_opts(ui, bzinfo, in
opt_desc)
values[key] = select_users(valid_users, search_strings)
if values[key] is None:
- raise error.Abort("Invalid " + opt_name)
+ raise Abort("Invalid " + opt_name.encode())
else:
values[key] = []
@@ 1718,7 1725,7 @@ def _bzexport_moz_phab(ui, repo, opts, r
revs = scmutil.revrange(repo, [rev])
contig = scmutil.revrange(repo, ["{0}::{1}".format(revs.first(), revs.last())])
if set(revs) != set(contig):
- raise error.Abort(_("revs must be contiguous"))
+ raise Abort("revs must be contiguous")
if revs.first() == revs.last() and ":" not in rev:
span = expand_revs_to_bug_ancestors(ui, repo, revs.first(),
@@ 1807,13 1814,13 @@ def _bzexport_phabsend(ui, repo, opts, r
revs.sort()
if len(revs) > 1 and not opts['edit'] and not opts['same'] and not opts['first']:
- raise error.Abort(
- "Multiple revisions require --same, --first, or --edit")
+ raise Abort("Multiple revisions require --same, --first, or --edit")
if opts['new']:
values = edit_form(ui, repo, values, 'new_bug_template')
fill_values(values, ui, repo, api_server, finalize=True,
patchdata=contents)
+ import pdb; pdb.set_trace()
bug = create_bug(ui, values, bzinfo, opts)
values['BUGNUM'] = str(bug)
@@ 1873,11 1880,12 @@ def _bzexport_phabsend(ui, repo, opts, r
suggested_bug, _ = extract_bug_num_and_desc(p1.description().decode())
msg = "No bug given, enter bug"
if suggested_bug is not None:
- msg += " (default " + suggested_bug + ")"
+ msg += " (default " + suggested_bug + " from previous patch)"
+ suggested_bug = suggested_bug.encode()
msg += ">"
firstline = repo[rev].description().split(b'\n')[0]
ui.write(b'Patch description: ' + firstline + b'\n')
- bug = ui.prompt(msg.encode(), default=suggested_bug.encode()).decode()
+ bug = ui.prompt(msg.encode(), default=suggested_bug).decode()
values['BUGNUM'] = bug
revmap.update(maybe_update_patch(ui, repo, rev, bug, opts))
@@ 1966,7 1974,7 @@ def newbug(ui, repo, *args, **opts):
opts = strkwvals(opts)
auth, api_server, bugzilla = bzinfo = bugzilla_info(ui, opts.get('ffprofile'))
if not bugzilla:
- raise error.Abort(_('not using bugzilla for this repo; set [bzexport] use-bugzilla = True'))
+ raise Abort("not using bugzilla for this repo; set [bzexport] use-bugzilla = True")
if args:
args = [s.decode() for s in args]
@@ 1976,7 1984,7 @@ def newbug(ui, repo, *args, **opts):
if args and not opts['comment']:
opts['comment'] = args.pop(0)
if args:
- raise error.Abort(_("Too many arguments to newbug command (only title and comment may be given)"))
+ raise Abort("Too many arguments to newbug command (only title and comment may be given)")
opts['new'] = True
values = fill_values_from_opts(ui, bzinfo, {}, opts,
@@ 1991,7 1999,7 @@ def newbug(ui, repo, *args, **opts):
cc = validate_users(ui, api_server, auth, values['CC'], multi_user_prompt, 'reviewer')
if cc is None:
- raise error.Abort("Invalid users")
+ raise Abort("Invalid users")
values['CC'] = select_users(cc, values['CC'])
if opts['interactive'] and ui.prompt(_("Create bug in '%s' :: '%s' (y/n)?") %