Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHG1a07f9187831: py3: handle keyword arguments in hgext/rebase.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| yuja |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| hg, | hg, | ||||
| lock, | lock, | ||||
| merge as mergemod, | merge as mergemod, | ||||
| mergeutil, | mergeutil, | ||||
| obsolete, | obsolete, | ||||
| obsutil, | obsutil, | ||||
| patch, | patch, | ||||
| phases, | phases, | ||||
| pycompat, | |||||
| registrar, | registrar, | ||||
| repair, | repair, | ||||
| revset, | revset, | ||||
| revsetlang, | revsetlang, | ||||
| scmutil, | scmutil, | ||||
| smartset, | smartset, | ||||
| util, | util, | ||||
| ) | ) | ||||
| singletransaction = True | singletransaction = True | ||||
| Return Values: | Return Values: | ||||
| Returns 0 on success, 1 if nothing to rebase or there are | Returns 0 on success, 1 if nothing to rebase or there are | ||||
| unresolved conflicts. | unresolved conflicts. | ||||
| """ | """ | ||||
| opts = pycompat.byteskwargs(opts) | |||||
| rbsrt = rebaseruntime(repo, ui, opts) | rbsrt = rebaseruntime(repo, ui, opts) | ||||
| with repo.wlock(), repo.lock(): | with repo.wlock(), repo.lock(): | ||||
| # Validate input and define rebasing points | # Validate input and define rebasing points | ||||
| destf = opts.get('dest', None) | destf = opts.get('dest', None) | ||||
| srcf = opts.get('source', None) | srcf = opts.get('source', None) | ||||
| basef = opts.get('base', None) | basef = opts.get('base', None) | ||||
| revf = opts.get('rev', []) | revf = opts.get('rev', []) | ||||
| if fm: | if fm: | ||||
| nodechanges = {hex(oldn): [hex(n) for n in newn] | nodechanges = {hex(oldn): [hex(n) for n in newn] | ||||
| for oldn, newn in replacements.iteritems()} | for oldn, newn in replacements.iteritems()} | ||||
| fm.data(nodechanges=nodechanges) | fm.data(nodechanges=nodechanges) | ||||
| def pullrebase(orig, ui, repo, *args, **opts): | def pullrebase(orig, ui, repo, *args, **opts): | ||||
| 'Call rebase after pull if the latter has been invoked with --rebase' | 'Call rebase after pull if the latter has been invoked with --rebase' | ||||
| ret = None | ret = None | ||||
| if opts.get('rebase'): | if opts.get(r'rebase'): | ||||
| if ui.configbool('commands', 'rebase.requiredest'): | if ui.configbool('commands', 'rebase.requiredest'): | ||||
| msg = _('rebase destination required by configuration') | msg = _('rebase destination required by configuration') | ||||
| hint = _('use hg pull followed by hg rebase -d DEST') | hint = _('use hg pull followed by hg rebase -d DEST') | ||||
| raise error.Abort(msg, hint=hint) | raise error.Abort(msg, hint=hint) | ||||
| with repo.wlock(), repo.lock(): | with repo.wlock(), repo.lock(): | ||||
| if opts.get('update'): | if opts.get(r'update'): | ||||
| del opts['update'] | del opts[r'update'] | ||||
| ui.debug('--update and --rebase are not compatible, ignoring ' | ui.debug('--update and --rebase are not compatible, ignoring ' | ||||
| 'the update flag\n') | 'the update flag\n') | ||||
| cmdutil.checkunfinished(repo) | cmdutil.checkunfinished(repo) | ||||
| cmdutil.bailifchanged(repo, hint=_('cannot pull with rebase: ' | cmdutil.bailifchanged(repo, hint=_('cannot pull with rebase: ' | ||||
| 'please commit or shelve your changes first')) | 'please commit or shelve your changes first')) | ||||
| revsprepull = len(repo) | revsprepull = len(repo) | ||||
| origpostincoming = commands.postincoming | origpostincoming = commands.postincoming | ||||
| def _dummy(*args, **kwargs): | def _dummy(*args, **kwargs): | ||||
| pass | pass | ||||
| commands.postincoming = _dummy | commands.postincoming = _dummy | ||||
| try: | try: | ||||
| ret = orig(ui, repo, *args, **opts) | ret = orig(ui, repo, *args, **opts) | ||||
| finally: | finally: | ||||
| commands.postincoming = origpostincoming | commands.postincoming = origpostincoming | ||||
| revspostpull = len(repo) | revspostpull = len(repo) | ||||
| if revspostpull > revsprepull: | if revspostpull > revsprepull: | ||||
| # --rev option from pull conflict with rebase own --rev | # --rev option from pull conflict with rebase own --rev | ||||
| # dropping it | # dropping it | ||||
| if 'rev' in opts: | if r'rev' in opts: | ||||
| del opts['rev'] | del opts[r'rev'] | ||||
| # positional argument from pull conflicts with rebase's own | # positional argument from pull conflicts with rebase's own | ||||
| # --source. | # --source. | ||||
| if 'source' in opts: | if r'source' in opts: | ||||
| del opts['source'] | del opts[r'source'] | ||||
| # revsprepull is the len of the repo, not revnum of tip. | # revsprepull is the len of the repo, not revnum of tip. | ||||
| destspace = list(repo.changelog.revs(start=revsprepull)) | destspace = list(repo.changelog.revs(start=revsprepull)) | ||||
| opts['_destspace'] = destspace | opts[r'_destspace'] = destspace | ||||
| try: | try: | ||||
| rebase(ui, repo, **opts) | rebase(ui, repo, **opts) | ||||
| except error.NoMergeDestAbort: | except error.NoMergeDestAbort: | ||||
| # we can maybe update instead | # we can maybe update instead | ||||
| rev, _a, _b = destutil.destupdate(repo) | rev, _a, _b = destutil.destupdate(repo) | ||||
| if rev == repo['.'].rev(): | if rev == repo['.'].rev(): | ||||
| ui.status(_('nothing to rebase\n')) | ui.status(_('nothing to rebase\n')) | ||||
| else: | else: | ||||
| ui.status(_('nothing to rebase - updating instead\n')) | ui.status(_('nothing to rebase - updating instead\n')) | ||||
| # not passing argument to get the bare update behavior | # not passing argument to get the bare update behavior | ||||
| # with warning and trumpets | # with warning and trumpets | ||||
| commands.update(ui, repo) | commands.update(ui, repo) | ||||
| else: | else: | ||||
| if opts.get('tool'): | if opts.get(r'tool'): | ||||
| raise error.Abort(_('--tool can only be used with --rebase')) | raise error.Abort(_('--tool can only be used with --rebase')) | ||||
| ret = orig(ui, repo, *args, **opts) | ret = orig(ui, repo, *args, **opts) | ||||
| return ret | return ret | ||||
| def _filterobsoleterevs(repo, revs): | def _filterobsoleterevs(repo, revs): | ||||
| """returns a set of the obsolete revisions in revs""" | """returns a set of the obsolete revisions in revs""" | ||||
| return set(r for r in revs if repo[r].obsolete()) | return set(r for r in revs if repo[r].obsolete()) | ||||