Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHGf083e7fd6313: infinitepush: delete the non-forward-move flag for hg push
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| indygreg |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/infinitepush/__init__.py (21 lines) | |||
| M | hgext/infinitepush/bundleparts.py (5 lines) | |||
| M | tests/test-infinitepush-bundlestore.t (8 lines) |
| default='', | default='', | ||||
| ) | ) | ||||
| configitem('experimental', 'server-bundlestore-bookmark', | configitem('experimental', 'server-bundlestore-bookmark', | ||||
| default='', | default='', | ||||
| ) | ) | ||||
| configitem('experimental', 'infinitepush-scratchpush', | configitem('experimental', 'infinitepush-scratchpush', | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| configitem('experimental', 'non-forward-move', | |||||
| default=False, | |||||
| ) | |||||
| experimental = 'experimental' | experimental = 'experimental' | ||||
| configbookmark = 'server-bundlestore-bookmark' | configbookmark = 'server-bundlestore-bookmark' | ||||
| configscratchpush = 'infinitepush-scratchpush' | configscratchpush = 'infinitepush-scratchpush' | ||||
| confignonforwardmove = 'non-forward-move' | |||||
| scratchbranchparttype = bundleparts.scratchbranchparttype | scratchbranchparttype = bundleparts.scratchbranchparttype | ||||
| cmdtable = infinitepushcommands.cmdtable | cmdtable = infinitepushcommands.cmdtable | ||||
| revsetpredicate = registrar.revsetpredicate() | revsetpredicate = registrar.revsetpredicate() | ||||
| templatekeyword = registrar.templatekeyword() | templatekeyword = registrar.templatekeyword() | ||||
| _scratchbranchmatcher = lambda x: False | _scratchbranchmatcher = lambda x: False | ||||
| _maybehash = re.compile(r'^[a-f0-9]+$').search | _maybehash = re.compile(r'^[a-f0-9]+$').search | ||||
| _lookupwrap(wireproto.commands['lookup'][0]), 'key') | _lookupwrap(wireproto.commands['lookup'][0]), 'key') | ||||
| extensions.wrapfunction(exchange, 'getbundlechunks', getbundlechunks) | extensions.wrapfunction(exchange, 'getbundlechunks', getbundlechunks) | ||||
| extensions.wrapfunction(bundle2, 'processparts', processparts) | extensions.wrapfunction(bundle2, 'processparts', processparts) | ||||
| def clientextsetup(ui): | def clientextsetup(ui): | ||||
| entry = extensions.wrapcommand(commands.table, 'push', _push) | entry = extensions.wrapcommand(commands.table, 'push', _push) | ||||
| if not any(a for a in entry[1] if a[1] == 'non-forward-move'): | |||||
| entry[1].append(('', 'non-forward-move', None, | |||||
| _('allows moving a remote bookmark to an ' | |||||
| 'arbitrary place'))) | |||||
| entry[1].append( | entry[1].append( | ||||
| ('', 'bundle-store', None, | ('', 'bundle-store', None, | ||||
| _('force push to go to bundle store (EXPERIMENTAL)'))) | _('force push to go to bundle store (EXPERIMENTAL)'))) | ||||
| extensions.wrapcommand(commands.table, 'pull', _pull) | extensions.wrapcommand(commands.table, 'pull', _pull) | ||||
| extensions.wrapfunction(discovery, 'checkheads', _checkheads) | extensions.wrapfunction(discovery, 'checkheads', _checkheads) | ||||
| with ui.configoverride(overrides, 'infinitepush'): | with ui.configoverride(overrides, 'infinitepush'): | ||||
| scratchpush = opts.get('bundle_store') | scratchpush = opts.get('bundle_store') | ||||
| if _scratchbranchmatcher(bookmark): | if _scratchbranchmatcher(bookmark): | ||||
| scratchpush = True | scratchpush = True | ||||
| # bundle2 can be sent back after push (for example, bundle2 | # bundle2 can be sent back after push (for example, bundle2 | ||||
| # containing `pushkey` part to update bookmarks) | # containing `pushkey` part to update bookmarks) | ||||
| ui.setconfig(experimental, 'bundle2.pushback', True) | ui.setconfig(experimental, 'bundle2.pushback', True) | ||||
| ui.setconfig(experimental, confignonforwardmove, | |||||
| opts.get('non_forward_move'), '--non-forward-move') | |||||
| if scratchpush: | if scratchpush: | ||||
| # this is an infinitepush, we don't want the bookmark to be applied | # this is an infinitepush, we don't want the bookmark to be applied | ||||
| # rather that should be stored in the bundlestore | # rather that should be stored in the bundlestore | ||||
| opts['bookmark'] = [] | opts['bookmark'] = [] | ||||
| ui.setconfig(experimental, configscratchpush, True) | ui.setconfig(experimental, configscratchpush, True) | ||||
| oldphasemove = extensions.wrapfunction(exchange, | oldphasemove = extensions.wrapfunction(exchange, | ||||
| '_localphasemove', | '_localphasemove', | ||||
| _phasemove) | _phasemove) | ||||
| pushop.cgresult = 0 | pushop.cgresult = 0 | ||||
| return | return | ||||
| # This parameter tells the server that the following bundle is an | # This parameter tells the server that the following bundle is an | ||||
| # infinitepush. This let's it switch the part processing to our infinitepush | # infinitepush. This let's it switch the part processing to our infinitepush | ||||
| # code path. | # code path. | ||||
| bundler.addparam("infinitepush", "True") | bundler.addparam("infinitepush", "True") | ||||
| nonforwardmove = pushop.force or pushop.ui.configbool(experimental, | |||||
| confignonforwardmove) | |||||
| scratchparts = bundleparts.getscratchbranchparts(pushop.repo, | scratchparts = bundleparts.getscratchbranchparts(pushop.repo, | ||||
| pushop.remote, | pushop.remote, | ||||
| pushop.outgoing, | pushop.outgoing, | ||||
| nonforwardmove, | |||||
| pushop.ui, | pushop.ui, | ||||
| bookmark) | bookmark) | ||||
| for scratchpart in scratchparts: | for scratchpart in scratchparts: | ||||
| bundler.addpart(scratchpart) | bundler.addpart(scratchpart) | ||||
| def handlereply(op): | def handlereply(op): | ||||
| # server either succeeds or aborts; no code to read | # server either succeeds or aborts; no code to read | ||||
| # new bookmark | # new bookmark | ||||
| if oldnode is None: | if oldnode is None: | ||||
| return revs | return revs | ||||
| # Fast forward update | # Fast forward update | ||||
| if oldnode in bundle and list(bundle.set('bundle() & %s::', oldnode)): | if oldnode in bundle and list(bundle.set('bundle() & %s::', oldnode)): | ||||
| return revs | return revs | ||||
| # Forced non-fast forward update | |||||
| if force: | |||||
| return revs | return revs | ||||
| else: | |||||
| raise error.Abort(_('non-forward push'), | |||||
| hint=_('use --non-forward-move to override')) | |||||
| @contextlib.contextmanager | @contextlib.contextmanager | ||||
| def logservicecall(logger, service, **kwargs): | def logservicecall(logger, service, **kwargs): | ||||
| start = time.time() | start = time.time() | ||||
| logger(service, eventtype='start', **kwargs) | logger(service, eventtype='start', **kwargs) | ||||
| try: | try: | ||||
| yield | yield | ||||
| logger(service, eventtype='success', | logger(service, eventtype='success', | ||||
| ) | ) | ||||
| from . import common | from . import common | ||||
| isremotebooksenabled = common.isremotebooksenabled | isremotebooksenabled = common.isremotebooksenabled | ||||
| scratchbranchparttype = 'b2x:infinitepush' | scratchbranchparttype = 'b2x:infinitepush' | ||||
| def getscratchbranchparts(repo, peer, outgoing, confignonforwardmove, | def getscratchbranchparts(repo, peer, outgoing, ui, bookmark): | ||||
| ui, bookmark): | |||||
| if not outgoing.missing: | if not outgoing.missing: | ||||
| raise error.Abort(_('no commits to push')) | raise error.Abort(_('no commits to push')) | ||||
| if scratchbranchparttype not in bundle2.bundle2caps(peer): | if scratchbranchparttype not in bundle2.bundle2caps(peer): | ||||
| raise error.Abort(_('no server support for %r') % scratchbranchparttype) | raise error.Abort(_('no server support for %r') % scratchbranchparttype) | ||||
| _validaterevset(repo, revsetlang.formatspec('%ln', outgoing.missing), | _validaterevset(repo, revsetlang.formatspec('%ln', outgoing.missing), | ||||
| bookmark) | bookmark) | ||||
| params = {} | params = {} | ||||
| params['cgversion'] = cgversion | params['cgversion'] = cgversion | ||||
| if bookmark: | if bookmark: | ||||
| params['bookmark'] = bookmark | params['bookmark'] = bookmark | ||||
| # 'prevbooknode' is necessary for pushkey reply part | # 'prevbooknode' is necessary for pushkey reply part | ||||
| params['bookprevnode'] = '' | params['bookprevnode'] = '' | ||||
| if bookmark in repo: | if bookmark in repo: | ||||
| params['bookprevnode'] = repo[bookmark].hex() | params['bookprevnode'] = repo[bookmark].hex() | ||||
| if confignonforwardmove: | |||||
| params['force'] = '1' | |||||
| # Do not send pushback bundle2 part with bookmarks if remotenames extension | # Do not send pushback bundle2 part with bookmarks if remotenames extension | ||||
| # is enabled. It will be handled manually in `_push()` | # is enabled. It will be handled manually in `_push()` | ||||
| if not isremotebooksenabled(ui): | if not isremotebooksenabled(ui): | ||||
| params['pushbackbookmarks'] = '1' | params['pushbackbookmarks'] = '1' | ||||
| parts = [] | parts = [] | ||||
| $ scratchbookmarks | $ scratchbookmarks | ||||
| scratch/anotherbranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 | scratch/anotherbranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 | ||||
| scratch/mybranch 6c10d49fe92751666c40263f96721b918170d3da | scratch/mybranch 6c10d49fe92751666c40263f96721b918170d3da | ||||
| $ hg push -r . -B scratch/mybranch | $ hg push -r . -B scratch/mybranch | ||||
| pushing to ssh://user@dummy/repo | pushing to ssh://user@dummy/repo | ||||
| searching for changes | searching for changes | ||||
| remote: non-forward push | |||||
| remote: (use --non-forward-move to override) | |||||
| abort: push failed on remote | |||||
| [255] | |||||
| $ hg push -r . -B scratch/mybranch --non-forward-move | |||||
| pushing to ssh://user@dummy/repo | |||||
| searching for changes | |||||
| remote: pushing 5 commits: | remote: pushing 5 commits: | ||||
| remote: 20759b6926ce scratchcommit | remote: 20759b6926ce scratchcommit | ||||
| remote: 1de1d7d92f89 new scratch commit | remote: 1de1d7d92f89 new scratch commit | ||||
| remote: 2b5d271c7e0d scratchcommitnobook | remote: 2b5d271c7e0d scratchcommitnobook | ||||
| remote: d8c4f54ab678 scratchcommitwithpushrebase | remote: d8c4f54ab678 scratchcommitwithpushrebase | ||||
| remote: 8872775dd97a scratch amended commit | remote: 8872775dd97a scratch amended commit | ||||
| $ scratchbookmarks | $ scratchbookmarks | ||||
| scratch/anotherbranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 | scratch/anotherbranch 1de1d7d92f8965260391d0513fe8a8d5973d3042 | ||||