mercurial/exchange.py
changeset 20439 0d3ccf285ff2
parent 20438 2b5ab0d11327
child 20440 400da8bc7786
equal deleted inserted replaced
20438:2b5ab0d11327 20439:0d3ccf285ff2
    33         self.revs = revs
    33         self.revs = revs
    34         # allow push of new branch
    34         # allow push of new branch
    35         self.newbranch = newbranch
    35         self.newbranch = newbranch
    36         # did a local lock get acquired?
    36         # did a local lock get acquired?
    37         self.locallocked = None
    37         self.locallocked = None
       
    38         # Integer version of the push result
       
    39         # - None means nothing to push
       
    40         # - 0 means HTTP error
       
    41         # - 1 means we pushed and remote head count is unchanged *or*
       
    42         #   we have outgoing changesets but refused to push
       
    43         # - other values as described by addchangegroup()
       
    44         self.ret = None
    38 
    45 
    39 def push(repo, remote, force=False, revs=None, newbranch=False):
    46 def push(repo, remote, force=False, revs=None, newbranch=False):
    40     '''Push outgoing changesets (limited by revs) from a local
    47     '''Push outgoing changesets (limited by revs) from a local
    41     repository to remote. Return an integer:
    48     repository to remote. Return an integer:
    42       - None means nothing to push
    49       - None means nothing to push
    97 
   104 
    98 
   105 
    99             if not outgoing.missing:
   106             if not outgoing.missing:
   100                 # nothing to push
   107                 # nothing to push
   101                 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
   108                 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
   102                 ret = None
       
   103             else:
   109             else:
   104                 # something to push
   110                 # something to push
   105                 if not pushop.force:
   111                 if not pushop.force:
   106                     # if repo.obsstore == False --> no obsolete
   112                     # if repo.obsstore == False --> no obsolete
   107                     # then, save the iteration
   113                     # then, save the iteration
   154                     # commit/push race), server aborts.
   160                     # commit/push race), server aborts.
   155                     if pushop.force:
   161                     if pushop.force:
   156                         remoteheads = ['force']
   162                         remoteheads = ['force']
   157                     # ssh: return remote's addchangegroup()
   163                     # ssh: return remote's addchangegroup()
   158                     # http: return remote's addchangegroup() or 0 for error
   164                     # http: return remote's addchangegroup() or 0 for error
   159                     ret = pushop.remote.unbundle(cg, remoteheads, 'push')
   165                     pushop.ret = pushop.remote.unbundle(cg, remoteheads,
       
   166                                                         'push')
   160                 else:
   167                 else:
   161                     # we return an integer indicating remote head count
   168                     # we return an integer indicating remote head count
   162                     # change
   169                     # change
   163                     ret = pushop.remote.addchangegroup(cg, 'push',
   170                     pushop.ret = pushop.remote.addchangegroup(cg, 'push',
   164                                                        pushop.repo.url())
   171                                                               pushop.repo.url())
   165 
   172 
   166             if ret:
   173             if pushop.ret:
   167                 # push succeed, synchronize target of the push
   174                 # push succeed, synchronize target of the push
   168                 cheads = outgoing.missingheads
   175                 cheads = outgoing.missingheads
   169             elif pushop.revs is None:
   176             elif pushop.revs is None:
   170                 # All out push fails. synchronize all common
   177                 # All out push fails. synchronize all common
   171                 cheads = outgoing.commonheads
   178                 cheads = outgoing.commonheads
   195                 cheads.extend(c.node() for c in revset)
   202                 cheads.extend(c.node() for c in revset)
   196             # even when we don't push, exchanging phase data is useful
   203             # even when we don't push, exchanging phase data is useful
   197             remotephases = pushop.remote.listkeys('phases')
   204             remotephases = pushop.remote.listkeys('phases')
   198             if (pushop.ui.configbool('ui', '_usedassubrepo', False)
   205             if (pushop.ui.configbool('ui', '_usedassubrepo', False)
   199                 and remotephases    # server supports phases
   206                 and remotephases    # server supports phases
   200                 and ret is None # nothing was pushed
   207                 and pushop.ret is None # nothing was pushed
   201                 and remotephases.get('publishing', False)):
   208                 and remotephases.get('publishing', False)):
   202                 # When:
   209                 # When:
   203                 # - this is a subrepo push
   210                 # - this is a subrepo push
   204                 # - and remote support phase
   211                 # - and remote support phase
   205                 # - and no changeset was pushed
   212                 # - and no changeset was pushed
   244     finally:
   251     finally:
   245         if locallock is not None:
   252         if locallock is not None:
   246             locallock.release()
   253             locallock.release()
   247 
   254 
   248     _pushbookmark(pushop)
   255     _pushbookmark(pushop)
   249     return ret
   256     return pushop.ret
   250 
   257 
   251 def _localphasemove(pushop, nodes, phase=phases.public):
   258 def _localphasemove(pushop, nodes, phase=phases.public):
   252     """move <nodes> to <phase> in the local source repo"""
   259     """move <nodes> to <phase> in the local source repo"""
   253     if pushop.locallocked:
   260     if pushop.locallocked:
   254         phases.advanceboundary(pushop.repo, phase, nodes)
   261         phases.advanceboundary(pushop.repo, phase, nodes)