Mercurial > hg
comparison hgext/rebase.py @ 35002:1a07f9187831
py3: handle keyword arguments in hgext/rebase.py
Differential Revision: https://phab.mercurial-scm.org/D1321
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 23 Oct 2017 00:04:47 +0530 |
parents | ddf37b6b8c3d |
children | a68c3420be41 |
comparison
equal
deleted
inserted
replaced
35001:3fbc30f7b9f0 | 35002:1a07f9187831 |
---|---|
41 mergeutil, | 41 mergeutil, |
42 obsolete, | 42 obsolete, |
43 obsutil, | 43 obsutil, |
44 patch, | 44 patch, |
45 phases, | 45 phases, |
46 pycompat, | |
46 registrar, | 47 registrar, |
47 repair, | 48 repair, |
48 revset, | 49 revset, |
49 revsetlang, | 50 revsetlang, |
50 scmutil, | 51 scmutil, |
696 | 697 |
697 Returns 0 on success, 1 if nothing to rebase or there are | 698 Returns 0 on success, 1 if nothing to rebase or there are |
698 unresolved conflicts. | 699 unresolved conflicts. |
699 | 700 |
700 """ | 701 """ |
702 opts = pycompat.byteskwargs(opts) | |
701 rbsrt = rebaseruntime(repo, ui, opts) | 703 rbsrt = rebaseruntime(repo, ui, opts) |
702 | 704 |
703 with repo.wlock(), repo.lock(): | 705 with repo.wlock(), repo.lock(): |
704 # Validate input and define rebasing points | 706 # Validate input and define rebasing points |
705 destf = opts.get('dest', None) | 707 destf = opts.get('dest', None) |
1550 fm.data(nodechanges=nodechanges) | 1552 fm.data(nodechanges=nodechanges) |
1551 | 1553 |
1552 def pullrebase(orig, ui, repo, *args, **opts): | 1554 def pullrebase(orig, ui, repo, *args, **opts): |
1553 'Call rebase after pull if the latter has been invoked with --rebase' | 1555 'Call rebase after pull if the latter has been invoked with --rebase' |
1554 ret = None | 1556 ret = None |
1555 if opts.get('rebase'): | 1557 if opts.get(r'rebase'): |
1556 if ui.configbool('commands', 'rebase.requiredest'): | 1558 if ui.configbool('commands', 'rebase.requiredest'): |
1557 msg = _('rebase destination required by configuration') | 1559 msg = _('rebase destination required by configuration') |
1558 hint = _('use hg pull followed by hg rebase -d DEST') | 1560 hint = _('use hg pull followed by hg rebase -d DEST') |
1559 raise error.Abort(msg, hint=hint) | 1561 raise error.Abort(msg, hint=hint) |
1560 | 1562 |
1561 with repo.wlock(), repo.lock(): | 1563 with repo.wlock(), repo.lock(): |
1562 if opts.get('update'): | 1564 if opts.get(r'update'): |
1563 del opts['update'] | 1565 del opts[r'update'] |
1564 ui.debug('--update and --rebase are not compatible, ignoring ' | 1566 ui.debug('--update and --rebase are not compatible, ignoring ' |
1565 'the update flag\n') | 1567 'the update flag\n') |
1566 | 1568 |
1567 cmdutil.checkunfinished(repo) | 1569 cmdutil.checkunfinished(repo) |
1568 cmdutil.bailifchanged(repo, hint=_('cannot pull with rebase: ' | 1570 cmdutil.bailifchanged(repo, hint=_('cannot pull with rebase: ' |
1579 commands.postincoming = origpostincoming | 1581 commands.postincoming = origpostincoming |
1580 revspostpull = len(repo) | 1582 revspostpull = len(repo) |
1581 if revspostpull > revsprepull: | 1583 if revspostpull > revsprepull: |
1582 # --rev option from pull conflict with rebase own --rev | 1584 # --rev option from pull conflict with rebase own --rev |
1583 # dropping it | 1585 # dropping it |
1584 if 'rev' in opts: | 1586 if r'rev' in opts: |
1585 del opts['rev'] | 1587 del opts[r'rev'] |
1586 # positional argument from pull conflicts with rebase's own | 1588 # positional argument from pull conflicts with rebase's own |
1587 # --source. | 1589 # --source. |
1588 if 'source' in opts: | 1590 if r'source' in opts: |
1589 del opts['source'] | 1591 del opts[r'source'] |
1590 # revsprepull is the len of the repo, not revnum of tip. | 1592 # revsprepull is the len of the repo, not revnum of tip. |
1591 destspace = list(repo.changelog.revs(start=revsprepull)) | 1593 destspace = list(repo.changelog.revs(start=revsprepull)) |
1592 opts['_destspace'] = destspace | 1594 opts[r'_destspace'] = destspace |
1593 try: | 1595 try: |
1594 rebase(ui, repo, **opts) | 1596 rebase(ui, repo, **opts) |
1595 except error.NoMergeDestAbort: | 1597 except error.NoMergeDestAbort: |
1596 # we can maybe update instead | 1598 # we can maybe update instead |
1597 rev, _a, _b = destutil.destupdate(repo) | 1599 rev, _a, _b = destutil.destupdate(repo) |
1601 ui.status(_('nothing to rebase - updating instead\n')) | 1603 ui.status(_('nothing to rebase - updating instead\n')) |
1602 # not passing argument to get the bare update behavior | 1604 # not passing argument to get the bare update behavior |
1603 # with warning and trumpets | 1605 # with warning and trumpets |
1604 commands.update(ui, repo) | 1606 commands.update(ui, repo) |
1605 else: | 1607 else: |
1606 if opts.get('tool'): | 1608 if opts.get(r'tool'): |
1607 raise error.Abort(_('--tool can only be used with --rebase')) | 1609 raise error.Abort(_('--tool can only be used with --rebase')) |
1608 ret = orig(ui, repo, *args, **opts) | 1610 ret = orig(ui, repo, *args, **opts) |
1609 | 1611 |
1610 return ret | 1612 return ret |
1611 | 1613 |