git » abk » commit e2db955

Proper source directory handling.

author
2005-03-02 23:47:56 UTC
committer
2005-03-02 23:47:56 UTC
parent 60d89a8a30454172fe71e2910529cbfa26b68772

Proper source directory handling.
It's nicer to just use the last part of the source path as the path itself,
since it'll make syncing, restoring and manipulation easier to see and to use;
besides, it's nicer if we save in dst/short_path than dst/full_path.

abk +13 -0

diff --git a/abk b/abk
index cb13f8d..f6437c5 100644
--- a/abk
+++ b/abk
@@ -276,6 +276,19 @@ def make_path(f):
 #
 
 def make_sync(src_path, srcidx_path, dst_path, dstidx_path):
+	"Sync two directories."
+	# reduce multiple '/' at the end to none (or only one if it's root)
+	while src_path[-1] == '/' and src_path != '/':
+		src_path = src_path[:-1]
+
+	# move to the source's parent, and use the new source so we
+	# create only one level directories.
+	if src_path != '/':
+		parent, src = os.path.split(src_path)
+		if parent:
+			os.chdir(parent)
+			src_path = src
+
 	# load destination index
 	print "* loading destination index"
 	dstidx = index_file(dstidx_path)