Skip to content
Snippets Groups Projects
Commit fa585aaa authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

Update upstream source from tag 'debian/upstream/0.0.7'

Update to upstream version '0.0.7'
with Debian dir 7d9ad79fa5b214792dc0896603959278f846f2d0
parents 6507ab6f 82a486d1
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 1.0 Metadata-Version: 1.0
Name: swh.model Name: swh.model
Version: 0.0.6 Version: 0.0.7
Summary: Software Heritage data model Summary: Software Heritage data model
Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Home-page: https://forge.softwareheritage.org/diffusion/DMOD/
Author: Software Heritage developers Author: Software Heritage developers
......
Metadata-Version: 1.0 Metadata-Version: 1.0
Name: swh.model Name: swh.model
Version: 0.0.6 Version: 0.0.7
Summary: Software Heritage data model Summary: Software Heritage data model
Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Home-page: https://forge.softwareheritage.org/diffusion/DMOD/
Author: Software Heritage developers Author: Software Heritage developers
......
...@@ -188,7 +188,8 @@ def compute_tree_metadata(dirname, ls_hashes): ...@@ -188,7 +188,8 @@ def compute_tree_metadata(dirname, ls_hashes):
def walk_and_compute_sha1_from_directory(rootdir, def walk_and_compute_sha1_from_directory(rootdir,
dir_ok_fn=lambda dirpath: True, dir_ok_fn=lambda dirpath: True,
with_root_tree=True): with_root_tree=True,
remove_empty_folder=False):
"""Compute git sha1 from directory rootdir. """Compute git sha1 from directory rootdir.
Args: Args:
...@@ -232,6 +233,17 @@ def walk_and_compute_sha1_from_directory(rootdir, ...@@ -232,6 +233,17 @@ def walk_and_compute_sha1_from_directory(rootdir,
dirname)), dirname)),
dirnames)) dirnames))
if remove_empty_folder: # round-trip to remove empty folders
gen_dir = ((dp, filtfn(dp, dns), fns) for (dp, dns, fns)
in os.walk(rootdir, topdown=False)
if dir_ok_fn(dp))
for dirpath, dirnames, filenames in gen_dir:
if dirnames == [] and filenames == []:
if os.path.islink(dirpath):
os.remove(dirpath)
else:
os.removedirs(dirpath)
gen_dir = ((dp, filtfn(dp, dns), fns) for (dp, dns, fns) gen_dir = ((dp, filtfn(dp, dns), fns) for (dp, dns, fns)
in os.walk(rootdir, topdown=False) in os.walk(rootdir, topdown=False)
if dir_ok_fn(dp)) if dir_ok_fn(dp))
...@@ -429,7 +441,8 @@ def __remove_paths_from_objects(objects, rootpaths, ...@@ -429,7 +441,8 @@ def __remove_paths_from_objects(objects, rootpaths,
def update_checksums_from(changed_paths, objects, def update_checksums_from(changed_paths, objects,
dir_ok_fn=lambda dirpath: True): dir_ok_fn=lambda dirpath: True,
remove_empty_folder=False):
"""Given a list of changed paths, recompute the checksums only where """Given a list of changed paths, recompute the checksums only where
needed. needed.
...@@ -459,7 +472,10 @@ def update_checksums_from(changed_paths, objects, ...@@ -459,7 +472,10 @@ def update_checksums_from(changed_paths, objects,
parent = os.path.dirname(path) parent = os.path.dirname(path)
if parent == root: # ... recompute everything anyway if parent == root: # ... recompute everything anyway
return walk_and_compute_sha1_from_directory(root, dir_ok_fn) return walk_and_compute_sha1_from_directory(
root,
dir_ok_fn=dir_ok_fn,
remove_empty_folder=remove_empty_folder)
if changed_path['action'] == 'D': # (D)elete if changed_path['action'] == 'D': # (D)elete
paths_to_remove.add(path) paths_to_remove.add(path)
...@@ -480,15 +496,24 @@ def update_checksums_from(changed_paths, objects, ...@@ -480,15 +496,24 @@ def update_checksums_from(changed_paths, objects,
# Recompute from disk the checksums from impacted common ancestor # Recompute from disk the checksums from impacted common ancestor
# rootdir changes. # rootdir changes.
if not objects.get(rootdir, None): while not objects.get(rootdir, None):
# rootdir no longer exists, recompute all # it could happened that the path is not found.
# folder could have been previously ignored # In the case of an ignored folder for example.
# (e.g. in svn case with ignore flag activated) # So we'll find the next existing parent
return walk_and_compute_sha1_from_directory(root, rootdir = os.path.dirname(rootdir)
dir_ok_fn)
if rootdir == root: # fallback, if we hit root, walk
hashes = walk_and_compute_sha1_from_directory(rootdir, dir_ok_fn, # everything anyway
with_root_tree=False) return walk_and_compute_sha1_from_directory(
root,
dir_ok_fn=dir_ok_fn,
remove_empty_folder=remove_empty_folder)
hashes = walk_and_compute_sha1_from_directory(
rootdir,
dir_ok_fn=dir_ok_fn,
with_root_tree=False,
remove_empty_folder=remove_empty_folder)
# Then update the original objects with new # Then update the original objects with new
# checksums for the arborescence tree below rootdir # checksums for the arborescence tree below rootdir
......
...@@ -146,6 +146,7 @@ class GitHashWalkArborescenceTree(unittest.TestCase): ...@@ -146,6 +146,7 @@ class GitHashWalkArborescenceTree(unittest.TestCase):
""" """
def setUp(self): def setUp(self):
self.tmp_root_path = tempfile.mkdtemp().encode('utf-8') self.tmp_root_path = tempfile.mkdtemp().encode('utf-8')
self.maxDiff = None
start_path = os.path.dirname(__file__).encode('utf-8') start_path = os.path.dirname(__file__).encode('utf-8')
pkg_doc_linux_r11 = os.path.join(start_path, pkg_doc_linux_r11 = os.path.join(start_path,
......
v0.0.6-0-gca235a0 v0.0.7-0-g22b9fca
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment