You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 08:09:32 UTC

[buildstream] 24/43: Make the duplication test optional in cas_based_directory

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch jmac/cas_to_cas_oct_v2
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit af6b327fe61f8629d07f7c1d523f2283bf861bbd
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Thu Oct 25 16:48:23 2018 +0100

    Make the duplication test optional in cas_based_directory
---
 buildstream/storage/_casbaseddirectory.py | 35 +++++++++++++++----------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py
index ce0ec2b..f1799b6 100644
--- a/buildstream/storage/_casbaseddirectory.py
+++ b/buildstream/storage/_casbaseddirectory.py
@@ -854,35 +854,34 @@ class CasBasedDirectory(Directory):
         if self.parent:
             self.parent._recalculate_recursing_up(self)
         
-        # Duplicate the current directory
-
+        duplicate_test = False
         
         print("Original CAS before CAS-based import: {}".format(self.show_files_recursive()))
         print("Original CAS hash: {}".format(self.ref.hash))
         duplicate_cas = None
         self._verify_unique()
         if isinstance(external_pathspec, CasBasedDirectory):
-            duplicate_cas = CasBasedDirectory(self.context, ref=copy.copy(self.ref))
-            duplicate_cas._verify_unique()
+            if duplicate_test:
+                duplicate_cas = CasBasedDirectory(self.context, ref=copy.copy(self.ref))
+                duplicate_cas._verify_unique()
+                print("Duplicated CAS before file-based import: {}".format(duplicate_cas.show_files_recursive()))
+                print("Duplicate CAS hash: {}".format(duplicate_cas.ref.hash))
             print("-"*80 + "Performing direct CAS-to-CAS import")
-            print("Duplicated CAS before file-based import: {}".format(duplicate_cas.show_files_recursive()))
-            print("Duplicate CAS hash: {}".format(duplicate_cas.ref.hash))
             result = self._import_cas_into_cas(external_pathspec, files=files)
             self._verify_unique()
             print("Result of cas-to-cas import: {}".format(self.show_files_recursive()))
             print("-"*80 + "Performing round-trip import via file system")
-            with tempfile.TemporaryDirectory(prefix="roundtrip") as tmpdir:
-                external_pathspec.export_files(tmpdir)
-                if files is None:
-                    files = list(list_relative_paths(tmpdir))
-                print("Importing from filesystem: filelist is: {}".format(files))
-                duplicate_cas._import_files_from_directory(tmpdir, files=files)
-                duplicate_cas._recalculate_recursing_down()
-                if duplicate_cas.parent:
-                    duplicate_cas.parent._recalculate_recursing_up(duplicate_cas)
-                print("Result of direct import: {}".format(duplicate_cas.show_files_recursive()))
-               
-
+            if duplicate_test:
+                with tempfile.TemporaryDirectory(prefix="roundtrip") as tmpdir:
+                    external_pathspec.export_files(tmpdir)
+                    if files is None:
+                        files = list(list_relative_paths(tmpdir))
+                    print("Importing from filesystem: filelist is: {}".format(files))
+                    duplicate_cas._import_files_from_directory(tmpdir, files=files)
+                    duplicate_cas._recalculate_recursing_down()
+                    if duplicate_cas.parent:
+                        duplicate_cas.parent._recalculate_recursing_up(duplicate_cas)
+                    print("Result of direct import: {}".format(duplicate_cas.show_files_recursive()))
         else:
             print("-"*80 + "Performing initial import")
             if isinstance(external_pathspec, FileBasedDirectory):