]> arthur.barton.de Git - bup.git/blobdiff - cmd/save-cmd.py
import-rsnapshot: exit with 1, not -1
[bup.git] / cmd / save-cmd.py
index b8e4f7aa597d999d877a31a40b36f4c40e205a71..fc93408c2a5dcc61923d2f7bc18356856c4fe926 100755 (executable)
@@ -141,7 +141,22 @@ def _pop(force_tree, dir_metadata=None):
                                                    [metadata_f],
                                                    keep_boundaries=False)
         shalist.append((mode, '.bupm', id))
-    tree = force_tree or w.new_tree(shalist)
+    # FIXME: only test if collision is possible (i.e. given --strip, etc.)?
+    if force_tree:
+        tree = force_tree
+    else:
+        names_seen = set()
+        clean_list = []
+        for x in shalist:
+            name = x[1]
+            if name in names_seen:
+                parent_path = '/'.join(parts) + '/'
+                add_error('error: ignoring duplicate path %r in %r'
+                          % (name, parent_path))
+            else:
+                names_seen.add(name)
+                clean_list.append(x)
+        tree = w.new_tree(clean_list)
     if shalists:
         shalists[-1].append((GIT_MODE_TREE,
                              git.mangle_name(part,
@@ -308,16 +323,7 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during):
     # ...].
 
     if first_root == None:
-        dir_name, fs_path = dirp[0]
         first_root = dirp[0]
-        # Not indexed, so just grab the FS metadata or use empty metadata.
-        try:
-           meta = metadata.from_path(fs_path) if fs_path else metadata.Metadata()
-        except (OSError, IOError), e:
-            add_error(e)
-            lastskip_name = dir_name
-        else:
-           _push(dir_name, meta)
     elif first_root != dirp[0]:
         root_collision = True
 
@@ -334,8 +340,8 @@ for (transname,ent) in r.filter(extra, wantrecurse=wantrecurse_during):
         except (OSError, IOError), e:
             add_error(e)
             lastskip_name = dir_name
-        else:
-           _push(dir_name, meta)
+            meta = metadata.Metadata()
+        _push(dir_name, meta)
 
     if not file:
         if len(parts) == 1: