comparison mercurial/revset.py @ 26587:56b2bcea2529

error: get Abort from 'error' instead of 'util' The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be confused about that and gives all the credit to 'util' instead of the hardworking 'error'. In a spirit of equity, we break the cycle of injustice and give back to 'error' the respect it deserves. And screw that 'util' poser. For great justice.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 08 Oct 2015 12:55:45 -0700
parents a024e2db4553
children ff6baf32b3ba
comparison
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
478 if curhead == bmheads[0]: 478 if curhead == bmheads[0]:
479 node = bmheads[1] 479 node = bmheads[1]
480 else: 480 else:
481 node = bmheads[0] 481 node = bmheads[0]
482 elif len(bmheads) > 2: 482 elif len(bmheads) > 2:
483 raise util.Abort(_("multiple matching bookmarks to merge - " 483 raise error.Abort(_("multiple matching bookmarks to merge - "
484 "please merge with an explicit rev or bookmark"), 484 "please merge with an explicit rev or bookmark"),
485 hint=_("run 'hg heads' to see all heads")) 485 hint=_("run 'hg heads' to see all heads"))
486 elif len(bmheads) <= 1: 486 elif len(bmheads) <= 1:
487 raise util.Abort(_("no matching bookmark to merge - " 487 raise error.Abort(_("no matching bookmark to merge - "
488 "please merge with an explicit rev or bookmark"), 488 "please merge with an explicit rev or bookmark"),
489 hint=_("run 'hg heads' to see all heads")) 489 hint=_("run 'hg heads' to see all heads"))
490 else: 490 else:
491 branch = repo[None].branch() 491 branch = repo[None].branch()
492 bheads = repo.branchheads(branch) 492 bheads = repo.branchheads(branch)
493 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] 493 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
494 494
495 if len(nbhs) > 2: 495 if len(nbhs) > 2:
496 raise util.Abort(_("branch '%s' has %d heads - " 496 raise error.Abort(_("branch '%s' has %d heads - "
497 "please merge with an explicit rev") 497 "please merge with an explicit rev")
498 % (branch, len(bheads)), 498 % (branch, len(bheads)),
499 hint=_("run 'hg heads .' to see heads")) 499 hint=_("run 'hg heads .' to see heads"))
500 500
501 parent = repo.dirstate.p1() 501 parent = repo.dirstate.p1()
502 if len(nbhs) <= 1: 502 if len(nbhs) <= 1:
503 if len(bheads) > 1: 503 if len(bheads) > 1:
504 raise util.Abort(_("heads are bookmarked - " 504 raise error.Abort(_("heads are bookmarked - "
505 "please merge with an explicit rev"), 505 "please merge with an explicit rev"),
506 hint=_("run 'hg heads' to see all heads")) 506 hint=_("run 'hg heads' to see all heads"))
507 if len(repo.heads()) > 1: 507 if len(repo.heads()) > 1:
508 raise util.Abort(_("branch '%s' has one head - " 508 raise error.Abort(_("branch '%s' has one head - "
509 "please merge with an explicit rev") 509 "please merge with an explicit rev")
510 % branch, 510 % branch,
511 hint=_("run 'hg heads' to see all heads")) 511 hint=_("run 'hg heads' to see all heads"))
512 msg, hint = _('nothing to merge'), None 512 msg, hint = _('nothing to merge'), None
513 if parent != repo.lookup(branch): 513 if parent != repo.lookup(branch):
514 hint = _("use 'hg update' instead") 514 hint = _("use 'hg update' instead")
515 raise util.Abort(msg, hint=hint) 515 raise error.Abort(msg, hint=hint)
516 516
517 if parent not in bheads: 517 if parent not in bheads:
518 raise util.Abort(_('working directory not at a head revision'), 518 raise error.Abort(_('working directory not at a head revision'),
519 hint=_("use 'hg update' or merge with an " 519 hint=_("use 'hg update' or merge with an "
520 "explicit revision")) 520 "explicit revision"))
521 if parent == nbhs[0]: 521 if parent == nbhs[0]:
522 node = nbhs[-1] 522 node = nbhs[-1]
523 else: 523 else:
719 Bundle must be specified by the -R option.""" 719 Bundle must be specified by the -R option."""
720 720
721 try: 721 try:
722 bundlerevs = repo.changelog.bundlerevs 722 bundlerevs = repo.changelog.bundlerevs
723 except AttributeError: 723 except AttributeError:
724 raise util.Abort(_("no bundle provided - specify with -R")) 724 raise error.Abort(_("no bundle provided - specify with -R"))
725 return subset & bundlerevs 725 return subset & bundlerevs
726 726
727 def checkstatus(repo, subset, pat, field): 727 def checkstatus(repo, subset, pat, field):
728 hasset = matchmod.patkind(pat) == 'set' 728 hasset = matchmod.patkind(pat) == 'set'
729 729
2667 # Do not expand raw strings 2667 # Do not expand raw strings
2668 return tree 2668 return tree
2669 alias = _getalias(aliases, tree) 2669 alias = _getalias(aliases, tree)
2670 if alias is not None: 2670 if alias is not None:
2671 if alias.error: 2671 if alias.error:
2672 raise util.Abort(alias.error) 2672 raise error.Abort(alias.error)
2673 if alias in expanding: 2673 if alias in expanding:
2674 raise error.ParseError(_('infinite expansion of revset alias "%s" ' 2674 raise error.ParseError(_('infinite expansion of revset alias "%s" '
2675 'detected') % alias.name) 2675 'detected') % alias.name)
2676 expanding.append(alias) 2676 expanding.append(alias)
2677 if alias.name not in cache: 2677 if alias.name not in cache:
2866 pos += 1 2866 pos += 1
2867 d = expr[pos] 2867 d = expr[pos]
2868 ret += listexp(list(args[arg]), d) 2868 ret += listexp(list(args[arg]), d)
2869 arg += 1 2869 arg += 1
2870 else: 2870 else:
2871 raise util.Abort('unexpected revspec format character %s' % d) 2871 raise error.Abort('unexpected revspec format character %s' % d)
2872 else: 2872 else:
2873 ret += c 2873 ret += c
2874 pos += 1 2874 pos += 1
2875 2875
2876 return ret 2876 return ret