Mercurial > hg
comparison hgext/rebase.py @ 47459:de54d11040e7
rebase: keep str-keyed opts long enough to make `action` a str
This is just another little py3 cleanup.
Differential Revision: https://phab.mercurial-scm.org/D10891
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 21 Jun 2021 09:54:36 -0700 |
parents | ba6881c6a178 |
children | c9cedb546262 |
comparison
equal
deleted
inserted
replaced
47458:50cd14dbd3b3 | 47459:de54d11040e7 |
---|---|
1061 | 1061 |
1062 Returns 0 on success, 1 if nothing to rebase or there are | 1062 Returns 0 on success, 1 if nothing to rebase or there are |
1063 unresolved conflicts. | 1063 unresolved conflicts. |
1064 | 1064 |
1065 """ | 1065 """ |
1066 opts = pycompat.byteskwargs(opts) | |
1067 inmemory = ui.configbool(b'rebase', b'experimental.inmemory') | 1066 inmemory = ui.configbool(b'rebase', b'experimental.inmemory') |
1068 action = cmdutil.check_at_most_one_arg(opts, b'abort', b'stop', b'continue') | 1067 action = cmdutil.check_at_most_one_arg(opts, 'abort', 'stop', 'continue') |
1069 if action: | 1068 if action: |
1070 cmdutil.check_incompatible_arguments( | 1069 cmdutil.check_incompatible_arguments( |
1071 opts, action, [b'confirm', b'dry_run'] | 1070 opts, action, ['confirm', 'dry_run'] |
1072 ) | 1071 ) |
1073 cmdutil.check_incompatible_arguments( | 1072 cmdutil.check_incompatible_arguments( |
1074 opts, action, [b'rev', b'source', b'base', b'dest'] | 1073 opts, action, ['rev', 'source', 'base', 'dest'] |
1075 ) | 1074 ) |
1076 cmdutil.check_at_most_one_arg(opts, b'confirm', b'dry_run') | 1075 cmdutil.check_at_most_one_arg(opts, 'confirm', 'dry_run') |
1077 cmdutil.check_at_most_one_arg(opts, b'rev', b'source', b'base') | 1076 cmdutil.check_at_most_one_arg(opts, 'rev', 'source', 'base') |
1078 | 1077 |
1079 if action or repo.currenttransaction() is not None: | 1078 if action or repo.currenttransaction() is not None: |
1080 # in-memory rebase is not compatible with resuming rebases. | 1079 # in-memory rebase is not compatible with resuming rebases. |
1081 # (Or if it is run within a transaction, since the restart logic can | 1080 # (Or if it is run within a transaction, since the restart logic can |
1082 # fail the entire transaction.) | 1081 # fail the entire transaction.) |
1083 inmemory = False | 1082 inmemory = False |
1084 | 1083 |
1085 if opts.get(b'auto_orphans'): | 1084 if opts.get('auto_orphans'): |
1086 disallowed_opts = set(opts) - {b'auto_orphans'} | 1085 disallowed_opts = set(opts) - {'auto_orphans'} |
1087 cmdutil.check_incompatible_arguments( | 1086 cmdutil.check_incompatible_arguments( |
1088 opts, b'auto_orphans', disallowed_opts | 1087 opts, 'auto_orphans', disallowed_opts |
1089 ) | 1088 ) |
1090 | 1089 |
1091 userrevs = list(repo.revs(opts.get(b'auto_orphans'))) | 1090 userrevs = list(repo.revs(opts.get('auto_orphans'))) |
1092 opts[b'rev'] = [revsetlang.formatspec(b'%ld and orphan()', userrevs)] | 1091 opts['rev'] = [revsetlang.formatspec(b'%ld and orphan()', userrevs)] |
1093 opts[b'dest'] = b'_destautoorphanrebase(SRC)' | 1092 opts['dest'] = b'_destautoorphanrebase(SRC)' |
1094 | 1093 |
1094 opts = pycompat.byteskwargs(opts) | |
1095 if opts.get(b'dry_run') or opts.get(b'confirm'): | 1095 if opts.get(b'dry_run') or opts.get(b'confirm'): |
1096 return _dryrunrebase(ui, repo, action, opts) | 1096 return _dryrunrebase(ui, repo, action, opts) |
1097 elif action == b'stop': | 1097 elif action == 'stop': |
1098 rbsrt = rebaseruntime(repo, ui) | 1098 rbsrt = rebaseruntime(repo, ui) |
1099 with repo.wlock(), repo.lock(): | 1099 with repo.wlock(), repo.lock(): |
1100 rbsrt.restorestatus() | 1100 rbsrt.restorestatus() |
1101 if rbsrt.collapsef: | 1101 if rbsrt.collapsef: |
1102 raise error.StateError(_(b"cannot stop in --collapse session")) | 1102 raise error.StateError(_(b"cannot stop in --collapse session")) |
1208 rbsrt = rebaseruntime(repo, ui, inmemory, opts=opts) | 1208 rbsrt = rebaseruntime(repo, ui, inmemory, opts=opts) |
1209 return _origrebase(ui, repo, action, opts, rbsrt) | 1209 return _origrebase(ui, repo, action, opts, rbsrt) |
1210 | 1210 |
1211 | 1211 |
1212 def _origrebase(ui, repo, action, opts, rbsrt): | 1212 def _origrebase(ui, repo, action, opts, rbsrt): |
1213 assert action != b'stop' | 1213 assert action != 'stop' |
1214 with repo.wlock(), repo.lock(): | 1214 with repo.wlock(), repo.lock(): |
1215 if opts.get(b'interactive'): | 1215 if opts.get(b'interactive'): |
1216 try: | 1216 try: |
1217 if extensions.find(b'histedit'): | 1217 if extensions.find(b'histedit'): |
1218 enablehistedit = b'' | 1218 enablehistedit = b'' |
1236 if action: | 1236 if action: |
1237 if rbsrt.collapsef: | 1237 if rbsrt.collapsef: |
1238 raise error.InputError( | 1238 raise error.InputError( |
1239 _(b'cannot use collapse with continue or abort') | 1239 _(b'cannot use collapse with continue or abort') |
1240 ) | 1240 ) |
1241 if action == b'abort' and opts.get(b'tool', False): | 1241 if action == 'abort' and opts.get(b'tool', False): |
1242 ui.warn(_(b'tool option will be ignored\n')) | 1242 ui.warn(_(b'tool option will be ignored\n')) |
1243 if action == b'continue': | 1243 if action == 'continue': |
1244 ms = mergestatemod.mergestate.read(repo) | 1244 ms = mergestatemod.mergestate.read(repo) |
1245 mergeutil.checkunresolved(ms) | 1245 mergeutil.checkunresolved(ms) |
1246 | 1246 |
1247 retcode = rbsrt._prepareabortorcontinue( | 1247 retcode = rbsrt._prepareabortorcontinue(isabort=(action == 'abort')) |
1248 isabort=(action == b'abort') | |
1249 ) | |
1250 if retcode is not None: | 1248 if retcode is not None: |
1251 return retcode | 1249 return retcode |
1252 else: | 1250 else: |
1253 # search default destination in this space | 1251 # search default destination in this space |
1254 # used in the 'hg pull --rebase' case, see issue 5214. | 1252 # used in the 'hg pull --rebase' case, see issue 5214. |