clone: add progress support to hardlink clones (
issue3059)
--- a/mercurial/hg.py Thu Mar 19 10:24:22 2015 -0400
+++ b/mercurial/hg.py Fri Mar 13 18:28:11 2015 -0400
@@ -243,6 +243,12 @@
try:
hardlink = None
num = 0
+ closetopic = [None]
+ def prog(topic, pos):
+ if pos is None:
+ closetopic[0] = topic
+ else:
+ ui.progress(topic, pos + num)
srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
srcvfs = scmutil.vfs(srcrepo.sharedpath)
dstvfs = scmutil.vfs(destpath)
@@ -259,12 +265,16 @@
# lock to avoid premature writing to the target
destlock = lock.lock(dstvfs, lockfile)
hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
- hardlink)
+ hardlink, progress=prog)
num += n
if hardlink:
ui.debug("linked %d files\n" % num)
+ if closetopic[0]:
+ ui.progress(closetopic[0], None)
else:
ui.debug("copied %d files\n" % num)
+ if closetopic[0]:
+ ui.progress(closetopic[0], None)
return destlock
except: # re-raises
release(destlock)
--- a/tests/test-clone.t Thu Mar 19 10:24:22 2015 -0400
+++ b/tests/test-clone.t Fri Mar 13 18:28:11 2015 -0400
@@ -65,6 +65,14 @@
#if hardlink
$ hg --debug clone -U . ../c
+ linking: 1
+ linking: 2
+ linking: 3
+ linking: 4
+ linking: 5
+ linking: 6
+ linking: 7
+ linking: 8
linked 8 files
#else
$ hg --debug clone -U . ../c
--- a/tests/test-hardlinks.t Thu Mar 19 10:24:22 2015 -0400
+++ b/tests/test-hardlinks.t Fri Mar 13 18:28:11 2015 -0400
@@ -58,6 +58,13 @@
Create hardlinked clone r2:
$ hg clone -U --debug r1 r2
+ linking: 1
+ linking: 2
+ linking: 3
+ linking: 4
+ linking: 5
+ linking: 6
+ linking: 7
linked 7 files
Create non-hardlinked clone r3:
--- a/tests/test-subrepo-recursion.t Thu Mar 19 10:24:22 2015 -0400
+++ b/tests/test-subrepo-recursion.t Fri Mar 13 18:28:11 2015 -0400
@@ -342,6 +342,16 @@
cloned:
$ hg clone -U . ../empty
+ \r (no-eol) (esc)
+ linking [ <=> ] 1\r (no-eol) (esc)
+ linking [ <=> ] 2\r (no-eol) (esc)
+ linking [ <=> ] 3\r (no-eol) (esc)
+ linking [ <=> ] 4\r (no-eol) (esc)
+ linking [ <=> ] 5\r (no-eol) (esc)
+ linking [ <=> ] 6\r (no-eol) (esc)
+ linking [ <=> ] 7\r (no-eol) (esc)
+ linking [ <=> ] 8\r (no-eol) (esc)
+ \r (no-eol) (esc)
$ cd ../empty
$ hg archive --subrepos -r tip ../archive.tar.gz
\r (no-eol) (esc)
@@ -355,6 +365,16 @@
archiving [==========================================>] 3/3\r (no-eol) (esc)
\r (no-eol) (esc)
\r (no-eol) (esc)
+ linking [ <=> ] 1\r (no-eol) (esc)
+ linking [ <=> ] 2\r (no-eol) (esc)
+ linking [ <=> ] 3\r (no-eol) (esc)
+ linking [ <=> ] 4\r (no-eol) (esc)
+ linking [ <=> ] 5\r (no-eol) (esc)
+ linking [ <=> ] 6\r (no-eol) (esc)
+ linking [ <=> ] 7\r (no-eol) (esc)
+ linking [ <=> ] 8\r (no-eol) (esc)
+ \r (no-eol) (esc)
+ \r (no-eol) (esc)
archiving (foo) [ ] 0/3\r (no-eol) (esc)
archiving (foo) [ ] 0/3\r (no-eol) (esc)
archiving (foo) [===========> ] 1/3\r (no-eol) (esc)
@@ -365,6 +385,14 @@
archiving (foo) [====================================>] 3/3\r (no-eol) (esc)
\r (no-eol) (esc)
\r (no-eol) (esc)
+ linking [ <=> ] 1\r (no-eol) (esc)
+ linking [ <=> ] 2\r (no-eol) (esc)
+ linking [ <=> ] 3\r (no-eol) (esc)
+ linking [ <=> ] 4\r (no-eol) (esc)
+ linking [ <=> ] 5\r (no-eol) (esc)
+ linking [ <=> ] 6\r (no-eol) (esc)
+ \r (no-eol) (esc)
+ \r (no-eol) (esc)
archiving (foo/bar) [ ] 0/1\r (no-eol) (glob) (esc)
archiving (foo/bar) [ ] 0/1\r (no-eol) (glob) (esc)
archiving (foo/bar) [================================>] 1/1\r (no-eol) (glob) (esc)