[cedar-backup-svn] SF.net SVN: cedar-backup: [915] cedar-backup2/trunk
Brought to you by:
pronovic
|
From: <pro...@us...> - 2008-04-28 03:22:22
|
Revision: 915
http://cedar-backup.svn.sourceforge.net/cedar-backup/?rev=915&view=rev
Author: pronovic
Date: 2008-04-27 20:21:50 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
Implement CollectDir.dereference configuration option
Modified Paths:
--------------
cedar-backup2/trunk/CedarBackup2/actions/collect.py
cedar-backup2/trunk/CedarBackup2/config.py
cedar-backup2/trunk/Changelog
cedar-backup2/trunk/manual/src/config.xml
cedar-backup2/trunk/test/configtests.py
cedar-backup2/trunk/test/data/cback.conf.15
cedar-backup2/trunk/test/data/cback.conf.20
cedar-backup2/trunk/test/data/cback.conf.21
cedar-backup2/trunk/test/data/cback.conf.8
Modified: cedar-backup2/trunk/CedarBackup2/actions/collect.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/actions/collect.py 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/CedarBackup2/actions/collect.py 2008-04-28 03:21:50 UTC (rev 915)
@@ -127,13 +127,14 @@
archiveMode = _getArchiveMode(config, collectDir)
ignoreFile = _getIgnoreFile(config, collectDir)
linkDepth = _getLinkDepth(collectDir)
+ dereference = _getDereference(collectDir)
digestPath = _getDigestPath(config, collectDir)
tarfilePath = _getTarfilePath(config, collectDir, archiveMode)
(excludePaths, excludePatterns) = _getExclusions(config, collectDir)
if fullBackup or (collectMode in ['daily', 'incr', ]) or (collectMode == 'weekly' and todayIsStart):
logger.debug("Directory meets criteria to be backed up today.")
_collectDirectory(config, collectDir.absolutePath, tarfilePath,
- collectMode, archiveMode, ignoreFile, linkDepth,
+ collectMode, archiveMode, ignoreFile, linkDepth, dereference,
resetDigest, digestPath, excludePaths, excludePatterns)
else:
logger.debug("Directory will not be backed up, per collect mode.")
@@ -182,8 +183,8 @@
###############################
def _collectDirectory(config, absolutePath, tarfilePath, collectMode, archiveMode,
- ignoreFile, linkDepth, resetDigest, digestPath, excludePaths,
- excludePatterns):
+ ignoreFile, linkDepth, dereference, resetDigest, digestPath,
+ excludePaths, excludePatterns):
"""
Collects a configured collect directory.
@@ -203,6 +204,7 @@
@param archiveMode: Archive mode to use.
@param ignoreFile: Ignore file to use.
@param linkDepth: Link depth value to use.
+ @param dereference: Dereference flag to use.
@param resetDigest: Reset digest flag.
@param digestPath: Path to digest file on disk, if needed.
@param excludePaths: List of absolute paths to exclude.
@@ -212,7 +214,7 @@
backupList.ignoreFile = ignoreFile
backupList.excludePaths = excludePaths
backupList.excludePatterns = excludePatterns
- backupList.addDirContents(absolutePath, linkDepth=linkDepth)
+ backupList.addDirContents(absolutePath, linkDepth=linkDepth, dereference=dereference)
_executeBackup(config, backupList, absolutePath, tarfilePath, collectMode, archiveMode, resetDigest, digestPath)
@@ -407,6 +409,25 @@
############################
+# _getDereference() function
+############################
+
+def _getDereference(item):
+ """
+ Gets the dereference flag that should be used for a collect directory.
+ If possible, use the one on the directory, otherwise set a value of False.
+ @param item: C{CollectDir} object
+ @return: Ignore file to use.
+ """
+ if item.dereference is None:
+ dereference = False
+ else:
+ dereference = item.dereference
+ logger.debug("Dereference flag is [%s]" % dereference)
+ return dereference
+
+
+############################
# _getDigestPath() function
############################
Modified: cedar-backup2/trunk/CedarBackup2/config.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/config.py 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/CedarBackup2/config.py 2008-04-28 03:21:50 UTC (rev 915)
@@ -1359,13 +1359,13 @@
@note: Lists within this class are "unordered" for equality comparisons.
@sort: __init__, __repr__, __str__, __cmp__, absolutePath, collectMode,
- archiveMode, ignoreFile, linkDepth, absoluteExcludePaths,
+ archiveMode, ignoreFile, linkDepth, dereference, absoluteExcludePaths,
relativeExcludePaths, excludePatterns
"""
def __init__(self, absolutePath=None, collectMode=None, archiveMode=None, ignoreFile=None,
absoluteExcludePaths=None, relativeExcludePaths=None, excludePatterns=None,
- linkDepth=None):
+ linkDepth=None, dereference=False):
"""
Constructor for the C{CollectDir} class.
@@ -1374,6 +1374,7 @@
@param archiveMode: Overridden archive mode for this directory.
@param ignoreFile: Overidden ignore file name for this directory.
@param linkDepth: Maximum at which soft links should be followed.
+ @param dereference: Whether to dereference links that are followed.
@param absoluteExcludePaths: List of absolute paths to exclude.
@param relativeExcludePaths: List of relative paths to exclude.
@param excludePatterns: List of regular expression patterns to exclude.
@@ -1385,6 +1386,7 @@
self._archiveMode = None
self._ignoreFile = None
self._linkDepth = None
+ self._deference = None
self._absoluteExcludePaths = None
self._relativeExcludePaths = None
self._excludePatterns = None
@@ -1393,6 +1395,7 @@
self.archiveMode = archiveMode
self.ignoreFile = ignoreFile
self.linkDepth = linkDepth
+ self.dereference = dereference
self.absoluteExcludePaths = absoluteExcludePaths
self.relativeExcludePaths = relativeExcludePaths
self.excludePatterns = excludePatterns
@@ -1401,12 +1404,12 @@
"""
Official string representation for class instance.
"""
- return "CollectDir(%s, %s, %s, %s, %s, %s, %s, %s)" % (self.absolutePath, self.collectMode,
- self.archiveMode, self.ignoreFile,
- self.absoluteExcludePaths,
- self.relativeExcludePaths,
- self.excludePatterns,
- self.linkDepth)
+ return "CollectDir(%s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.absolutePath, self.collectMode,
+ self.archiveMode, self.ignoreFile,
+ self.absoluteExcludePaths,
+ self.relativeExcludePaths,
+ self.excludePatterns,
+ self.linkDepth, self.dereference)
def __str__(self):
"""
@@ -1448,6 +1451,11 @@
return -1
else:
return 1
+ if self._dereference != other._dereference:
+ if self._dereference < other._dereference:
+ return -1
+ else:
+ return 1
if self._absoluteExcludePaths != other._absoluteExcludePaths:
if self._absoluteExcludePaths < other._absoluteExcludePaths:
return -1
@@ -1558,6 +1566,22 @@
"""
return self._linkDepth
+ def _setDereference(self, value):
+ """
+ Property target used to set the dereference flag.
+ No validations, but we normalize the value to C{True} or C{False}.
+ """
+ if value:
+ self._dereference = True
+ else:
+ self._dereference = False
+
+ def _getDereference(self):
+ """
+ Property target used to get the dereference flag.
+ """
+ return self._dereference
+
def _setAbsoluteExcludePaths(self, value):
"""
Property target used to set the absolute exclude paths list.
@@ -1630,6 +1654,7 @@
archiveMode = property(_getArchiveMode, _setArchiveMode, None, doc="Overridden archive mode for this directory.")
ignoreFile = property(_getIgnoreFile, _setIgnoreFile, None, doc="Overridden ignore file name for this directory.")
linkDepth = property(_getLinkDepth, _setLinkDepth, None, doc="Maximum at which soft links should be followed.")
+ dereference = property(_getDereference, _setDereference, None, doc="Whether to dereference links that are followed.")
absoluteExcludePaths = property(_getAbsoluteExcludePaths, _setAbsoluteExcludePaths, None, "List of absolute paths to exclude.")
relativeExcludePaths = property(_getRelativeExcludePaths, _setRelativeExcludePaths, None, "List of relative paths to exclude.")
excludePatterns = property(_getExcludePatterns, _setExcludePatterns, None, "List of regular expression patterns to exclude.")
@@ -4714,6 +4739,7 @@
archiveMode archive_mode
ignoreFile ignore_file
linkDepth link_depth
+ dereference dereference
The collect mode is a special case. Just a C{mode} tag is accepted for
backwards compatibility, but we prefer C{collect_mode} for consistency
@@ -4745,6 +4771,7 @@
cdir.archiveMode = readString(entry, "archive_mode")
cdir.ignoreFile = readString(entry, "ignore_file")
cdir.linkDepth = readInteger(entry, "link_depth")
+ cdir.dereference = readBoolean(entry, "dereference")
(cdir.absoluteExcludePaths, cdir.relativeExcludePaths, cdir.excludePatterns) = Config._parseExclusions(entry)
lst.append(cdir)
if lst == []:
@@ -5365,6 +5392,7 @@
archiveMode dir/archive_mode
ignoreFile dir/ignore_file
linkDepth dir/link_depth
+ dereference dir/dereference
Note that an original XML document might have listed the collect mode
using the C{mode} tag, since we accept both C{collect_mode} and C{mode}.
@@ -5393,6 +5421,7 @@
addStringNode(xmlDom, sectionNode, "archive_mode", collectDir.archiveMode)
addStringNode(xmlDom, sectionNode, "ignore_file", collectDir.ignoreFile)
addIntegerNode(xmlDom, sectionNode, "link_depth", collectDir.linkDepth)
+ addBooleanNode(xmlDom, sectionNode, "dereference", collectDir.dereference)
if ((collectDir.absoluteExcludePaths is not None and collectDir.absoluteExcludePaths != []) or
(collectDir.relativeExcludePaths is not None and collectDir.relativeExcludePaths != []) or
(collectDir.excludePatterns is not None and collectDir.excludePatterns != [])):
@@ -5706,6 +5735,8 @@
raise ValueError("Archive mode must either be set in parent collect section or individual collect directory.")
if self.collect.ignoreFile is None and collectDir.ignoreFile is None:
raise ValueError("Ignore file must either be set in parent collect section or individual collect directory.")
+ if (collectDir.linkDepth is None or collectDir.linkDepth < 1) and collectDir.dereference:
+ raise ValueError("Dereference flag is only valid when a non-zero link depth is in use.")
def _validateStage(self):
"""
Modified: cedar-backup2/trunk/Changelog
===================================================================
--- cedar-backup2/trunk/Changelog 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/Changelog 2008-04-28 03:21:50 UTC (rev 915)
@@ -3,6 +3,9 @@
* Add the ability to dereference links when following them.
- Add util.dereferenceLink() function
- Add dereference flag to FilesystemList.addDirContents()
+ - Add CollectDir.dereference attribute
+ - Modify collect action to obey CollectDir.dereference
+ - Update user manual to discuss new attribute
Version 2.17.1 26 Apr 2008
Modified: cedar-backup2/trunk/manual/src/config.xml
===================================================================
--- cedar-backup2/trunk/manual/src/config.xml 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/manual/src/config.xml 2008-04-28 03:21:50 UTC (rev 915)
@@ -1125,7 +1125,8 @@
but a set of soft links to other files and directories.
Normally, Cedar Backup does not follow soft links, but you can
override this behavior for individual directories using the
- <literal>link_depth</literal> option (see below).
+ <literal>link_depth</literal> and <literal>dereference</literal>
+ options (see below).
</para>
<para>
@@ -1635,7 +1636,7 @@
This field is optional. If it doesn't exist,
the backup will assume a value of zero, meaning
that soft links within the collect directory will
- never be followed.
+ never be followed.
</para>
<para>
<emphasis>Restrictions:</emphasis> If set, must
@@ -1645,6 +1646,38 @@
</varlistentry>
<varlistentry>
+ <term><literal>dereference</literal></term>
+ <listitem>
+ <para>Whether to dereference soft links.</para>
+ <para>
+ If this flag is set, links that are being
+ followed will be dereferenced before being added
+ to the backup. The link will be added (as a
+ link), and then the directory or file that the
+ link points at will be added as well.
+ </para>
+ <para>
+ This value only applies to a directory where soft
+ links are being followed (per the
+ <literal>link_depth</literal> configuration
+ option). It never applies to a configured
+ collect directory itself, only to other
+ directories within the collect directory.
+ </para>
+ <para>
+ This field is optional. If it doesn't exist,
+ the backup will assume that links should never be
+ dereferenced.
+ </para>
+ <para>
+ <emphasis>Restrictions:</emphasis> Must be a
+ boolean (<literal>Y</literal> or
+ <literal>N</literal>).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><literal>exclude</literal></term>
<listitem>
<para>List of paths or patterns to exclude from the backup.</para>
Modified: cedar-backup2/trunk/test/configtests.py
===================================================================
--- cedar-backup2/trunk/test/configtests.py 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/test/configtests.py 2008-04-28 03:21:50 UTC (rev 915)
@@ -2439,6 +2439,7 @@
self.failUnlessEqual(None, collectDir.archiveMode)
self.failUnlessEqual(None, collectDir.ignoreFile)
self.failUnlessEqual(None, collectDir.linkDepth)
+ self.failUnlessEqual(False, collectDir.dereference)
self.failUnlessEqual(None, collectDir.absoluteExcludePaths)
self.failUnlessEqual(None, collectDir.relativeExcludePaths)
self.failUnlessEqual(None, collectDir.excludePatterns)
@@ -2447,12 +2448,13 @@
"""
Test constructor with all values filled in, with valid values.
"""
- collectDir = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 2)
+ collectDir = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 2, True)
self.failUnlessEqual("/etc/whatever", collectDir.absolutePath)
self.failUnlessEqual("incr", collectDir.collectMode)
self.failUnlessEqual("tar", collectDir.archiveMode)
self.failUnlessEqual(".ignore", collectDir.ignoreFile)
self.failUnlessEqual(2, collectDir.linkDepth)
+ self.failUnlessEqual(True, collectDir.dereference)
self.failUnlessEqual([], collectDir.absoluteExcludePaths)
self.failUnlessEqual([], collectDir.relativeExcludePaths)
self.failUnlessEqual([], collectDir.excludePatterns)
@@ -2807,7 +2809,44 @@
self.failUnlessAssignRaises(ValueError, collectDir, "linkDepth", "ken")
self.failUnlessEqual(None, collectDir.linkDepth)
+ def testConstructor_039(self):
+ """
+ Test assignment of dereference attribute, None value.
+ """
+ collectDir = CollectDir(dereference=True)
+ self.failUnlessEqual(True, collectDir.dereference)
+ collectDir.dereference = None
+ self.failUnlessEqual(False, collectDir.dereference)
+ def testConstructor_040(self):
+ """
+ Test assignment of dereference attribute, valid value (real boolean).
+ """
+ collectDir = CollectDir()
+ self.failUnlessEqual(False, collectDir.dereference)
+ collectDir.dereference = True
+ self.failUnlessEqual(True, collectDir.dereference)
+ collectDir.dereference = False
+ self.failUnlessEqual(False, collectDir.dereference)
+
+ def testConstructor_041(self):
+ """
+ Test assignment of dereference attribute, valid value (expression).
+ """
+ collectDir = CollectDir()
+ self.failUnlessEqual(False, collectDir.dereference)
+ collectDir.dereference = 0
+ self.failUnlessEqual(False, collectDir.dereference)
+ collectDir.dereference = []
+ self.failUnlessEqual(False, collectDir.dereference)
+ collectDir.dereference = None
+ self.failUnlessEqual(False, collectDir.dereference)
+ collectDir.dereference = ['a']
+ self.failUnlessEqual(True, collectDir.dereference)
+ collectDir.dereference = 3
+ self.failUnlessEqual(True, collectDir.dereference)
+
+
############################
# Test comparison operators
############################
@@ -2831,8 +2870,8 @@
Test comparison of two identical objects, all attributes non-None (empty
lists).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
self.failUnless(collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
self.failUnless(collectDir1 <= collectDir2)
@@ -2845,8 +2884,8 @@
Test comparison of two identical objects, all attributes non-None
(non-empty lists).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/one",], ["two",], ["three",], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/one",], ["two",], ["three",], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/one",], ["two",], ["three",], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/one",], ["two",], ["three",], 1, True)
self.failUnless(collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
self.failUnless(collectDir1 <= collectDir2)
@@ -2872,8 +2911,8 @@
"""
Test comparison of two differing objects, absolutePath differs.
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
- collectDir2 = CollectDir("/stuff", "incr", "tar", ".ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/stuff", "incr", "tar", ".ignore", [], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(collectDir1 < collectDir2)
@@ -2900,8 +2939,8 @@
"""
Test comparison of two differing objects, collectMode differs.
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "daily", "tar", ".ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "daily", "tar", ".ignore", [], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
@@ -2928,8 +2967,8 @@
"""
Test comparison of two differing objects, archiveMode differs.
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "targz", ".ignore", [], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "targz", ".ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
@@ -2956,8 +2995,8 @@
"""
Test comparison of two differing objects, ignoreFile differs.
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
@@ -3001,8 +3040,8 @@
Test comparison of two differing objects, absoluteExcludePaths differs
(one empty, one not empty).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/whatever", ], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/whatever", ], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(collectDir1 < collectDir2)
@@ -3016,8 +3055,8 @@
Test comparison of two differing objects, absoluteExcludePaths differs
(both not empty).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/stuff", ], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/stuff", "/something", ], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/stuff", ], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", ["/stuff", "/something", ], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2) # note: different than standard due to unsorted list
@@ -3061,8 +3100,8 @@
Test comparison of two differing objects, relativeExcludePaths differs
(one empty, one not empty).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], ["one", ], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], ["one", ], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
@@ -3076,8 +3115,8 @@
Test comparison of two differing objects, relativeExcludePaths differs
(both not empty).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], ["one", ], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], ["two", ], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], ["one", ], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], ["two", ], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(collectDir1 < collectDir2)
@@ -3121,8 +3160,8 @@
Test comparison of two differing objects, excludePatterns differs (one
empty, one not empty).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], ["pattern", ], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], ["pattern", ], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(collectDir1 < collectDir2)
@@ -3136,8 +3175,8 @@
Test comparison of two differing objects, excludePatterns differs (both
not empty).
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], ["p1", ], 1)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], ["p2", ], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], ["p1", ], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", ".ignore", [], [], ["p2", ], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(collectDir1 < collectDir2)
@@ -3164,8 +3203,8 @@
"""
Test comparison of two differing objects, linkDepth differs.
"""
- collectDir1 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 2)
- collectDir2 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 1)
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 2, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 1, True)
self.failIfEqual(collectDir1, collectDir2)
self.failUnless(not collectDir1 == collectDir2)
self.failUnless(not collectDir1 < collectDir2)
@@ -3174,7 +3213,35 @@
self.failUnless(collectDir1 >= collectDir2)
self.failUnless(collectDir1 != collectDir2)
+ def testComparison_026(self):
+ """
+ Test comparison of two differing objects, dereference differs (one None).
+ """
+ collectDir1 = CollectDir()
+ collectDir2 = CollectDir(dereference=True)
+ self.failIfEqual(collectDir1, collectDir2)
+ self.failUnless(not collectDir1 == collectDir2)
+ self.failUnless(collectDir1 < collectDir2)
+ self.failUnless(collectDir1 <= collectDir2)
+ self.failUnless(not collectDir1 > collectDir2)
+ self.failUnless(not collectDir1 >= collectDir2)
+ self.failUnless(collectDir1 != collectDir2)
+ def testComparison_027(self):
+ """
+ Test comparison of two differing objects, dereference differs.
+ """
+ collectDir1 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 1, True)
+ collectDir2 = CollectDir("/etc/whatever", "incr", "tar", "ignore", [], [], [], 1, False)
+ self.failIfEqual(collectDir1, collectDir2)
+ self.failUnless(not collectDir1 == collectDir2)
+ self.failUnless(not collectDir1 < collectDir2)
+ self.failUnless(not collectDir1 <= collectDir2)
+ self.failUnless(collectDir1 > collectDir2)
+ self.failUnless(collectDir1 >= collectDir2)
+ self.failUnless(collectDir1 != collectDir2)
+
+
#####################
# TestPurgeDir class
#####################
@@ -10696,7 +10763,67 @@
config.peers.remotePeers[0].managedActions = ["collect", ]
config._validatePeers()
+ def testValidate_078(self):
+ """
+ Test case where dereference is True but link depth is None.
+ """
+ config = Config()
+ config.collect = CollectConfig()
+ config.collect.targetDir = "/whatever"
+ config.collect.collectDirs = [ CollectDir(absolutePath="/stuff", collectMode="incr", archiveMode="tar", ignoreFile="i", linkDepth=None, dereference=True), ]
+ self.failUnlessRaises(ValueError, config._validateCollect)
+ def testValidate_079(self):
+ """
+ Test case where dereference is True but link depth is zero.
+ """
+ config = Config()
+ config.collect = CollectConfig()
+ config.collect.targetDir = "/whatever"
+ config.collect.collectDirs = [ CollectDir(absolutePath="/stuff", collectMode="incr", archiveMode="tar", ignoreFile="i", linkDepth=0, dereference=True), ]
+ self.failUnlessRaises(ValueError, config._validateCollect)
+
+ def testValidate_080(self):
+ """
+ Test case where dereference is False and linkDepth is None.
+ """
+ config = Config()
+ config.collect = CollectConfig()
+ config.collect.targetDir = "/whatever"
+ config.collect.collectDirs = [ CollectDir(absolutePath="/stuff", collectMode="incr", archiveMode="tar", ignoreFile="i", linkDepth=None, dereference=False), ]
+ config._validateCollect()
+
+ def testValidate_081(self):
+ """
+ Test case where dereference is None and linkDepth is None.
+ """
+ config = Config()
+ config.collect = CollectConfig()
+ config.collect.targetDir = "/whatever"
+ config.collect.collectDirs = [ CollectDir(absolutePath="/stuff", collectMode="incr", archiveMode="tar", ignoreFile="i", linkDepth=None, dereference=None), ]
+ config._validateCollect()
+
+ def testValidate_082(self):
+ """
+ Test case where dereference is False and linkDepth is zero.
+ """
+ config = Config()
+ config.collect = CollectConfig()
+ config.collect.targetDir = "/whatever"
+ config.collect.collectDirs = [ CollectDir(absolutePath="/stuff", collectMode="incr", archiveMode="tar", ignoreFile="i", linkDepth=0, dereference=False), ]
+ config._validateCollect()
+
+ def testValidate_083(self):
+ """
+ Test case where dereference is None and linkDepth is zero.
+ """
+ config = Config()
+ config.collect = CollectConfig()
+ config.collect.targetDir = "/whatever"
+ config.collect.collectDirs = [ CollectDir(absolutePath="/stuff", collectMode="incr", archiveMode="tar", ignoreFile="i", linkDepth=0, dereference=None), ]
+ config._validateCollect()
+
+
############################
# Test parsing of documents
############################
@@ -10939,6 +11066,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
@@ -11126,6 +11254,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
@@ -11193,6 +11322,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
@@ -11257,6 +11387,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
@@ -11324,6 +11455,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
@@ -11479,6 +11611,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
@@ -11550,6 +11683,7 @@
expected.collect.collectDirs = []
expected.collect.collectDirs.append(CollectDir(absolutePath="/root"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/tmp", linkDepth=3))
+ expected.collect.collectDirs.append(CollectDir(absolutePath="/ken", linkDepth=1, dereference=True))
expected.collect.collectDirs.append(CollectDir(absolutePath="/var/log", collectMode="incr"))
expected.collect.collectDirs.append(CollectDir(absolutePath="/etc",collectMode="incr",archiveMode="tar",ignoreFile=".ignore"))
collectDir = CollectDir(absolutePath="/opt")
Modified: cedar-backup2/trunk/test/data/cback.conf.15
===================================================================
--- cedar-backup2/trunk/test/data/cback.conf.15 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/test/data/cback.conf.15 2008-04-28 03:21:50 UTC (rev 915)
@@ -71,6 +71,11 @@
<link_depth>3</link_depth>
</dir>
<dir>
+ <abs_path>/ken</abs_path>
+ <link_depth>1</link_depth>
+ <dereference>Y</dereference>
+ </dir>
+ <dir>
<abs_path>/var/log</abs_path>
<mode>incr</mode> <!-- deprecated form -->
</dir>
Modified: cedar-backup2/trunk/test/data/cback.conf.20
===================================================================
--- cedar-backup2/trunk/test/data/cback.conf.20 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/test/data/cback.conf.20 2008-04-28 03:21:50 UTC (rev 915)
@@ -74,6 +74,11 @@
<link_depth>3</link_depth>
</dir>
<dir>
+ <abs_path>/ken</abs_path>
+ <link_depth>1</link_depth>
+ <dereference>Y</dereference>
+ </dir>
+ <dir>
<abs_path>/var/log</abs_path>
<mode>incr</mode> <!-- deprecated form -->
</dir>
Modified: cedar-backup2/trunk/test/data/cback.conf.21
===================================================================
--- cedar-backup2/trunk/test/data/cback.conf.21 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/test/data/cback.conf.21 2008-04-28 03:21:50 UTC (rev 915)
@@ -115,6 +115,11 @@
<link_depth>3</link_depth>
</dir>
<dir>
+ <abs_path>/ken</abs_path>
+ <link_depth>1</link_depth>
+ <dereference>Y</dereference>
+ </dir>
+ <dir>
<abs_path>/var/log</abs_path>
<mode>incr</mode> <!-- deprecated form -->
</dir>
Modified: cedar-backup2/trunk/test/data/cback.conf.8
===================================================================
--- cedar-backup2/trunk/test/data/cback.conf.8 2008-04-28 02:40:04 UTC (rev 914)
+++ cedar-backup2/trunk/test/data/cback.conf.8 2008-04-28 03:21:50 UTC (rev 915)
@@ -20,6 +20,11 @@
<link_depth>3</link_depth>
</dir>
<dir>
+ <abs_path>/ken</abs_path>
+ <link_depth>1</link_depth>
+ <dereference>Y</dereference>
+ </dir>
+ <dir>
<abs_path>/var/log</abs_path>
<mode>incr</mode> <!-- deprecated form -->
</dir>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|