changeset 11251:c61442f6d106

clone: print number of linked/copied files on --debug
author Adrian Buehlmann <adrian@cadifra.com>
date Mon, 31 May 2010 13:47:51 +0200
parents ac6fec2af8c8
children 56f306238256 d3ffbeae8a5a
files mercurial/hg.py mercurial/util.py
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Mon May 31 21:43:03 2010 +0200
+++ b/mercurial/hg.py	Mon May 31 13:47:51 2010 +0200
@@ -278,6 +278,7 @@
                 raise
 
             hardlink = None
+            num = 0
             for f in src_repo.store.copylist():
                 src = os.path.join(src_repo.sharedpath, f)
                 dst = os.path.join(dest_path, f)
@@ -288,7 +289,12 @@
                     if dst.endswith('data'):
                         # lock to avoid premature writing to the target
                         dest_lock = lock.lock(os.path.join(dstbase, "lock"))
-                    hardlink = util.copyfiles(src, dst, hardlink)
+                    hardlink, n = util.copyfiles(src, dst, hardlink)
+                    num += n
+            if hardlink:
+                ui.debug("linked %d files\n" % num)
+            else:
+                ui.debug("copied %d files\n" % num)
 
             # we need to re-init the repo after manually copying the data
             # into it
--- a/mercurial/util.py	Mon May 31 21:43:03 2010 +0200
+++ b/mercurial/util.py	Mon May 31 13:47:51 2010 +0200
@@ -453,12 +453,14 @@
         hardlink = (os.stat(src).st_dev ==
                     os.stat(os.path.dirname(dst)).st_dev)
 
+    num = 0
     if os.path.isdir(src):
         os.mkdir(dst)
         for name, kind in osutil.listdir(src):
             srcname = os.path.join(src, name)
             dstname = os.path.join(dst, name)
-            hardlink = copyfiles(srcname, dstname, hardlink)
+            hardlink, n = copyfiles(srcname, dstname, hardlink)
+            num += n
     else:
         if hardlink:
             try:
@@ -468,8 +470,9 @@
                 shutil.copy(src, dst)
         else:
             shutil.copy(src, dst)
+        num += 1
 
-    return hardlink
+    return hardlink, num
 
 class path_auditor(object):
     '''ensure that a filesystem path contains no banned components.