comparison mercurial/exchange.py @ 20465:170f71061069

push: move outgoing check logic in its own function Now that every necessary information is held in the `pushoperation` object, we can extract the part responsible of aborting the push to it's own function. This changeset is mostly pure code movement. the exception is the fact this function returns a value to decide if changeset bundle should be pushed.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 30 Jan 2014 21:01:21 -0800
parents d032417db243
children 233623d58c9a
comparison
equal deleted inserted replaced
20464:d032417db243 20465:170f71061069
109 commoninc=commoninc, force=pushop.force) 109 commoninc=commoninc, force=pushop.force)
110 pushop.outgoing = outgoing 110 pushop.outgoing = outgoing
111 pushop.remoteheads = remoteheads 111 pushop.remoteheads = remoteheads
112 pushop.incoming = inc 112 pushop.incoming = inc
113 113
114 114 if _pushcheckoutgoing(pushop):
115 if not outgoing.missing:
116 # nothing to push
117 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
118 else:
119 # something to push
120 if not pushop.force:
121 # if repo.obsstore == False --> no obsolete
122 # then, save the iteration
123 if unfi.obsstore:
124 # this message are here for 80 char limit reason
125 mso = _("push includes obsolete changeset: %s!")
126 mst = "push includes %s changeset: %s!"
127 # plain versions for i18n tool to detect them
128 _("push includes unstable changeset: %s!")
129 _("push includes bumped changeset: %s!")
130 _("push includes divergent changeset: %s!")
131 # If we are to push if there is at least one
132 # obsolete or unstable changeset in missing, at
133 # least one of the missinghead will be obsolete or
134 # unstable. So checking heads only is ok
135 for node in outgoing.missingheads:
136 ctx = unfi[node]
137 if ctx.obsolete():
138 raise util.Abort(mso % ctx)
139 elif ctx.troubled():
140 raise util.Abort(_(mst)
141 % (ctx.troubles()[0],
142 ctx))
143 newbm = pushop.ui.configlist('bookmarks', 'pushing')
144 discovery.checkheads(unfi, pushop.remote, outgoing,
145 remoteheads, pushop.newbranch,
146 bool(pushop.incoming), newbm)
147 _pushchangeset(pushop) 115 _pushchangeset(pushop)
148 _pushsyncphase(pushop) 116 _pushsyncphase(pushop)
149 _pushobsolete(pushop) 117 _pushobsolete(pushop)
150 finally: 118 finally:
151 if lock is not None: 119 if lock is not None:
154 if locallock is not None: 122 if locallock is not None:
155 locallock.release() 123 locallock.release()
156 124
157 _pushbookmark(pushop) 125 _pushbookmark(pushop)
158 return pushop.ret 126 return pushop.ret
127
128 def _pushcheckoutgoing(pushop):
129 outgoing = pushop.outgoing
130 unfi = pushop.repo.unfiltered()
131 if not outgoing.missing:
132 # nothing to push
133 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
134 return False
135 # something to push
136 if not pushop.force:
137 # if repo.obsstore == False --> no obsolete
138 # then, save the iteration
139 if unfi.obsstore:
140 # this message are here for 80 char limit reason
141 mso = _("push includes obsolete changeset: %s!")
142 mst = "push includes %s changeset: %s!"
143 # plain versions for i18n tool to detect them
144 _("push includes unstable changeset: %s!")
145 _("push includes bumped changeset: %s!")
146 _("push includes divergent changeset: %s!")
147 # If we are to push if there is at least one
148 # obsolete or unstable changeset in missing, at
149 # least one of the missinghead will be obsolete or
150 # unstable. So checking heads only is ok
151 for node in outgoing.missingheads:
152 ctx = unfi[node]
153 if ctx.obsolete():
154 raise util.Abort(mso % ctx)
155 elif ctx.troubled():
156 raise util.Abort(_(mst)
157 % (ctx.troubles()[0],
158 ctx))
159 newbm = pushop.ui.configlist('bookmarks', 'pushing')
160 discovery.checkheads(unfi, pushop.remote, outgoing,
161 pushop.remoteheads,
162 pushop.newbranch,
163 bool(pushop.incoming),
164 newbm)
165 return True
159 166
160 def _pushchangeset(pushop): 167 def _pushchangeset(pushop):
161 """Make the actual push of changeset bundle to remote repo""" 168 """Make the actual push of changeset bundle to remote repo"""
162 outgoing = pushop.outgoing 169 outgoing = pushop.outgoing
163 unbundle = pushop.remote.capable('unbundle') 170 unbundle = pushop.remote.capable('unbundle')