##// END OF EJS Templates
histedit: use more specific exceptions for more detailed exit codes...
Martin von Zweigbergk -
r48868:f27a8339 default
parent child Browse files
Show More
@@ -749,7 +749,7 b' def _isdirtywc(repo):'
749
749
750
750
751 def abortdirty():
751 def abortdirty():
752 raise error.Abort(
752 raise error.StateError(
753 _(b'working copy has pending changes'),
753 _(b'working copy has pending changes'),
754 hint=_(
754 hint=_(
755 b'amend, commit, or revert them and run histedit '
755 b'amend, commit, or revert them and run histedit '
@@ -1052,12 +1052,12 b' def findoutgoing(ui, repo, remote=None, '
1052
1052
1053 outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
1053 outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
1054 if not outgoing.missing:
1054 if not outgoing.missing:
1055 raise error.Abort(_(b'no outgoing ancestors'))
1055 raise error.StateError(_(b'no outgoing ancestors'))
1056 roots = list(repo.revs(b"roots(%ln)", outgoing.missing))
1056 roots = list(repo.revs(b"roots(%ln)", outgoing.missing))
1057 if len(roots) > 1:
1057 if len(roots) > 1:
1058 msg = _(b'there are ambiguous outgoing revisions')
1058 msg = _(b'there are ambiguous outgoing revisions')
1059 hint = _(b"see 'hg help histedit' for more detail")
1059 hint = _(b"see 'hg help histedit' for more detail")
1060 raise error.Abort(msg, hint=hint)
1060 raise error.StateError(msg, hint=hint)
1061 return repo[roots[0]].node()
1061 return repo[roots[0]].node()
1062
1062
1063
1063
@@ -1703,13 +1703,13 b' def _chistedit(ui, repo, freeargs, opts)'
1703 if defaultrev is not None:
1703 if defaultrev is not None:
1704 revs.append(defaultrev)
1704 revs.append(defaultrev)
1705 if len(revs) != 1:
1705 if len(revs) != 1:
1706 raise error.Abort(
1706 raise error.InputError(
1707 _(b'histedit requires exactly one ancestor revision')
1707 _(b'histedit requires exactly one ancestor revision')
1708 )
1708 )
1709
1709
1710 rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs)))
1710 rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs)))
1711 if len(rr) != 1:
1711 if len(rr) != 1:
1712 raise error.Abort(
1712 raise error.InputError(
1713 _(
1713 _(
1714 b'The specified revisions must have '
1714 b'The specified revisions must have '
1715 b'exactly one common root'
1715 b'exactly one common root'
@@ -1720,7 +1720,7 b' def _chistedit(ui, repo, freeargs, opts)'
1720 topmost = repo.dirstate.p1()
1720 topmost = repo.dirstate.p1()
1721 revs = between(repo, root, topmost, keep)
1721 revs = between(repo, root, topmost, keep)
1722 if not revs:
1722 if not revs:
1723 raise error.Abort(
1723 raise error.InputError(
1724 _(b'%s is not an ancestor of working directory') % short(root)
1724 _(b'%s is not an ancestor of working directory') % short(root)
1725 )
1725 )
1726
1726
@@ -1926,7 +1926,7 b' def _validateargs(ui, repo, freeargs, op'
1926 # blanket if mq patches are applied somewhere
1926 # blanket if mq patches are applied somewhere
1927 mq = getattr(repo, 'mq', None)
1927 mq = getattr(repo, 'mq', None)
1928 if mq and mq.applied:
1928 if mq and mq.applied:
1929 raise error.Abort(_(b'source has mq patches applied'))
1929 raise error.StateError(_(b'source has mq patches applied'))
1930
1930
1931 # basic argument incompatibility processing
1931 # basic argument incompatibility processing
1932 outg = opts.get(b'outgoing')
1932 outg = opts.get(b'outgoing')
@@ -1934,24 +1934,26 b' def _validateargs(ui, repo, freeargs, op'
1934 abort = opts.get(b'abort')
1934 abort = opts.get(b'abort')
1935 force = opts.get(b'force')
1935 force = opts.get(b'force')
1936 if force and not outg:
1936 if force and not outg:
1937 raise error.Abort(_(b'--force only allowed with --outgoing'))
1937 raise error.InputError(_(b'--force only allowed with --outgoing'))
1938 if goal == b'continue':
1938 if goal == b'continue':
1939 if any((outg, abort, revs, freeargs, rules, editplan)):
1939 if any((outg, abort, revs, freeargs, rules, editplan)):
1940 raise error.Abort(_(b'no arguments allowed with --continue'))
1940 raise error.InputError(_(b'no arguments allowed with --continue'))
1941 elif goal == b'abort':
1941 elif goal == b'abort':
1942 if any((outg, revs, freeargs, rules, editplan)):
1942 if any((outg, revs, freeargs, rules, editplan)):
1943 raise error.Abort(_(b'no arguments allowed with --abort'))
1943 raise error.InputError(_(b'no arguments allowed with --abort'))
1944 elif goal == b'edit-plan':
1944 elif goal == b'edit-plan':
1945 if any((outg, revs, freeargs)):
1945 if any((outg, revs, freeargs)):
1946 raise error.Abort(
1946 raise error.InputError(
1947 _(b'only --commands argument allowed with --edit-plan')
1947 _(b'only --commands argument allowed with --edit-plan')
1948 )
1948 )
1949 else:
1949 else:
1950 if outg:
1950 if outg:
1951 if revs:
1951 if revs:
1952 raise error.Abort(_(b'no revisions allowed with --outgoing'))
1952 raise error.InputError(
1953 _(b'no revisions allowed with --outgoing')
1954 )
1953 if len(freeargs) > 1:
1955 if len(freeargs) > 1:
1954 raise error.Abort(
1956 raise error.InputError(
1955 _(b'only one repo argument allowed with --outgoing')
1957 _(b'only one repo argument allowed with --outgoing')
1956 )
1958 )
1957 else:
1959 else:
@@ -1962,7 +1964,7 b' def _validateargs(ui, repo, freeargs, op'
1962 revs.append(defaultrev)
1964 revs.append(defaultrev)
1963
1965
1964 if len(revs) != 1:
1966 if len(revs) != 1:
1965 raise error.Abort(
1967 raise error.InputError(
1966 _(b'histedit requires exactly one ancestor revision')
1968 _(b'histedit requires exactly one ancestor revision')
1967 )
1969 )
1968
1970
@@ -1995,7 +1997,7 b' def _histedit(ui, repo, state, freeargs,'
1995 ),
1997 ),
1996 default=1,
1998 default=1,
1997 ):
1999 ):
1998 raise error.Abort(_(b'histedit cancelled\n'))
2000 raise error.CanceledError(_(b'histedit cancelled\n'))
1999 # rebuild state
2001 # rebuild state
2000 if goal == goalcontinue:
2002 if goal == goalcontinue:
2001 state.read()
2003 state.read()
@@ -2205,7 +2207,7 b' def _newhistedit(ui, repo, state, revs, '
2205 else:
2207 else:
2206 rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs)))
2208 rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs)))
2207 if len(rr) != 1:
2209 if len(rr) != 1:
2208 raise error.Abort(
2210 raise error.InputError(
2209 _(
2211 _(
2210 b'The specified revisions must have '
2212 b'The specified revisions must have '
2211 b'exactly one common root'
2213 b'exactly one common root'
@@ -2215,7 +2217,7 b' def _newhistedit(ui, repo, state, revs, '
2215
2217
2216 revs = between(repo, root, topmost, state.keep)
2218 revs = between(repo, root, topmost, state.keep)
2217 if not revs:
2219 if not revs:
2218 raise error.Abort(
2220 raise error.InputError(
2219 _(b'%s is not an ancestor of working directory') % short(root)
2221 _(b'%s is not an ancestor of working directory') % short(root)
2220 )
2222 )
2221
2223
@@ -2245,7 +2247,7 b' def _newhistedit(ui, repo, state, revs, '
2245 followcopies=False,
2247 followcopies=False,
2246 )
2248 )
2247 except error.Abort:
2249 except error.Abort:
2248 raise error.Abort(
2250 raise error.StateError(
2249 _(
2251 _(
2250 b"untracked files in working directory conflict with files in %s"
2252 b"untracked files in working directory conflict with files in %s"
2251 )
2253 )
@@ -2323,7 +2325,9 b' def between(repo, old, new, keep):'
2323 if revs and not keep:
2325 if revs and not keep:
2324 rewriteutil.precheck(repo, revs, b'edit')
2326 rewriteutil.precheck(repo, revs, b'edit')
2325 if repo.revs(b'(%ld) and merge()', revs):
2327 if repo.revs(b'(%ld) and merge()', revs):
2326 raise error.Abort(_(b'cannot edit history that contains merges'))
2328 raise error.StateError(
2329 _(b'cannot edit history that contains merges')
2330 )
2327 return pycompat.maplist(repo.changelog.node, revs)
2331 return pycompat.maplist(repo.changelog.node, revs)
2328
2332
2329
2333
@@ -93,7 +93,7 b' Run on a revision not ancestors of the c'
93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
94 $ hg histedit -r 4
94 $ hg histedit -r 4
95 abort: 08d98a8350f3 is not an ancestor of working directory
95 abort: 08d98a8350f3 is not an ancestor of working directory
96 [255]
96 [10]
97 $ hg up --quiet
97 $ hg up --quiet
98
98
99
99
@@ -290,7 +290,7 b' short hash. This tests issue3893.'
290 created new head
290 created new head
291 $ hg histedit -r 'heads(all())'
291 $ hg histedit -r 'heads(all())'
292 abort: The specified revisions must have exactly one common root
292 abort: The specified revisions must have exactly one common root
293 [255]
293 [10]
294
294
295 Test that trimming description using multi-byte characters
295 Test that trimming description using multi-byte characters
296 --------------------------------------------------------------------
296 --------------------------------------------------------------------
@@ -552,5 +552,5 b' warn the user on editing tagged commits'
552 do you want to continue (yN)? n
552 do you want to continue (yN)? n
553 abort: histedit cancelled
553 abort: histedit cancelled
554
554
555 [255]
555 [250]
556 $ cd ..
556 $ cd ..
@@ -160,7 +160,7 b' even prompt the user for rules, sidestep'
160 $ hg histedit e860deea161a
160 $ hg histedit e860deea161a
161 c: untracked file differs
161 c: untracked file differs
162 abort: untracked files in working directory conflict with files in 055a42cdd887
162 abort: untracked files in working directory conflict with files in 055a42cdd887
163 [255]
163 [20]
164
164
165 We should have detected the collision early enough we're not in a
165 We should have detected the collision early enough we're not in a
166 histedit state, and p1 is unchanged.
166 histedit state, and p1 is unchanged.
@@ -508,7 +508,7 b' Note that there is a few reordering in t'
508 $ hg ci -m 'modify wat'
508 $ hg ci -m 'modify wat'
509 $ hg histedit 050280826e04
509 $ hg histedit 050280826e04
510 abort: cannot edit history that contains merges
510 abort: cannot edit history that contains merges
511 [255]
511 [20]
512 $ cd ..
512 $ cd ..
513
513
514 Check abort behavior
514 Check abort behavior
@@ -134,7 +134,7 b' test to check number of roots in outgoin'
134 $ HGEDITOR=cat hg -q histedit --outgoing '../r'
134 $ HGEDITOR=cat hg -q histedit --outgoing '../r'
135 abort: there are ambiguous outgoing revisions
135 abort: there are ambiguous outgoing revisions
136 (see 'hg help histedit' for more detail)
136 (see 'hg help histedit' for more detail)
137 [255]
137 [20]
138
138
139 $ hg -q update -C 2
139 $ hg -q update -C 2
140 $ echo aa >> a
140 $ echo aa >> a
@@ -151,6 +151,6 b' test to check number of roots in outgoin'
151 $ HGEDITOR=cat hg -q histedit --outgoing '../r#default'
151 $ HGEDITOR=cat hg -q histedit --outgoing '../r#default'
152 abort: there are ambiguous outgoing revisions
152 abort: there are ambiguous outgoing revisions
153 (see 'hg help histedit' for more detail)
153 (see 'hg help histedit' for more detail)
154 [255]
154 [20]
155
155
156 $ cd ..
156 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now