comparison mercurial/exchange.py @ 23437:94e2862dbcfb

push: elevate phase transaction to cover entire operation This patch series is intended to allow bundle2 push reply part handlers to make changes to the local repository; it has been developed in parallel with an extension that allows the server to rebase incoming changesets while applying them. Most pushes already open a transaction in order to sync phase information. This diff replaces that transaction with one that spans the entire push operation. This transaction will be used in a later patch to guard repository changes made during the reply handler.
author Eric Sumner <ericsumner@fb.com>
date Fri, 21 Nov 2014 15:06:38 -0800
parents 52db731b964d
children 743736fc7c41
comparison
equal deleted inserted replaced
23436:52db731b964d 23437:94e2862dbcfb
102 self.fallbackoutdatedphases = None 102 self.fallbackoutdatedphases = None
103 # outgoing obsmarkers 103 # outgoing obsmarkers
104 self.outobsmarkers = set() 104 self.outobsmarkers = set()
105 # outgoing bookmarks 105 # outgoing bookmarks
106 self.outbookmarks = [] 106 self.outbookmarks = []
107 # transaction manager
108 self.trmanager = None
107 109
108 @util.propertycache 110 @util.propertycache
109 def futureheads(self): 111 def futureheads(self):
110 """future remote heads if the changeset push succeeds""" 112 """future remote heads if the changeset push succeeds"""
111 return self.outgoing.missingheads 113 return self.outgoing.missingheads
202 # We do not abort the push, but just disable the local phase 204 # We do not abort the push, but just disable the local phase
203 # synchronisation. 205 # synchronisation.
204 msg = 'cannot lock source repository: %s\n' % err 206 msg = 'cannot lock source repository: %s\n' % err
205 pushop.ui.debug(msg) 207 pushop.ui.debug(msg)
206 try: 208 try:
209 if pushop.locallocked:
210 pushop.trmanager = transactionmanager(repo,
211 'push-response',
212 pushop.remote.url())
207 pushop.repo.checkpush(pushop) 213 pushop.repo.checkpush(pushop)
208 lock = None 214 lock = None
209 unbundle = pushop.remote.capable('unbundle') 215 unbundle = pushop.remote.capable('unbundle')
210 if not unbundle: 216 if not unbundle:
211 lock = pushop.remote.lock() 217 lock = pushop.remote.lock()
220 _pushobsolete(pushop) 226 _pushobsolete(pushop)
221 _pushbookmark(pushop) 227 _pushbookmark(pushop)
222 finally: 228 finally:
223 if lock is not None: 229 if lock is not None:
224 lock.release() 230 lock.release()
231 if pushop.trmanager:
232 pushop.trmanager.close()
225 finally: 233 finally:
234 if pushop.trmanager:
235 pushop.trmanager.release()
226 if locallock is not None: 236 if locallock is not None:
227 locallock.release() 237 locallock.release()
228 238
229 return pushop 239 return pushop
230 240
691 pushop.ui.warn(_('updating %s to public failed!\n') 701 pushop.ui.warn(_('updating %s to public failed!\n')
692 % newremotehead) 702 % newremotehead)
693 703
694 def _localphasemove(pushop, nodes, phase=phases.public): 704 def _localphasemove(pushop, nodes, phase=phases.public):
695 """move <nodes> to <phase> in the local source repo""" 705 """move <nodes> to <phase> in the local source repo"""
696 if pushop.locallocked: 706 if pushop.trmanager:
697 tr = pushop.repo.transaction('push-phase-sync') 707 phases.advanceboundary(pushop.repo,
698 try: 708 pushop.trmanager.transaction(),
699 phases.advanceboundary(pushop.repo, tr, phase, nodes) 709 phase,
700 tr.close() 710 nodes)
701 finally:
702 tr.release()
703 else: 711 else:
704 # repo is not locked, do not change any phases! 712 # repo is not locked, do not change any phases!
705 # Informs the user that phases should have been moved when 713 # Informs the user that phases should have been moved when
706 # applicable. 714 # applicable.
707 actualmoves = [n for n in nodes if phase < pushop.repo[n].phase()] 715 actualmoves = [n for n in nodes if phase < pushop.repo[n].phase()]