mercurial/exchange.py
changeset 20968 33d5fdd9bd99
parent 20967 984850270acb
child 20969 7a679918ee2b
equal deleted inserted replaced
20967:984850270acb 20968:33d5fdd9bd99
     3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
     3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
       
     8 import sys
     8 from i18n import _
     9 from i18n import _
     9 from node import hex, nullid
    10 from node import hex, nullid
    10 import cStringIO
    11 import cStringIO
    11 import errno
    12 import errno
    12 import util, scmutil, changegroup, base85
    13 import util, scmutil, changegroup, base85
   626             their_heads == ['hashed', heads_hash]):
   627             their_heads == ['hashed', heads_hash]):
   627         # someone else committed/pushed/unbundled while we
   628         # someone else committed/pushed/unbundled while we
   628         # were transferring data
   629         # were transferring data
   629         raise PushRaced('repository changed while %s - '
   630         raise PushRaced('repository changed while %s - '
   630                         'please try again' % context)
   631                         'please try again' % context)
       
   632 
       
   633 def unbundle(repo, cg, heads, source, url):
       
   634     """Apply a bundle to a repo.
       
   635 
       
   636     this function makes sure the repo is locked during the application and have
       
   637     mechanism to check that no push race occured between the creation of the
       
   638     bundle and its application.
       
   639 
       
   640     If the push was raced as PushRaced exception is raised."""
       
   641     r = 0
       
   642     lock = repo.lock()
       
   643     try:
       
   644         check_heads(repo, heads, 'uploading changes')
       
   645         # push can proceed
       
   646         try:
       
   647             r = changegroup.addchangegroup(repo, cg, source, url)
       
   648         except util.Abort, inst:
       
   649             # The old code we moved used sys.stderr directly.
       
   650             # We did not changed it to minise code change.
       
   651             # This need to be moved to something proper.
       
   652             # Feel free to do it.
       
   653             sys.stderr.write("abort: %s\n" % inst)
       
   654     finally:
       
   655         lock.release()
       
   656     return r