[PATCH 1 of 4] hg: ensure the progress bar is completed when copying the store
Matt Harbison
mharbison72 at gmail.com
Sat Sep 1 06:05:30 UTC 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1535214404 14400
# Sat Aug 25 12:26:44 2018 -0400
# Node ID bcd44b97559a0150b988f812ffc28be1f7f9d452
# Parent a7e22dd31f540916e79fbf23ff9f1c5baf380c53
hg: ensure the progress bar is completed when copying the store
This is just a block indent under the context manager.
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -381,31 +381,30 @@ def copystore(ui, srcrepo, destpath):
try:
hardlink = None
topic = _('linking') if hardlink else _('copying')
- progress = ui.makeprogress(topic)
- num = 0
- srcpublishing = srcrepo.publishing()
- srcvfs = vfsmod.vfs(srcrepo.sharedpath)
- dstvfs = vfsmod.vfs(destpath)
- for f in srcrepo.store.copylist():
- if srcpublishing and f.endswith('phaseroots'):
- continue
- dstbase = os.path.dirname(f)
- if dstbase and not dstvfs.exists(dstbase):
- dstvfs.mkdir(dstbase)
- if srcvfs.exists(f):
- if f.endswith('data'):
- # 'dstbase' may be empty (e.g. revlog format 0)
- lockfile = os.path.join(dstbase, "lock")
- # lock to avoid premature writing to the target
- destlock = lock.lock(dstvfs, lockfile)
- hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
- hardlink, progress)
- num += n
- if hardlink:
- ui.debug("linked %d files\n" % num)
- else:
- ui.debug("copied %d files\n" % num)
- progress.complete()
+ with ui.makeprogress(topic) as progress:
+ num = 0
+ srcpublishing = srcrepo.publishing()
+ srcvfs = vfsmod.vfs(srcrepo.sharedpath)
+ dstvfs = vfsmod.vfs(destpath)
+ for f in srcrepo.store.copylist():
+ if srcpublishing and f.endswith('phaseroots'):
+ continue
+ dstbase = os.path.dirname(f)
+ if dstbase and not dstvfs.exists(dstbase):
+ dstvfs.mkdir(dstbase)
+ if srcvfs.exists(f):
+ if f.endswith('data'):
+ # 'dstbase' may be empty (e.g. revlog format 0)
+ lockfile = os.path.join(dstbase, "lock")
+ # lock to avoid premature writing to the target
+ destlock = lock.lock(dstvfs, lockfile)
+ hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
+ hardlink, progress)
+ num += n
+ if hardlink:
+ ui.debug("linked %d files\n" % num)
+ else:
+ ui.debug("copied %d files\n" % num)
return destlock
except: # re-raises
release(destlock)
More information about the Mercurial-devel
mailing list