git » abk » commit c305709

New command line option --exclude

author Leandro Lucarella
2005-05-01 15:21:08 UTC
committer Leandro Lucarella
2005-05-01 15:21:08 UTC
parent 16befd1649bc0ad24a88c508956152ffd95794bf

New command line option --exclude

abk +8 -2

diff --git a/abk b/abk
index 27fdfb1..8aac12b 100644
--- a/abk
+++ b/abk
@@ -341,7 +341,7 @@ def relative_path(base, path):
 # main operations
 #
 
-def make_sync(sources, srcidx_path, dst_path, dstidx_path):
+def make_sync(sources, srcidx_path, dst_path, dstidx_path, exclude):
 	"Sync two directories."
 	# destination and indexes are always a complete path
 	srcidx_path = os.path.join(os.getcwd(), srcidx_path)
@@ -493,6 +493,9 @@ commands:
 	parser.add_option("-a", "--hash-mode", default='sha', metavar="MODE",
 		help="select the hash to use to check for file content change. "
 		"Available modes: none, sha, md5 [default: sha]")
+	parser.add_option("-e", "--exclude", metavar="REGEX", action="append",
+		help="excludes files that matches with the regular expression. "
+		"This option accepts multiple instances")
 	parser.add_option("-i", "--new-idx", metavar="FILE",
 		help="select where to write the new generated index. "
 		"This is useful for incremental backups. "
@@ -556,7 +559,10 @@ elif cmd == 'sync':
 		parser.error("Missing parameter(s) for command sync.")
 	if opts.new_idx:
 		new_idx_path = opts.new_idx
-	make_sync(sources, new_idx_path, dst_path, old_idx_path)
+	exclude = []
+	if opts.exclude:
+		exclude = opts.exclude
+	make_sync(sources, new_idx_path, dst_path, old_idx_path, exclude)
 else:
 	parser.error("Unknown command (%s)." % cmd)