Patchwork [6,of,7] util.copyfiles: add optional ignore parameter

login
register
mail settings
Submitter Angel Ezquerra
Date Nov. 25, 2015, 12:22 a.m.
Message ID <842eee140028656f82d3.1448410950@waste.org>
Download mbox | patch
Permalink /patch/11636/
State Changes Requested
Headers show

Comments

Angel Ezquerra - Nov. 25, 2015, 12:22 a.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1448234511 -3600
#      Mon Nov 23 00:21:51 2015 +0100
# Node ID 842eee140028656f82d3d05ca3cdc68677a4ce39
# Parent  ec9de3a84179e1e3531d784b1f15d988a33f5455
util.copyfiles: add optional ignore parameter

Make it possible to specify a list of files that will not be copied.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -800,7 +800,7 @@ 
             raise Abort(str(inst))
 
 def copyfiles(src, dst, hardlink=None, progress=lambda t, pos: None,
-              overwrite=True):
+              overwrite=True, ignore=None):
     """Copy a directory tree using hardlinks if possible."""
     num = 0
 
@@ -812,7 +812,9 @@ 
     else:
         topic = _('copying')
 
-    if os.path.isdir(src):
+    if ignore and src in ignore:
+        pass
+    elif os.path.isdir(src):
         if not os.path.exists(dst):
             os.mkdir(dst)
         for name, kind in osutil.listdir(src):
@@ -822,7 +824,7 @@ 
                 if pos is not None:
                     return progress(t, pos + num)
             hardlink, n = copyfiles(srcname, dstname, hardlink, progress=nprog,
-                                    overwrite=overwrite)
+                                    overwrite=overwrite, ignore=ignore)
             num += n
     elif not overwrite and os.path.exists(dst):
         pass