Patchwork [2,of,2,issue3059] clone: add progress support to hardlink clones (issue3059)

login
register
mail settings
Submitter Augie Fackler
Date March 14, 2015, 12:02 a.m.
Message ID <71028509667d91a7918d.1426291326@106.17.16.172.in-addr.arpa>
Download mbox | patch
Permalink /patch/8077/
State Superseded
Headers show

Comments

Augie Fackler - March 14, 2015, 12:02 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1426285691 14400
#      Fri Mar 13 18:28:11 2015 -0400
# Node ID 71028509667d91a7918dcc87d88ffc8636d44d2d
# Parent  1eae0d483e9f5cf412fa72a481fe641b78d0b248
clone: add progress support to hardlink clones (issue3059)
Martin von Zweigbergk - March 14, 2015, 4:36 a.m.
On Fri, Mar 13, 2015 at 5:02 PM Augie Fackler <raf@durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1426285691 14400
> #      Fri Mar 13 18:28:11 2015 -0400
> # Node ID 71028509667d91a7918dcc87d88ffc8636d44d2d
> # Parent  1eae0d483e9f5cf412fa72a481fe641b78d0b248
> clone: add progress support to hardlink clones (issue3059)
>
> diff --git a/mercurial/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -242,6 +242,8 @@ def copystore(ui, srcrepo, destpath):
>          srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
>          srcvfs = scmutil.vfs(srcrepo.sharedpath)
>          dstvfs = scmutil.vfs(destpath)
> +        def prog(topic, pos):
> +            ui.progress(topic, pos + num)
>          for f in srcrepo.store.copylist():
>              if srcpublishing and f.endswith('phaseroots'):
>                  continue
> @@ -255,12 +257,14 @@ def copystore(ui, srcrepo, destpath):
>                      # 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)
> +            ui.progress(_("linking"), None)
>          else:
>              ui.debug("copied %d files\n" % num)
> +            ui.progress(_("copying"), None)
>          return destlock
>      except: # re-raises
>          release(destlock)
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -746,9 +746,9 @@ def copyfiles(src, dst, hardlink=None, p
>          hardlink = (os.stat(src).st_dev ==
>                      os.stat(os.path.dirname(dst)).st_dev)
>      if hardlink:
> -        topic = 'linking'
> +        topic = _("linking")
>      else:
> -        topic = 'copying'
> +        topic = _("copying")
>

Was this hunk supposed to be in patch 1/2?


>      num = 0
>      if os.path.isdir(src):
> diff --git a/tests/test-clone.t b/tests/test-clone.t
> --- a/tests/test-clone.t
> +++ b/tests/test-clone.t
> @@ -65,6 +65,14 @@ No update, with debug option:
>
>  #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
> diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
> --- a/tests/test-hardlinks.t
> +++ b/tests/test-hardlinks.t
> @@ -58,6 +58,13 @@ Prepare repo r1:
>  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:
> diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-
> recursion.t
> --- a/tests/test-subrepo-recursion.t
> +++ b/tests/test-subrepo-recursion.t
> @@ -342,6 +342,16 @@ Test archiving a revision that reference
>  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 @@ cloned:
>    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 @@ cloned:
>    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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -242,6 +242,8 @@  def copystore(ui, srcrepo, destpath):
         srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
         srcvfs = scmutil.vfs(srcrepo.sharedpath)
         dstvfs = scmutil.vfs(destpath)
+        def prog(topic, pos):
+            ui.progress(topic, pos + num)
         for f in srcrepo.store.copylist():
             if srcpublishing and f.endswith('phaseroots'):
                 continue
@@ -255,12 +257,14 @@  def copystore(ui, srcrepo, destpath):
                     # 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)
+            ui.progress(_("linking"), None)
         else:
             ui.debug("copied %d files\n" % num)
+            ui.progress(_("copying"), None)
         return destlock
     except: # re-raises
         release(destlock)
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -746,9 +746,9 @@  def copyfiles(src, dst, hardlink=None, p
         hardlink = (os.stat(src).st_dev ==
                     os.stat(os.path.dirname(dst)).st_dev)
     if hardlink:
-        topic = 'linking'
+        topic = _("linking")
     else:
-        topic = 'copying'
+        topic = _("copying")
 
     num = 0
     if os.path.isdir(src):
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -65,6 +65,14 @@  No update, with debug option:
 
 #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
diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -58,6 +58,13 @@  Prepare repo r1:
 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:
diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t
--- a/tests/test-subrepo-recursion.t
+++ b/tests/test-subrepo-recursion.t
@@ -342,6 +342,16 @@  Test archiving a revision that reference
 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 @@  cloned:
   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 @@  cloned:
   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)