Commit 3f9338bc authored by ben's avatar ben

Fixed source finalizer resume bug (although more remains to be done)


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@95 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 4b4a73c9
......@@ -76,7 +76,7 @@ class HLSourceStruct:
def iterate_from(cls):
"""Supply more aruments to DestructiveStepping.Iterate_from"""
if cls._session_info is None: Globals.select_source.set_iter()
else: Globals.select_source.set_iter(cls._session_info.last_index)
else: Globals.select_source.set_iter(cls._session_info.last_index, 1)
return Globals.select_source
def split_initial_dsiter(cls):
......
......@@ -241,7 +241,7 @@ class IterTreeReducer:
def Finish(self):
"""Call at end of sequence to tie everything up"""
assert not self.finished
assert not self.finished, (self.base_index, self.index)
if self.subinstance:
self.subinstance.Finish()
self.branch_process(self.subinstance)
......
......@@ -200,8 +200,7 @@ class Robust:
"""
try: return init_thunk()
except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException), exc:
Log.exception()
RPathException, RdiffException), exc:
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
......@@ -209,8 +208,11 @@ class Robust:
'EIO', # reported by docv
'ETXTBSY' # reported by Campbell on some NT system
])):
Log.exception()
return error_thunk(exc)
else: raise
else:
Log.exception(1, 2)
raise
def listrp(rp):
"""Like rp.listdir() but return [] if error, and sort results"""
......
......@@ -74,12 +74,15 @@ class Select:
self.prefix = self.dsrpath.path
self.quoting_on = Globals.quoting_enabled and quoted_filenames
def set_iter(self, starting_index = None, sel_func = None):
def set_iter(self, starting_index = None, iterate_parents = None,
sel_func = None):
"""Initialize more variables, get ready to iterate
Will iterate indicies greater than starting_index. Selection
function sel_func is called on each dsrp and is usually
self.Select. Returns self just for convenience.
Will iterate indicies greater than starting_index. If
iterate_parents is true, will also include parents of
starting_index in iteration. Selection function sel_func is
called on each dsrp and is usually self.Select. Returns self
just for convenience.
"""
if not sel_func: sel_func = self.Select
......@@ -88,7 +91,10 @@ class Select:
self.starting_index = starting_index
self.iter = self.iterate_starting_from(self.dsrpath,
self.iterate_starting_from, sel_func)
else: self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func)
else:
assert not iterate_parents
self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func)
self.iterate_parents = iterate_parents
self.next = self.iter.next
self.__iter__ = lambda: self
return self
......@@ -140,8 +146,10 @@ class Select:
if dsrpath.index > self.starting_index: # past starting_index
for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func):
yield dsrp
elif dsrpath.index == self.starting_index[:len(dsrpath.index)]:
elif (dsrpath.index == self.starting_index[:len(dsrpath.index)]
and dsrpath.isdir()):
# May encounter starting index on this branch
if self.iterate_parents: yield dsrpath
for dsrp in self.iterate_in_dir(dsrpath,
self.iterate_starting_from,
sel_func): yield dsrp
......
......@@ -76,7 +76,7 @@ class HLSourceStruct:
def iterate_from(cls):
"""Supply more aruments to DestructiveStepping.Iterate_from"""
if cls._session_info is None: Globals.select_source.set_iter()
else: Globals.select_source.set_iter(cls._session_info.last_index)
else: Globals.select_source.set_iter(cls._session_info.last_index, 1)
return Globals.select_source
def split_initial_dsiter(cls):
......
......@@ -241,7 +241,7 @@ class IterTreeReducer:
def Finish(self):
"""Call at end of sequence to tie everything up"""
assert not self.finished
assert not self.finished, (self.base_index, self.index)
if self.subinstance:
self.subinstance.Finish()
self.branch_process(self.subinstance)
......
......@@ -200,8 +200,7 @@ class Robust:
"""
try: return init_thunk()
except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException), exc:
Log.exception()
RPathException, RdiffException), exc:
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
......@@ -209,8 +208,11 @@ class Robust:
'EIO', # reported by docv
'ETXTBSY' # reported by Campbell on some NT system
])):
Log.exception()
return error_thunk(exc)
else: raise
else:
Log.exception(1, 2)
raise
def listrp(rp):
"""Like rp.listdir() but return [] if error, and sort results"""
......
......@@ -74,12 +74,15 @@ class Select:
self.prefix = self.dsrpath.path
self.quoting_on = Globals.quoting_enabled and quoted_filenames
def set_iter(self, starting_index = None, sel_func = None):
def set_iter(self, starting_index = None, iterate_parents = None,
sel_func = None):
"""Initialize more variables, get ready to iterate
Will iterate indicies greater than starting_index. Selection
function sel_func is called on each dsrp and is usually
self.Select. Returns self just for convenience.
Will iterate indicies greater than starting_index. If
iterate_parents is true, will also include parents of
starting_index in iteration. Selection function sel_func is
called on each dsrp and is usually self.Select. Returns self
just for convenience.
"""
if not sel_func: sel_func = self.Select
......@@ -88,7 +91,10 @@ class Select:
self.starting_index = starting_index
self.iter = self.iterate_starting_from(self.dsrpath,
self.iterate_starting_from, sel_func)
else: self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func)
else:
assert not iterate_parents
self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func)
self.iterate_parents = iterate_parents
self.next = self.iter.next
self.__iter__ = lambda: self
return self
......@@ -140,8 +146,10 @@ class Select:
if dsrpath.index > self.starting_index: # past starting_index
for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func):
yield dsrp
elif dsrpath.index == self.starting_index[:len(dsrpath.index)]:
elif (dsrpath.index == self.starting_index[:len(dsrpath.index)]
and dsrpath.isdir()):
# May encounter starting index on this branch
if self.iterate_parents: yield dsrpath
for dsrp in self.iterate_in_dir(dsrpath,
self.iterate_starting_from,
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