diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-03-15 19:40:14 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-03-15 19:40:14 +0000 |
commit | 0b36f985cb741573e80986c5f0b06f04eeec4253 (patch) | |
tree | ded31e872e023d92bed13ebab61216dbc29a4f62 | |
parent | 4e1ea7701e862dcda08703ef66f1aa7852142e09 (diff) | |
download | rdiff-backup-0b36f985cb741573e80986c5f0b06f04eeec4253.tar.gz |
Removed various files no longer in use
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@305 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rwxr-xr-x | rdiff-backup/rdiff_backup/Make.old | 38 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/destructive_stepping.py | 212 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/filelist.py | 106 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/header.py | 19 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/rlist.py | 240 |
5 files changed, 0 insertions, 615 deletions
diff --git a/rdiff-backup/rdiff_backup/Make.old b/rdiff-backup/rdiff_backup/Make.old deleted file mode 100755 index 2b79ffe..0000000 --- a/rdiff-backup/rdiff_backup/Make.old +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python - -"""Read component files of rdiff-backup, and glue them together after -removing unnecessary bits.""" - -import os - -def mystrip(filename): - """Open filename, read input, strip appropriately, and return contents""" - fp = open(filename, "r") - lines = fp.readlines() - fp.close() - - i = 0 - while(lines[i][:60] != - "############################################################"): - i = i+1 - - return "".join(lines[i:]).strip() + "\n\n\n" - - - -files = ["globals.py", "static.py", "lazy.py", "log.py", "ttime.py", - "iterfile.py", "rdiff.py", "connection.py", "rpath.py", - "hardlink.py", "robust.py", "rorpiter.py", - "destructive_stepping.py", "selection.py", - "filename_mapping.py", "statistics.py", "increment.py", - "restore.py", "manage.py", "highlevel.py", - "setconnections.py", "main.py"] - -os.system("cp header.py rdiff-backup") - -outfp = open("rdiff-backup", "a") -for file in files: - outfp.write(mystrip(file)) -outfp.close() - -os.system("chmod 755 rdiff-backup") diff --git a/rdiff-backup/rdiff_backup/destructive_stepping.py b/rdiff-backup/rdiff_backup/destructive_stepping.py deleted file mode 100644 index 6dc77e7..0000000 --- a/rdiff-backup/rdiff_backup/destructive_stepping.py +++ /dev/null @@ -1,212 +0,0 @@ - -# Copyright 2002 Ben Escoto -# -# This file is part of rdiff-backup. -# -# rdiff-backup is free software; you can redistribute it and/or modify -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# rdiff-backup is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rdiff-backup; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA - -"""Deal with side effects from traversing trees""" - -from __future__ import generators -import types -import Globals, rpath, log - - -class DSRPPermError(Exception): - """Exception used when a DSRPath can't get sufficient permissions""" - pass - -class DSRPath(rpath.RPath): - """Destructive Stepping RPath - - Sometimes when we traverse the directory tree, even when we just - want to read files, we have to change things, like the permissions - of a file or directory in order to read it, or the file's access - times. This class is like an RPath, but the permission and time - modifications are delayed, so that they can be done at the very - end when they won't be disturbed later. - - Here are the new class variables: - delay_perms - true iff future perm changes should be delayed - newperms - holds the perm values while they are delayed - delay_atime - true iff some atime change are being delayed - newatime - holds the new atime - delay_mtime - true if some mtime change is being delayed - newmtime - holds the new mtime - - """ - def __init__(self, source, conn_or_rp, base = 0, index = ()): - """Initialize DSRP - - Source should be true iff the DSRPath is taken from the - "source" partition and thus settings like - Globals.change_source_perms should be paid attention to. - - If args is [rpath], return the dsrpath equivalent of rpath, - otherwise use the same arguments as the RPath initializer. - - """ - if base == 0: - assert isinstance(conn_or_rp, rpath.RPath) - rpath.RPath.__init__(self, conn_or_rp.conn, - conn_or_rp.base, conn_or_rp.index) - self.path = conn_or_rp.path # conn_or_rp may be quoted - else: rpath.RPath.__init__(self, conn_or_rp, base, index) - - if source != "bypass": - # "bypass" val is used when unpackaging over connection - assert source is None or source is 1 - self.source = source - self.set_delays(source) - self.set_init_perms(source) - - def set_delays(self, source): - """Delay writing permissions and times where appropriate""" - if not source or Globals.change_source_perms: - self.delay_perms, self.newperms = 1, None - else: self.delay_perms = None - - if Globals.preserve_atime: - self.delay_atime = 1 - # Now get atime right away if possible - if self.data.has_key('atime'): self.newatime = self.data['atime'] - else: self.newatime = None - else: self.delay_atime = None - - if source: - self.delay_mtime = None # we'll never change mtime of source file - else: - self.delay_mtime = 1 - # Save mtime now for a dir, because it might inadvertantly change - if self.isdir(): self.newmtime = self.data['mtime'] - else: self.newmtime = None - - def set_init_perms(self, source): - """If necessary, change permissions to ensure access""" - if self.isreg() and not self.readable(): - if (source and Globals.change_source_perms or - not source and Globals.change_mirror_perms): - self.chmod_bypass(0400) - elif self.isdir(): - if source and Globals.change_source_perms: - if not self.readable() or not self.executable(): - self.chmod_bypass(0500) - elif not source and Globals.change_mirror_perms: - if not self.hasfullperms(): self.chmod_bypass(0700) - - def warn(self, err): - log.Log("Received error '%s' when dealing with file %s, skipping..." - % (err, self.path), 1) - raise DSRPPermError(self.path) - - def __getstate__(self): - """Return picklable state. See RPath __getstate__.""" - assert self.conn is Globals.local_connection # Can't pickle a conn - return self.getstatedict() - - def getstatedict(self): - """Return dictionary containing the attributes we can save""" - pickle_dict = {} - for attrib in ['index', 'data', 'delay_perms', 'newperms', - 'delay_atime', 'newatime', - 'delay_mtime', 'newmtime', - 'path', 'base', 'source']: - if self.__dict__.has_key(attrib): - pickle_dict[attrib] = self.__dict__[attrib] - return pickle_dict - - def __setstate__(self, pickle_dict): - """Set state from object produced by getstate""" - self.conn = Globals.local_connection - for attrib in pickle_dict.keys(): - self.__dict__[attrib] = pickle_dict[attrib] - - def chmod(self, permissions): - """Change permissions, delaying if self.perms_delayed is set""" - if self.delay_perms: self.newperms = self.data['perms'] = permissions - else: rpath.RPath.chmod(self, permissions) - - def getperms(self): - """Return dsrp's intended permissions""" - if self.delay_perms and self.newperms is not None: - return self.newperms - else: return self.data['perms'] - - def chmod_bypass(self, permissions): - """Change permissions without updating the data dictionary""" - self.delay_perms = 1 - if self.newperms is None: self.newperms = self.getperms() - log.Log("DSRP: Perm bypass %s to %o" % (self.path, permissions), 8) - self.conn.os.chmod(self.path, permissions) - - def settime(self, accesstime, modtime): - """Change times, delaying if self.times_delayed is set""" - if self.delay_atime: self.newatime = self.data['atime'] = accesstime - if self.delay_mtime: self.newmtime = self.data['mtime'] = modtime - - if not self.delay_atime or not self.delay_mtime: - rpath.RPath.settime(self, accesstime, modtime) - - def setmtime(self, modtime): - """Change mtime, delaying if self.times_delayed is set""" - if self.delay_mtime: self.newmtime = self.data['mtime'] = modtime - else: rpath.RPath.setmtime(self, modtime) - - def getmtime(self): - """Return dsrp's intended modification time""" - if self.delay_mtime and self.newmtime is not None: - return self.newmtime - else: return self.data['mtime'] - - def getatime(self): - """Return dsrp's intended access time""" - if self.delay_atime and self.newatime is not None: - return self.newatime - else: return self.data['atime'] - - def write_changes(self): - """Write saved up permission/time changes""" - if not self.lstat(): return # File has been deleted in meantime - - if self.delay_perms and self.newperms is not None: - log.Log("Finalizing permissions of dsrp %s to %s" % - (self.path, self.newperms), 8) - rpath.RPath.chmod(self, self.newperms) - - do_atime = self.delay_atime and self.newatime is not None - do_mtime = self.delay_mtime and self.newmtime is not None - if do_atime and do_mtime: - rpath.RPath.settime(self, self.newatime, self.newmtime) - elif do_atime and not do_mtime: - rpath.RPath.settime(self, self.newatime, self.getmtime()) - elif not do_atime and do_mtime: - rpath.RPath.setmtime(self, self.newmtime) - - def newpath(self, newpath, index = ()): - """Return similar DSRPath but with new path""" - return self.__class__(self.source, self.conn, newpath, index) - - def append(self, ext): - """Return similar DSRPath with new extension""" - return self.__class__(self.source, self.conn, self.base, - self.index + (ext,)) - - def new_index(self, index): - """Return similar DSRPath with new index""" - return self.__class__(self.source, self.conn, self.base, index) - - - diff --git a/rdiff-backup/rdiff_backup/filelist.py b/rdiff-backup/rdiff_backup/filelist.py deleted file mode 100644 index a969047..0000000 --- a/rdiff-backup/rdiff_backup/filelist.py +++ /dev/null @@ -1,106 +0,0 @@ -from __future__ import generators -import rpath, manage - -####################################################################### -# -# filelist - Some routines that help with operations over files listed -# in standard input instead of over whole directories. -# - -class FilelistError(Exception): pass - -class Filelist: - """Many of these methods have analogs in highlevel.py""" - def File2Iter(fp, baserp): - """Convert file obj with one pathname per line into rpiter - - Closes fp when done. Given files are added to baserp. - - """ - while 1: - line = fp.readline() - if not line: break - if line[-1] == "\n": line = line[:-1] # strip trailing newline - if not line: continue # skip blank lines - elif line[0] == "/": raise FilelistError( - "Read in absolute file name %s." % line) - yield baserp.append(line) - assert not fp.close(), "Error closing filelist fp" - - def Mirror(src_rpath, dest_rpath, rpiter): - """Copy files in fileiter from src_rpath to dest_rpath""" - sigiter = dest_rpath.conn.Filelist.get_sigs(dest_rpath, rpiter) - diffiter = Filelist.get_diffs(src_rpath, sigiter) - dest_rpath.conn.Filelist.patch(dest_rpath, diffiter) - dest_rpath.setdata() - - def Mirror_and_increment(src_rpath, dest_rpath, inc_rpath): - """Mirror + put increment in tree based at inc_rpath""" - sigiter = dest_rpath.conn.Filelist.get_sigs(dest_rpath, rpiter) - diffiter = Filelist.get_diffs(src_rpath, sigiter) - dest_rpath.conn.Filelist.patch_and_increment(dest_rpath, diffiter, - inc_rpath) - dest_rpath.setdata() - - def get_sigs(dest_rpbase, rpiter): - """Get signatures of file analogs in rpiter - - This is meant to be run on the destination side. Only the - extention part of the rps in rpiter will be used; the base is - ignored. - - """ - def dest_iter(src_iter): - for src_rp in src_iter: yield dest_rpbase.new_index(src_rp.index) - return RORPIter.Signatures(dest_iter()) - - def get_diffs(src_rpbase, sigiter): - """Get diffs based on sigiter and files in src_rpbase - - This should be run on the local side. - - """ - for sig_rorp in sigiter: - new_rp = src_rpbase.new_index(sig_rorp.index) - yield RORPIter.diffonce(sig_rorp, new_rp) - - def patch(dest_rpbase, diffiter): - """Process diffs in diffiter and update files in dest_rbpase. - - Run remotely. - - """ - for diff_rorp in diffiter: - basisrp = dest_rpbase.new_index(diff_rorp.index) - if basisrp.lstat(): Filelist.make_subdirs(basisrp) - Log("Processing %s" % basisrp.path, 7) - RORPIter.patchonce(dest_rpbase, basisrp, diff_rorp) - - def patch_and_increment(dest_rpbase, diffiter, inc_rpbase): - """Apply diffs in diffiter to dest_rpbase, and increment to inc_rpbase - - Also to be run remotely. - - """ - for diff_rorp in diffiter: - basisrp = dest_rpbase.new_index(diff_rorp.index) - if diff_rorp.lstat(): Filelist.make_subdirs(basisrp) - Log("Processing %s" % basisrp.path, 7) - # XXX This isn't done yet... - - def make_subdirs(rpath): - """Make sure that all the directories under the rpath exist - - This function doesn't try to get the permissions right on the - underlying directories, just do the minimum to make sure the - file can be created. - - """ - dirname = rpath.dirsplit()[0] - if dirname == '.' or dirname == '': return - dir_rp = RPath(rpath.conn, dirname) - Filelist.make_subdirs(dir_rp) - if not dir_rp.lstat(): dir_rp.mkdir() - - -MakeStatic(Filelist) diff --git a/rdiff-backup/rdiff_backup/header.py b/rdiff-backup/rdiff_backup/header.py deleted file mode 100644 index f628a73..0000000 --- a/rdiff-backup/rdiff_backup/header.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -# -# rdiff-backup -- Mirror files while keeping incremental changes -# Version 0.8.0 released June 14, 2002 -# Copyright (C) 2001, 2002 Ben Escoto <bescoto@stanford.edu> -# -# This program is licensed under the GNU General Public License (GPL). -# Distributions of rdiff-backup usually include a copy of the GPL in a -# file called COPYING. The GPL is also available online at -# http://www.gnu.org/copyleft/gpl.html. -# -# See http://www.stanford.edu/~bescoto/rdiff-backup for more -# information. Please send mail to me or the mailing list if you find -# bugs or have any suggestions. - -from __future__ import nested_scopes, generators -import os, stat, time, sys, getopt, re, cPickle, types, shutil, sha, marshal, traceback, popen2, tempfile, gzip, UserList, errno, signal - - diff --git a/rdiff-backup/rdiff_backup/rlist.py b/rdiff-backup/rdiff_backup/rlist.py deleted file mode 100644 index f27d693..0000000 --- a/rdiff-backup/rdiff_backup/rlist.py +++ /dev/null @@ -1,240 +0,0 @@ -from __future__ import generators -import marshal, sha, types -from rdiff_backup.iterfile import * - -####################################################################### -# -# rlist - Define the CachingIter, and sig/diff/patch ops on iterators -# - -class CachingIter: - """Cache parts of an iter using a list - - Turn an iter into something that you can prepend elements into, - and also read from without apparently changing the state. - - """ - def __init__(self, iter_or_list): - if type(iter_or_list) is types.ListType: - self.iter = iter(iter_or_list) - else: self.iter = iter_or_list - self.next = self.iter.next - self.head = [] - - def __iter__(self): return self - - def _next(self): - """Take elements from the head list - - When there are elements waiting before the main iterator, this - is the next function. If not, iter.next returns to being next. - - """ - head = self.head - a = head[0] - del head[0] - if not head: self.next = self.iter.next - return a - - def nextrange(self, m): - """Return next m elements in list""" - l = head[:m] - del head[:m] - for i in xrange(m - len(l)): l.append(self.iter.next()) - return l - - def peek(self): - """Return next element without removing it from iterator""" - n = self.next() - self.push(n) - return n - - def push(self, elem): - """Insert an element into the iterator at the beginning""" - if not self.head: self.next = self._next - self.head.insert(0, elem) - - def pushrange(self, elem_list): - """Insert list of multiple elements at the beginning""" - if not self.head: self.next = self._next - self.head[:0] = elem_list - - def cache(self, m): - """Move next m elements from iter to internal list - - If m is None, append the entire rest of the iterator. - - """ - h, it = self.head, self.iter - if m is None: - for i in it: h.append(i) - else: - for i in xrange(m): h.append(it.next()) - - def __getitem__(self, key): - """Support a[i:j] style notation. Non destructive""" - if type(key) is types.SliceType: - if key.stop > len(self.head): self.cache(key.stop - len(self.head)) - return self.head[key.start, key.stop] - else: - if key >= len(self.head): self.cache(key + 1 - len(self.head)) - return self.head[key] - - - -class RListDelta: - """Note a difference from one iterator (A) to another (B) - - The min, max pairs are indicies which stand for the half-open - interval (min, max], and elemlist is a list of all the elements in - A which fall within this interval. - - These are produced by the function RList.Deltas(...) - - """ - def __init__(self, (min, max), elemlist): - self.min, self.max = min, max - self.elemlist = elemlist - - - -class RList: - """Tools for signatures, diffing, and patching an iterator - - This class requires that the iterators involved are yielding - objects that have .index and .data attributes. Two objects with - the same .data attribute are supposed to be equivalent. The - iterator must also yield the objects in increasing order with - respect to the .index attribute. - - """ - blocksize = 100 - - def Signatures(iter): - """Return iterator of signatures from stream of pairs - - Each signature is an ordered pair (last index sig applies to, - SHA digest of data) - - """ - i, s = 0, sha.new() - for iter_elem in iter: - s.update(marshal.dumps(iter_elem.data)) - i = i+1 - if i == RList.blocksize: - yield (iter_elem.index, s.digest()) - i, s = 0, sha.new() - if i != 0: yield (iter_elem.index, s.digest()) - - def sig_one_block(iter_or_list): - """Return the digest portion of a signature on given list""" - s = sha.new() - for iter_elem in iter_or_list: s.update(marshal.dumps(iter_elem.data)) - return s.digest() - - def Deltas(remote_sigs, iter): - """Return iterator of Delta objects that bring iter to remote""" - def get_before(index, iter): - """Return elements in iter whose index is before or equal index - iter needs to be pushable - """ - l = [] - while 1: - try: iter_elem = iter.next() - except StopIteration: return l - if iter_elem.index > index: break - l.append(iter_elem) - iter.push(iter_elem) - return l - - if not isinstance(iter, CachingIter): iter = CachingIter(iter) - oldindex = None - for (rs_index, rs_digest) in remote_sigs: - l = get_before(rs_index, iter) - if rs_digest != RList.sig_one_block(l): - yield RListDelta((oldindex, rs_index), l) - oldindex = rs_index - - def patch_once(basis, delta): - """Apply one delta to basis to return original iterator - - This returns original iterator up to and including the max range - of delta, then stop. basis should be pushable. - - """ - # Return elements of basis until start of delta range - for basis_elem in basis: - if basis_elem.index > delta.min: - basis.push(basis_elem) - break - yield basis_elem - - # Yield elements of delta... - for elem in delta.elemlist: yield elem - - # Finally, discard basis until end of delta range - for basis_elem in basis: - if basis_elem.index > delta.max: - basis.push(basis_elem) - break - - def Patch(basis, deltas): - """Apply a delta stream to basis iterator, yielding original""" - if not isinstance(basis, CachingIter): basis = CachingIter(basis) - for d in deltas: - for elem in RList.patch_once(basis, d): yield elem - for elem in basis: yield elem - - def get_difference_once(basis, delta): - """From one delta, find differences from basis - - Will return pairs (basis_elem, new_elem) where basis_elem is - the element from the basis iterator and new_elem is the - element from the other iterator. If either is missing None - will take its place. If both are present iff two have the - same index. - - """ - # Discard any elements of basis before delta starts - for basis_elem in basis: - if basis_elem.index > delta.min: - basis.push(basis_elem) - break - - # In range compare each one by one - di, boverflow, doverflow = 0, None, None - while 1: - # Set indicies and data, or mark if at end of range already - try: - basis_elem = basis.next() - if basis_elem.index > delta.max: - basis.push(basis_elem) - boverflow = 1 - except StopIteration: boverflow = 1 - if di >= len(delta.elemlist): doverflow = 1 - else: delta_elem = delta.elemlist[di] - - if boverflow and doverflow: break - elif boverflow: - yield (None, delta_elem) - di = di+1 - elif doverflow: yield (basis_elem, None) - - # Now can assume that everything is in range - elif basis_elem.index > delta_elem.index: - yield (None, delta_elem) - basis.push(basis_elem) - di = di+1 - elif basis_elem.index == delta_elem.index: - if basis_elem.data != delta_elem.data: - yield (basis_elem, delta_elem) - di = di+1 - else: yield (basis_elem, None) - - def Dissimilar(basis, deltas): - """Return iter of differences from delta iter and basis iter""" - if not isinstance(basis, CachingIter): basis = CachingIter(basis) - for d in deltas: - for triple in RList.get_difference_once(basis, d): yield triple - -MakeStatic(RList) |