Mercurial > public > mercurial-scm > hg
comparison mercurial/changelog.py @ 39777:b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
When catching errors in storage, we should be catching
StorageError instead of RevlogError. When throwing errors related
to storage, we shouldn't be using RevlogError unless we know
the error stemmed from revlogs. And we only reliably know that
if we're in revlog.py or are inheriting from a type defined in
revlog.py.
Differential Revision: https://phab.mercurial-scm.org/D4655
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 18 Sep 2018 16:47:09 -0700 |
parents | 5763216ba311 |
children | a3095bc47217 |
comparison
equal
deleted
inserted
replaced
39776:cb65d4b7e429 | 39777:b63dee7bd0d9 |
---|---|
511 user = user.strip() | 511 user = user.strip() |
512 # An empty username or a username with a "\n" will make the | 512 # An empty username or a username with a "\n" will make the |
513 # revision text contain two "\n\n" sequences -> corrupt | 513 # revision text contain two "\n\n" sequences -> corrupt |
514 # repository since read cannot unpack the revision. | 514 # repository since read cannot unpack the revision. |
515 if not user: | 515 if not user: |
516 raise error.RevlogError(_("empty username")) | 516 raise error.StorageError(_("empty username")) |
517 if "\n" in user: | 517 if "\n" in user: |
518 raise error.RevlogError(_("username %r contains a newline") | 518 raise error.StorageError(_("username %r contains a newline") |
519 % pycompat.bytestr(user)) | 519 % pycompat.bytestr(user)) |
520 | 520 |
521 desc = stripdesc(desc) | 521 desc = stripdesc(desc) |
522 | 522 |
523 if date: | 523 if date: |
524 parseddate = "%d %d" % dateutil.parsedate(date) | 524 parseddate = "%d %d" % dateutil.parsedate(date) |
527 if extra: | 527 if extra: |
528 branch = extra.get("branch") | 528 branch = extra.get("branch") |
529 if branch in ("default", ""): | 529 if branch in ("default", ""): |
530 del extra["branch"] | 530 del extra["branch"] |
531 elif branch in (".", "null", "tip"): | 531 elif branch in (".", "null", "tip"): |
532 raise error.RevlogError(_('the name \'%s\' is reserved') | 532 raise error.StorageError(_('the name \'%s\' is reserved') |
533 % branch) | 533 % branch) |
534 if extra: | 534 if extra: |
535 extra = encodeextra(extra) | 535 extra = encodeextra(extra) |
536 parseddate = "%s %s" % (parseddate, extra) | 536 parseddate = "%s %s" % (parseddate, extra) |
537 l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] | 537 l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] |
538 text = "\n".join(l) | 538 text = "\n".join(l) |