comparison hgext/infinitepush/__init__.py @ 37198:78c2e9418278

infinitepush: drop the `--create` flag to push command The extension added a `--create` flag for creating a new bookmark on the bundlestore. This patch changes the bahviour to create a bookmark if it does not exists and removes the requirement of the `--create` and then drop the logic around the `--create` flag. Tests are changed to drop the usage of `--create` flag. Differential Revision: https://phab.mercurial-scm.org/D2107
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 09 Feb 2018 14:16:03 +0530
parents 7fa00a6f8180
children c5687ce3b411
comparison
equal deleted inserted replaced
37197:7fa00a6f8180 37198:78c2e9418278
173 default=100, 173 default=100,
174 ) 174 )
175 configitem('experimental', 'server-bundlestore-bookmark', 175 configitem('experimental', 'server-bundlestore-bookmark',
176 default='', 176 default='',
177 ) 177 )
178 configitem('experimental', 'server-bundlestore-create',
179 default='',
180 )
181 configitem('experimental', 'infinitepush-scratchpush', 178 configitem('experimental', 'infinitepush-scratchpush',
182 default=False, 179 default=False,
183 ) 180 )
184 configitem('experimental', 'non-forward-move', 181 configitem('experimental', 'non-forward-move',
185 default=False, 182 default=False,
186 ) 183 )
187 184
188 experimental = 'experimental' 185 experimental = 'experimental'
189 configbookmark = 'server-bundlestore-bookmark' 186 configbookmark = 'server-bundlestore-bookmark'
190 configcreate = 'server-bundlestore-create'
191 configscratchpush = 'infinitepush-scratchpush' 187 configscratchpush = 'infinitepush-scratchpush'
192 confignonforwardmove = 'non-forward-move' 188 confignonforwardmove = 'non-forward-move'
193 189
194 scratchbranchparttype = bundleparts.scratchbranchparttype 190 scratchbranchparttype = bundleparts.scratchbranchparttype
195 cmdtable = infinitepushcommands.cmdtable 191 cmdtable = infinitepushcommands.cmdtable
325 321
326 if not any(a for a in entry[1] if a[1] == 'non-forward-move'): 322 if not any(a for a in entry[1] if a[1] == 'non-forward-move'):
327 entry[1].append(('', 'non-forward-move', None, 323 entry[1].append(('', 'non-forward-move', None,
328 _('allows moving a remote bookmark to an ' 324 _('allows moving a remote bookmark to an '
329 'arbitrary place'))) 325 'arbitrary place')))
330
331 if not any(a for a in entry[1] if a[1] == 'create'):
332 entry[1].append(
333 ('', 'create', None, _('create a new remote bookmark')))
334 326
335 entry[1].append( 327 entry[1].append(
336 ('', 'bundle-store', None, 328 ('', 'bundle-store', None,
337 _('force push to go to bundle store (EXPERIMENTAL)'))) 329 _('force push to go to bundle store (EXPERIMENTAL)')))
338 330
750 common, inc, remoteheads = orig(*args, **kwargs) 742 common, inc, remoteheads = orig(*args, **kwargs)
751 return common, True, remoteheads 743 return common, True, remoteheads
752 744
753 def _push(orig, ui, repo, dest=None, *args, **opts): 745 def _push(orig, ui, repo, dest=None, *args, **opts):
754 bookmark = opts.get('to') or '' 746 bookmark = opts.get('to') or ''
755 create = opts.get('create') or False
756 747
757 oldphasemove = None 748 oldphasemove = None
758 overrides = {(experimental, configbookmark): bookmark, 749 overrides = {(experimental, configbookmark): bookmark}
759 (experimental, configcreate): create}
760 750
761 with ui.configoverride(overrides, 'infinitepush'): 751 with ui.configoverride(overrides, 'infinitepush'):
762 scratchpush = opts.get('bundle_store') 752 scratchpush = opts.get('bundle_store')
763 if _scratchbranchmatcher(bookmark): 753 if _scratchbranchmatcher(bookmark):
764 scratchpush = True 754 scratchpush = True
837 orig(pushop, nodes, phase) 827 orig(pushop, nodes, phase)
838 828
839 @exchange.b2partsgenerator(scratchbranchparttype) 829 @exchange.b2partsgenerator(scratchbranchparttype)
840 def partgen(pushop, bundler): 830 def partgen(pushop, bundler):
841 bookmark = pushop.ui.config(experimental, configbookmark) 831 bookmark = pushop.ui.config(experimental, configbookmark)
842 create = pushop.ui.configbool(experimental, configcreate)
843 scratchpush = pushop.ui.configbool(experimental, configscratchpush) 832 scratchpush = pushop.ui.configbool(experimental, configscratchpush)
844 if 'changesets' in pushop.stepsdone or not scratchpush: 833 if 'changesets' in pushop.stepsdone or not scratchpush:
845 return 834 return
846 835
847 if scratchbranchparttype not in bundle2.bundle2caps(pushop.remote): 836 if scratchbranchparttype not in bundle2.bundle2caps(pushop.remote):
863 scratchparts = bundleparts.getscratchbranchparts(pushop.repo, 852 scratchparts = bundleparts.getscratchbranchparts(pushop.repo,
864 pushop.remote, 853 pushop.remote,
865 pushop.outgoing, 854 pushop.outgoing,
866 nonforwardmove, 855 nonforwardmove,
867 pushop.ui, 856 pushop.ui,
868 bookmark, 857 bookmark)
869 create)
870 858
871 for scratchpart in scratchparts: 859 for scratchpart in scratchparts:
872 bundler.addpart(scratchpart) 860 bundler.addpart(scratchpart)
873 861
874 def handlereply(op): 862 def handlereply(op):
1026 bundlepath = "bundle:%s+%s" % (op.repo.root, bundlefile) 1014 bundlepath = "bundle:%s+%s" % (op.repo.root, bundlefile)
1027 bundle = hg.repository(op.repo.ui, bundlepath) 1015 bundle = hg.repository(op.repo.ui, bundlepath)
1028 1016
1029 bookmark = params.get('bookmark') 1017 bookmark = params.get('bookmark')
1030 bookprevnode = params.get('bookprevnode', '') 1018 bookprevnode = params.get('bookprevnode', '')
1031 create = params.get('create')
1032 force = params.get('force') 1019 force = params.get('force')
1033 1020
1034 if bookmark: 1021 if bookmark:
1035 oldnode = index.getnode(bookmark) 1022 oldnode = index.getnode(bookmark)
1036
1037 if not oldnode and not create:
1038 raise error.Abort("unknown bookmark %s" % bookmark,
1039 hint="use --create if you want to create one")
1040 else: 1023 else:
1041 oldnode = None 1024 oldnode = None
1042 bundleheads = bundle.revs('heads(bundle())') 1025 bundleheads = bundle.revs('heads(bundle())')
1043 if bookmark and len(bundleheads) > 1: 1026 if bookmark and len(bundleheads) > 1:
1044 raise error.Abort( 1027 raise error.Abort(
1108 finally: 1091 finally:
1109 if bundle: 1092 if bundle:
1110 bundle.close() 1093 bundle.close()
1111 1094
1112 @bundle2.parthandler(scratchbranchparttype, 1095 @bundle2.parthandler(scratchbranchparttype,
1113 ('bookmark', 'bookprevnode' 'create', 'force', 1096 ('bookmark', 'bookprevnode', 'force',
1114 'pushbackbookmarks', 'cgversion')) 1097 'pushbackbookmarks', 'cgversion'))
1115 def bundle2scratchbranch(op, part): 1098 def bundle2scratchbranch(op, part):
1116 '''unbundle a bundle2 part containing a changegroup to store''' 1099 '''unbundle a bundle2 part containing a changegroup to store'''
1117 1100
1118 bundler = bundle2.bundle20(op.repo.ui) 1101 bundler = bundle2.bundle20(op.repo.ui)