mercurial/hg.py
changeset 38380 63e6f5ae84bc
parent 37717 0664be4f0c1f
child 38753 e06a10d3b926
equal deleted inserted replaced
38379:3a7c33a2cc5e 38380:63e6f5ae84bc
   370     returns destlock
   370     returns destlock
   371     '''
   371     '''
   372     destlock = None
   372     destlock = None
   373     try:
   373     try:
   374         hardlink = None
   374         hardlink = None
       
   375         topic = _('linking') if hardlink else _('copying')
       
   376         progress = ui.makeprogress(topic)
   375         num = 0
   377         num = 0
   376         closetopic = [None]
       
   377         def prog(topic, pos):
       
   378             if pos is None:
       
   379                 closetopic[0] = topic
       
   380             else:
       
   381                 ui.progress(topic, pos + num)
       
   382         srcpublishing = srcrepo.publishing()
   378         srcpublishing = srcrepo.publishing()
   383         srcvfs = vfsmod.vfs(srcrepo.sharedpath)
   379         srcvfs = vfsmod.vfs(srcrepo.sharedpath)
   384         dstvfs = vfsmod.vfs(destpath)
   380         dstvfs = vfsmod.vfs(destpath)
   385         for f in srcrepo.store.copylist():
   381         for f in srcrepo.store.copylist():
   386             if srcpublishing and f.endswith('phaseroots'):
   382             if srcpublishing and f.endswith('phaseroots'):
   393                     # 'dstbase' may be empty (e.g. revlog format 0)
   389                     # 'dstbase' may be empty (e.g. revlog format 0)
   394                     lockfile = os.path.join(dstbase, "lock")
   390                     lockfile = os.path.join(dstbase, "lock")
   395                     # lock to avoid premature writing to the target
   391                     # lock to avoid premature writing to the target
   396                     destlock = lock.lock(dstvfs, lockfile)
   392                     destlock = lock.lock(dstvfs, lockfile)
   397                 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
   393                 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
   398                                              hardlink, progress=prog)
   394                                              hardlink, progress)
   399                 num += n
   395                 num += n
   400         if hardlink:
   396         if hardlink:
   401             ui.debug("linked %d files\n" % num)
   397             ui.debug("linked %d files\n" % num)
   402             if closetopic[0]:
       
   403                 ui.progress(closetopic[0], None)
       
   404         else:
   398         else:
   405             ui.debug("copied %d files\n" % num)
   399             ui.debug("copied %d files\n" % num)
   406             if closetopic[0]:
   400         progress.complete()
   407                 ui.progress(closetopic[0], None)
       
   408         return destlock
   401         return destlock
   409     except: # re-raises
   402     except: # re-raises
   410         release(destlock)
   403         release(destlock)
   411         raise
   404         raise
   412 
   405