Commit 5b18bf90 authored by ben's avatar ben

Various changes to work with new destructive_stepping initialization

code.


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@69 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent d79e4da8
......@@ -6,7 +6,7 @@ execfile("rorpiter.py")
# destructive-stepping - Deal with side effects from traversing trees
#
class DSRPathError(Exception):
class DSRPPermError(Exception):
"""Exception used when a DSRPath can't get sufficient permissions"""
pass
......@@ -85,7 +85,7 @@ class DSRPath(RPath):
def warn(self, err):
Log("Received error '%s' when dealing with file %s, skipping..."
% (err, self.path), 1)
raise DSRPathError(self.path)
raise DSRPermError(self.path)
def __getstate__(self):
"""Return picklable state. See RPath __getstate__."""
......
......@@ -134,7 +134,7 @@ class HLDestinationStruct:
cls._session_info = session_info
def iterate_from(cls):
"""Supply more arguments to DestructiveStepping.Iterate_from"""
"""Return selection iterator to iterate all the mirror files"""
if cls._session_info is None: Globals.select_mirror.set_iter()
else: Globals.select_mirror.set_iter(cls._session_info.last_index)
return Globals.select_mirror
......@@ -203,9 +203,8 @@ class HLDestinationStruct:
def get_dsrp(cls, dest_rpath, index):
"""Return initialized dsrp based on dest_rpath with given index"""
dsrp = DSRPath(dest_rpath.conn, dest_rpath.base, index)
DestructiveStepping.initialize(dsrp, None)
return dsrp
return DSRPath(source = None, dest_rpath.conn,
dest_rpath.base, index)
def get_finalizer(cls):
"""Return finalizer, starting from session info if necessary"""
......@@ -230,9 +229,7 @@ class HLDestinationStruct:
indexed_tuple = collated.next()
Log("Processing %s" % str(indexed_tuple), 7)
diff_rorp, dsrp = indexed_tuple
if not dsrp:
dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index)
DestructiveStepping.initialize(dsrp, None)
if not dsrp: dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index)
if diff_rorp and not diff_rorp.isplaceholder():
RORPIter.patchonce_action(None, dsrp, diff_rorp).execute()
finalizer(dsrp.index, dsrp)
......@@ -261,9 +258,7 @@ class HLDestinationStruct:
Log("Processing %s" % str(indexed_tuple), 7)
diff_rorp, dsrp = indexed_tuple
index = indexed_tuple.index
if not dsrp:
dsrp = cls.get_dsrp(dest_rpath, index)
DestructiveStepping.initialize(dsrp, None)
if not dsrp: dsrp = cls.get_dsrp(dest_rpath, index)
if diff_rorp and diff_rorp.isplaceholder(): diff_rorp = None
ITR(index, diff_rorp, dsrp)
finalizer(index, dsrp)
......@@ -283,7 +278,7 @@ class HLDestinationStruct:
def check_skip_error(cls, thunk, dsrp):
"""Run thunk, catch certain errors skip files"""
try: return thunk()
except (IOError, OSError, SkipFileException), exp:
except (IOError, OSError, SkipFileException, DSRPPermError), exp:
Log.exception()
if (not isinstance(exp, IOError) or
(isinstance(exp, IOError) and
......
......@@ -87,8 +87,7 @@ class Restore:
select_result = Globals.select_mirror.Select(target)
if select_result == 0: return
if mirrorrp and (not Globals.select_source.Select(mirrorrp) or
DestructiveStepping.initialize(mirrorrp, None)):
if mirrorrp and not Globals.select_source.Select(mirrorrp):
mirrorrp = None
rcd = RestoreCombinedData(rid, mirrorrp, target)
......
......@@ -106,9 +106,8 @@ class Select:
"""
s = sel_func(dsrpath)
if not s or DestructiveStepping.initialize(dsrpath, self.source):
return
if s == 1: # File is included
if s === 0: return
elif s == 1: # File is included
yield dsrpath
if dsrpath.isdir():
for dsrp in self.iterate_in_dir(dsrpath, rec_func, sel_func):
......@@ -131,7 +130,6 @@ class Select:
def iterate_starting_from(self, dsrpath, rec_func, sel_func):
"""Like Iterate, but only yield indicies > self.starting_index"""
if DestructiveStepping.initialize(dsrpath, self.source): return
if dsrpath.index > self.starting_index: # past starting_index
for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func):
yield dsrp
......
......@@ -6,7 +6,7 @@ execfile("rorpiter.py")
# destructive-stepping - Deal with side effects from traversing trees
#
class DSRPathError(Exception):
class DSRPPermError(Exception):
"""Exception used when a DSRPath can't get sufficient permissions"""
pass
......@@ -85,7 +85,7 @@ class DSRPath(RPath):
def warn(self, err):
Log("Received error '%s' when dealing with file %s, skipping..."
% (err, self.path), 1)
raise DSRPathError(self.path)
raise DSRPermError(self.path)
def __getstate__(self):
"""Return picklable state. See RPath __getstate__."""
......
......@@ -134,7 +134,7 @@ class HLDestinationStruct:
cls._session_info = session_info
def iterate_from(cls):
"""Supply more arguments to DestructiveStepping.Iterate_from"""
"""Return selection iterator to iterate all the mirror files"""
if cls._session_info is None: Globals.select_mirror.set_iter()
else: Globals.select_mirror.set_iter(cls._session_info.last_index)
return Globals.select_mirror
......@@ -203,9 +203,8 @@ class HLDestinationStruct:
def get_dsrp(cls, dest_rpath, index):
"""Return initialized dsrp based on dest_rpath with given index"""
dsrp = DSRPath(dest_rpath.conn, dest_rpath.base, index)
DestructiveStepping.initialize(dsrp, None)
return dsrp
return DSRPath(source = None, dest_rpath.conn,
dest_rpath.base, index)
def get_finalizer(cls):
"""Return finalizer, starting from session info if necessary"""
......@@ -230,9 +229,7 @@ class HLDestinationStruct:
indexed_tuple = collated.next()
Log("Processing %s" % str(indexed_tuple), 7)
diff_rorp, dsrp = indexed_tuple
if not dsrp:
dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index)
DestructiveStepping.initialize(dsrp, None)
if not dsrp: dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index)
if diff_rorp and not diff_rorp.isplaceholder():
RORPIter.patchonce_action(None, dsrp, diff_rorp).execute()
finalizer(dsrp.index, dsrp)
......@@ -261,9 +258,7 @@ class HLDestinationStruct:
Log("Processing %s" % str(indexed_tuple), 7)
diff_rorp, dsrp = indexed_tuple
index = indexed_tuple.index
if not dsrp:
dsrp = cls.get_dsrp(dest_rpath, index)
DestructiveStepping.initialize(dsrp, None)
if not dsrp: dsrp = cls.get_dsrp(dest_rpath, index)
if diff_rorp and diff_rorp.isplaceholder(): diff_rorp = None
ITR(index, diff_rorp, dsrp)
finalizer(index, dsrp)
......@@ -283,7 +278,7 @@ class HLDestinationStruct:
def check_skip_error(cls, thunk, dsrp):
"""Run thunk, catch certain errors skip files"""
try: return thunk()
except (IOError, OSError, SkipFileException), exp:
except (IOError, OSError, SkipFileException, DSRPPermError), exp:
Log.exception()
if (not isinstance(exp, IOError) or
(isinstance(exp, IOError) and
......
......@@ -87,8 +87,7 @@ class Restore:
select_result = Globals.select_mirror.Select(target)
if select_result == 0: return
if mirrorrp and (not Globals.select_source.Select(mirrorrp) or
DestructiveStepping.initialize(mirrorrp, None)):
if mirrorrp and not Globals.select_source.Select(mirrorrp):
mirrorrp = None
rcd = RestoreCombinedData(rid, mirrorrp, target)
......
......@@ -106,9 +106,8 @@ class Select:
"""
s = sel_func(dsrpath)
if not s or DestructiveStepping.initialize(dsrpath, self.source):
return
if s == 1: # File is included
if s === 0: return
elif s == 1: # File is included
yield dsrpath
if dsrpath.isdir():
for dsrp in self.iterate_in_dir(dsrpath, rec_func, sel_func):
......@@ -131,7 +130,6 @@ class Select:
def iterate_starting_from(self, dsrpath, rec_func, sel_func):
"""Like Iterate, but only yield indicies > self.starting_index"""
if DestructiveStepping.initialize(dsrpath, self.source): return
if dsrpath.index > self.starting_index: # past starting_index
for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func):
yield dsrp
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment