summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2007-05-13 05:43:06 +0000
committerdgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2007-05-13 05:43:06 +0000
commit7a3688b54eb99e466921eacd8e45f9ead605dd66 (patch)
tree1667a87eac4afc03a4be2d179a8a65955a3abddb
parent31436edba539f5f20e7752b89e492632f454d958 (diff)
downloadrdiff-backup-7a3688b54eb99e466921eacd8e45f9ead605dd66.tar.gz
New --exclude-if-present option (i.e. --exclude-if-present .nobackup).
(Jeff Strunk). git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@797 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/CHANGELOG3
-rw-r--r--rdiff-backup/rdiff-backup.16
-rw-r--r--rdiff-backup/rdiff_backup/Main.py3
-rw-r--r--rdiff-backup/rdiff_backup/selection.py14
4 files changed, 25 insertions, 1 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index cbada73..f51b346 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,6 +1,9 @@
New in v1.1.10 (????/??/??)
---------------------------
+New --exclude-if-present option (i.e. --exclude-if-present .nobackup).
+(Jeff Strunk).
+
Use signal 0 rather than signal.NSIG when testing if another rdiff-backup
is still running. (Patch from Sébastien Maret)
diff --git a/rdiff-backup/rdiff-backup.1 b/rdiff-backup/rdiff-backup.1
index a6725f0..c2283f6 100644
--- a/rdiff-backup/rdiff-backup.1
+++ b/rdiff-backup/rdiff-backup.1
@@ -190,6 +190,12 @@ Exclude all socket files.
.B "\-\-exclude-symbolic-links"
Exclude all symbolic links.
.TP
+.BI "\-\exclude-if-present " filename
+Exclude directories if
+.IR filename
+is present. This option needs to come before any other include or
+exclude options.
+.TP
.B \-\-force
Authorize a more drastic modification of a directory than usual (for
instance, when overwriting of a destination path, or when removing
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index a7cb9e1..bb8a404 100644
--- a/rdiff-backup/rdiff_backup/Main.py
+++ b/rdiff-backup/rdiff_backup/Main.py
@@ -67,7 +67,7 @@ def parse_cmdlineoptions(arglist):
"exclude-symbolic-links", "exclude-sockets",
"exclude-filelist-stdin", "exclude-globbing-filelist=",
"exclude-globbing-filelist-stdin", "exclude-mirror=",
- "exclude-other-filesystems", "exclude-regexp=",
+ "exclude-other-filesystems", "exclude-regexp=", "exclude-if-present=",
"exclude-special-files", "force", "group-mapping-file=",
"include=", "include-filelist=", "include-filelist-stdin",
"include-globbing-filelist=",
@@ -109,6 +109,7 @@ def parse_cmdlineoptions(arglist):
opt == "--exclude-fifos" or
opt == "--exclude-other-filesystems" or
opt == "--exclude-regexp" or
+ opt == "--exclude-if-present" or
opt == "--exclude-special-files" or
opt == "--exclude-sockets" or
opt == "--exclude-symbolic-links"):
diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py
index 6a02e24..e9476ac 100644
--- a/rdiff-backup/rdiff_backup/selection.py
+++ b/rdiff-backup/rdiff_backup/selection.py
@@ -234,6 +234,8 @@ class Select:
for opt, arg in argtuples:
if opt == "--exclude":
self.add_selection_func(self.glob_get_sf(arg, 0))
+ elif opt == "--exclude-if-present":
+ self.add_selection_func(self.presence_get_sf(arg, 0))
elif opt == "--exclude-device-files":
self.add_selection_func(self.devfiles_get_sf(0))
elif opt == "--exclude-symbolic-links":
@@ -471,6 +473,18 @@ probably isn't what you meant.""" %
sel_func.name = "Regular expression: %s" % regexp_string
return sel_func
+ def presence_get_sf(self, presence_filename, include):
+ """Return selection function given by a file if present"""
+ assert include == 0 or include == 1
+
+ def sel_func(rp):
+ if rp.isdir() and rp.readable() and rp.append(presence_filename).isreg(): return include
+ return None
+
+ sel_func.exclude = not include
+ sel_func.name = "Presence file: %s" % presence_filename
+ return sel_func
+
def gen_get_sf(self, pred, include, name):
"""Returns a selection function that uses pred to test