Mercurial > hg
comparison hgext/absorb.py @ 45878:f4a218331ff4
errors: raise InputError in `hg absorb`
Differential Revision: https://phab.mercurial-scm.org/D9340
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 17 Nov 2020 16:23:57 -0800 |
parents | ac362d5a7893 |
children | 59fa3890d40a |
comparison
equal
deleted
inserted
replaced
45877:ac362d5a7893 | 45878:f4a218331ff4 |
---|---|
509 self._getline(l), | 509 self._getline(l), |
510 ) | 510 ) |
511 # run editor | 511 # run editor |
512 editedtext = self.ui.edit(editortext, b'', action=b'absorb') | 512 editedtext = self.ui.edit(editortext, b'', action=b'absorb') |
513 if not editedtext: | 513 if not editedtext: |
514 raise error.Abort(_(b'empty editor text')) | 514 raise error.InputError(_(b'empty editor text')) |
515 # parse edited result | 515 # parse edited result |
516 contents = [b''] * len(self.fctxs) | 516 contents = [b''] * len(self.fctxs) |
517 leftpadpos = 4 | 517 leftpadpos = 4 |
518 colonpos = leftpadpos + len(visiblefctxs) + 1 | 518 colonpos = leftpadpos + len(visiblefctxs) + 1 |
519 for l in mdiff.splitnewlines(editedtext): | 519 for l in mdiff.splitnewlines(editedtext): |
520 if l.startswith(b'HG:'): | 520 if l.startswith(b'HG:'): |
521 continue | 521 continue |
522 if l[colonpos - 1 : colonpos + 2] != b' : ': | 522 if l[colonpos - 1 : colonpos + 2] != b' : ': |
523 raise error.Abort(_(b'malformed line: %s') % l) | 523 raise error.InputError(_(b'malformed line: %s') % l) |
524 linecontent = l[colonpos + 2 :] | 524 linecontent = l[colonpos + 2 :] |
525 for i, ch in enumerate( | 525 for i, ch in enumerate( |
526 pycompat.bytestr(l[leftpadpos : colonpos - 1]) | 526 pycompat.bytestr(l[leftpadpos : colonpos - 1]) |
527 ): | 527 ): |
528 if ch == b'y': | 528 if ch == b'y': |
1016 """ | 1016 """ |
1017 if stack is None: | 1017 if stack is None: |
1018 limit = ui.configint(b'absorb', b'max-stack-size') | 1018 limit = ui.configint(b'absorb', b'max-stack-size') |
1019 headctx = repo[b'.'] | 1019 headctx = repo[b'.'] |
1020 if len(headctx.parents()) > 1: | 1020 if len(headctx.parents()) > 1: |
1021 raise error.Abort(_(b'cannot absorb into a merge')) | 1021 raise error.InputError(_(b'cannot absorb into a merge')) |
1022 stack = getdraftstack(headctx, limit) | 1022 stack = getdraftstack(headctx, limit) |
1023 if limit and len(stack) >= limit: | 1023 if limit and len(stack) >= limit: |
1024 ui.warn( | 1024 ui.warn( |
1025 _( | 1025 _( |
1026 b'absorb: only the recent %d changesets will ' | 1026 b'absorb: only the recent %d changesets will ' |
1027 b'be analysed\n' | 1027 b'be analysed\n' |
1028 ) | 1028 ) |
1029 % limit | 1029 % limit |
1030 ) | 1030 ) |
1031 if not stack: | 1031 if not stack: |
1032 raise error.Abort(_(b'no mutable changeset to change')) | 1032 raise error.InputError(_(b'no mutable changeset to change')) |
1033 if targetctx is None: # default to working copy | 1033 if targetctx is None: # default to working copy |
1034 targetctx = repo[None] | 1034 targetctx = repo[None] |
1035 if pats is None: | 1035 if pats is None: |
1036 pats = () | 1036 pats = () |
1037 if opts is None: | 1037 if opts is None: |