comparison mercurial/scmutil.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 366d489295ca
children 88c4e97b9669
comparison
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
121 121
122 def checknewlabel(repo, lbl, kind): 122 def checknewlabel(repo, lbl, kind):
123 # Do not use the "kind" parameter in ui output. 123 # Do not use the "kind" parameter in ui output.
124 # It makes strings difficult to translate. 124 # It makes strings difficult to translate.
125 if lbl in ['tip', '.', 'null']: 125 if lbl in ['tip', '.', 'null']:
126 raise util.Abort(_("the name '%s' is reserved") % lbl) 126 raise error.Abort(_("the name '%s' is reserved") % lbl)
127 for c in (':', '\0', '\n', '\r'): 127 for c in (':', '\0', '\n', '\r'):
128 if c in lbl: 128 if c in lbl:
129 raise util.Abort(_("%r cannot be used in a name") % c) 129 raise error.Abort(_("%r cannot be used in a name") % c)
130 try: 130 try:
131 int(lbl) 131 int(lbl)
132 raise util.Abort(_("cannot use an integer as a name")) 132 raise error.Abort(_("cannot use an integer as a name"))
133 except ValueError: 133 except ValueError:
134 pass 134 pass
135 135
136 def checkfilename(f): 136 def checkfilename(f):
137 '''Check that the filename f is an acceptable filename for a tracked file''' 137 '''Check that the filename f is an acceptable filename for a tracked file'''
138 if '\r' in f or '\n' in f: 138 if '\r' in f or '\n' in f:
139 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) 139 raise error.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f)
140 140
141 def checkportable(ui, f): 141 def checkportable(ui, f):
142 '''Check if filename f is portable and warn or abort depending on config''' 142 '''Check if filename f is portable and warn or abort depending on config'''
143 checkfilename(f) 143 checkfilename(f)
144 abort, warn = checkportabilityalert(ui) 144 abort, warn = checkportabilityalert(ui)
145 if abort or warn: 145 if abort or warn:
146 msg = util.checkwinfilename(f) 146 msg = util.checkwinfilename(f)
147 if msg: 147 if msg:
148 msg = "%s: %r" % (msg, f) 148 msg = "%s: %r" % (msg, f)
149 if abort: 149 if abort:
150 raise util.Abort(msg) 150 raise error.Abort(msg)
151 ui.warn(_("warning: %s\n") % msg) 151 ui.warn(_("warning: %s\n") % msg)
152 152
153 def checkportabilityalert(ui): 153 def checkportabilityalert(ui):
154 '''check if the user's config requests nothing, a warning, or abort for 154 '''check if the user's config requests nothing, a warning, or abort for
155 non-portable filenames''' 155 non-portable filenames'''
180 return 180 return
181 fl = encoding.lower(f) 181 fl = encoding.lower(f)
182 if fl in self._loweredfiles and f not in self._dirstate: 182 if fl in self._loweredfiles and f not in self._dirstate:
183 msg = _('possible case-folding collision for %s') % f 183 msg = _('possible case-folding collision for %s') % f
184 if self._abort: 184 if self._abort:
185 raise util.Abort(msg) 185 raise error.Abort(msg)
186 self._ui.warn(_("warning: %s\n") % msg) 186 self._ui.warn(_("warning: %s\n") % msg)
187 self._loweredfiles.add(fl) 187 self._loweredfiles.add(fl)
188 self._newfiles.add(f) 188 self._newfiles.add(f)
189 189
190 def filteredhash(repo, maxrev): 190 def filteredhash(repo, maxrev):
473 for "write" mode access. 473 for "write" mode access.
474 ''' 474 '''
475 if self._audit: 475 if self._audit:
476 r = util.checkosfilename(path) 476 r = util.checkosfilename(path)
477 if r: 477 if r:
478 raise util.Abort("%s: %r" % (r, path)) 478 raise error.Abort("%s: %r" % (r, path))
479 self.audit(path) 479 self.audit(path)
480 f = self.join(path) 480 f = self.join(path)
481 481
482 if not text and "b" not in mode: 482 if not text and "b" not in mode:
483 mode += "b" # for that other OS 483 mode += "b" # for that other OS
581 def __init__(self, vfs): 581 def __init__(self, vfs):
582 auditvfs.__init__(self, vfs) 582 auditvfs.__init__(self, vfs)
583 583
584 def __call__(self, path, mode='r', *args, **kw): 584 def __call__(self, path, mode='r', *args, **kw):
585 if mode not in ('r', 'rb'): 585 if mode not in ('r', 'rb'):
586 raise util.Abort('this vfs is read only') 586 raise error.Abort('this vfs is read only')
587 return self.vfs(path, mode, *args, **kw) 587 return self.vfs(path, mode, *args, **kw)
588 588
589 def join(self, path, *insidef): 589 def join(self, path, *insidef):
590 return self.vfs.join(path, *insidef) 590 return self.vfs.join(path, *insidef)
591 591
687 if not revspec and revspec != 0: 687 if not revspec and revspec != 0:
688 return repo[default] 688 return repo[default]
689 689
690 l = revrange(repo, [revspec]) 690 l = revrange(repo, [revspec])
691 if not l: 691 if not l:
692 raise util.Abort(_('empty revision set')) 692 raise error.Abort(_('empty revision set'))
693 return repo[l.last()] 693 return repo[l.last()]
694 694
695 def _pairspec(revspec): 695 def _pairspec(revspec):
696 tree = revset.parse(revspec) 696 tree = revset.parse(revspec)
697 tree = revset.optimize(tree, True)[1] # fix up "x^:y" -> "(x^):y" 697 tree = revset.optimize(tree, True)[1] # fix up "x^:y" -> "(x^):y"
714 else: 714 else:
715 first = l.first() 715 first = l.first()
716 second = l.last() 716 second = l.last()
717 717
718 if first is None: 718 if first is None:
719 raise util.Abort(_('empty revision range')) 719 raise error.Abort(_('empty revision range'))
720 720
721 # if top-level is range expression, the result must always be a pair 721 # if top-level is range expression, the result must always be a pair
722 if first == second and len(revs) == 1 and not _pairspec(revs[0]): 722 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
723 return repo.lookup(first), None 723 return repo.lookup(first), None
724 724