def testRdiffDeltaPatchGzip(self): """Same as above by try gzipping patches""" rplist = [ self.basis, self.new, self.delta, self.signature, self.output ] for rp in rplist: if rp.lstat(): rp.delete() MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) assert self.basis.lstat() and self.new.lstat() self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) assert self.signature.lstat() self.delta.write_from_fileobj( Rdiff.get_delta_sigrp(self.signature, self.new)) assert self.delta.lstat() os.system(b"gzip %s" % self.delta.path) os.system(b"mv %s.gz %s" % (self.delta.path, self.delta.path)) self.delta.setdata() Rdiff.patch_local(self.basis, self.delta, self.output, delta_compressed=1) assert rpath.cmp(self.new, self.output) list(map(rpath.RPath.delete, rplist))
def testRdiffDeltaPatchGzip(self): """Same as above by try gzipping patches""" rplist = [ self.basis, self.new, self.delta, self.signature, self.output ] for rp in rplist: if rp.lstat(): rp.delete() MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) self.assertTrue(self.basis.lstat() and self.new.lstat()) self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) self.assertTrue(self.signature.lstat()) self.delta.write_from_fileobj( Rdiff.get_delta_sigrp_hash(self.signature, self.new)) self.assertTrue(self.delta.lstat()) gzip_path = self.delta.path + b".gz" if os.name == "nt": # simulate gzip using 7z on Windows os_system("7z a -tgzip -sdel -bb0 -y %s %s" % (os.fsdecode(gzip_path), os.fsdecode(self.delta.path))) else: os_system(b"gzip %s" % self.delta.path) os.rename(gzip_path, self.delta.path) self.delta.setdata() Rdiff.patch_local(self.basis, self.delta, self.output, delta_compressed=1) self.assertTrue(rpath.cmp(self.new, self.output)) list(map(rpath.RPath.delete, rplist))
def testWriteDeltaGzip(self): """Same as above but delta is written gzipped""" rplist = [self.basis, self.new, self.delta, self.output] MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) self.assertTrue(self.basis.lstat() and self.new.lstat()) delta_gz = rpath.RPath(self.delta.conn, self.delta.path + b".gz") if delta_gz.lstat(): delta_gz.delete() Rdiff.write_delta(self.basis, self.new, delta_gz, 1) self.assertTrue(delta_gz.lstat()) if os.name == "nt": # simulate gunzip using 7z on Windows os_system( "7z e -tgzip -bb0 -y -o%s %s" % (os.fsdecode(delta_gz.get_parent_rp()), os.fsdecode(delta_gz))) os.unlink(delta_gz.path) else: os_system(b"gunzip %s" % delta_gz.path) delta_gz.setdata() self.delta.setdata() Rdiff.patch_local(self.basis, self.delta, self.output) self.assertTrue(rpath.cmp(self.new, self.output)) list(map(rpath.RPath.delete, rplist))
def testGzipDiff(self): """Test making gzipped diffs""" Globals.compression = 1 rp = increment.Increment(rf, rf2, target) self.check_time(rp) assert rp.equal_verbose(rf2, check_index = 0, compare_size = 0) Rdiff.patch_local(rf, rp, out2, delta_compressed = 1) assert rpath.cmp(rf2, out2) rp.delete() out2.delete()
def testDiff(self): """Test making diffs""" Globals.compression = None rp = increment.Increment(rf, rf2, target) self.check_time(rp) self.assertTrue(rp._equal_verbose(rf2, check_index=0, compare_size=0)) Rdiff.patch_local(rf, rp, out2) self.assertTrue(rpath.cmp(rf2, out2)) rp.delete() out2.delete()
def testGzipDiff(self): """Test making gzipped diffs""" Globals.compression = 1 rp = increment.Increment(rf, rf2, target) self.check_time(rp) assert rp.equal_verbose(rf2, check_index=0, compare_size=0) Rdiff.patch_local(rf, rp, out2, delta_compressed=1) assert rpath.cmp(rf2, out2) rp.delete() out2.delete()
def testWriteDelta(self): """Test write delta feature of rdiff""" if self.delta.lstat(): self.delta.delete() rplist = [self.basis, self.new, self.delta, self.output] MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) map(rpath.RPath.setdata, [self.basis, self.new]) assert self.basis.lstat() and self.new.lstat() Rdiff.write_delta(self.basis, self.new, self.delta) assert self.delta.lstat() Rdiff.patch_local(self.basis, self.delta, self.output) assert rpath.cmp(self.new, self.output) map(rpath.RPath.delete, rplist)
def testGzipRegexp(self): """Here a .gz file shouldn't be compressed""" Globals.compression = 1 rpath.copy(rf, out_gz) assert out_gz.lstat() rp = increment.Increment(rf, out_gz, target) self.check_time(rp) assert rp.equal_verbose(out_gz, check_index = 0, compare_size = 0) Rdiff.patch_local(rf, rp, out2) assert rpath.cmp(out_gz, out2) rp.delete() out2.delete() out_gz.delete()
def testGzipRegexp(self): """Here a .gz file shouldn't be compressed""" Globals.compression = 1 rpath.copy(rf, out_gz) assert out_gz.lstat() rp = increment.Increment(rf, out_gz, target) self.check_time(rp) assert rp.equal_verbose(out_gz, check_index=0, compare_size=0) Rdiff.patch_local(rf, rp, out2) assert rpath.cmp(out_gz, out2) rp.delete() out2.delete() out_gz.delete()
def testWriteDelta(self): """Test write delta feature of rdiff""" if self.delta.lstat(): self.delta.delete() rplist = [self.basis, self.new, self.delta, self.output] MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) assert self.basis.lstat() and self.new.lstat() Rdiff.write_delta(self.basis, self.new, self.delta) assert self.delta.lstat() Rdiff.patch_local(self.basis, self.delta, self.output) assert rpath.cmp(self.new, self.output) list(map(rpath.RPath.delete, rplist))
def testRdiffRename(self): """Rdiff replacing original file with patch outfile""" rplist = [self.basis, self.new, self.delta, self.signature] for rp in rplist: if rp.lstat(): rp.delete() MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) map(rpath.RPath.setdata, [self.basis, self.new]) assert self.basis.lstat() and self.new.lstat() self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) assert self.signature.lstat() self.delta.write_from_fileobj(Rdiff.get_delta_sigrp(self.signature, self.new)) assert self.delta.lstat() Rdiff.patch_local(self.basis, self.delta) assert rpath.cmp(self.basis, self.new) map(rpath.RPath.delete, rplist)
def testRdiffRename(self): """Rdiff replacing original file with patch outfile""" rplist = [self.basis, self.new, self.delta, self.signature] for rp in rplist: if rp.lstat(): rp.delete() MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) assert self.basis.lstat() and self.new.lstat() self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) assert self.signature.lstat() self.delta.write_from_fileobj( Rdiff.get_delta_sigrp(self.signature, self.new)) assert self.delta.lstat() Rdiff.patch_local(self.basis, self.delta) assert rpath.cmp(self.basis, self.new) list(map(rpath.RPath.delete, rplist))
def testWriteDeltaGzip(self): """Same as above but delta is written gzipped""" rplist = [self.basis, self.new, self.delta, self.output] MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) assert self.basis.lstat() and self.new.lstat() delta_gz = rpath.RPath(self.delta.conn, self.delta.path + ".gz") if delta_gz.lstat(): delta_gz.delete() Rdiff.write_delta(self.basis, self.new, delta_gz, 1) assert delta_gz.lstat() os.system("gunzip %s" % delta_gz.path) delta_gz.setdata() self.delta.setdata() Rdiff.patch_local(self.basis, self.delta, self.output) assert rpath.cmp(self.new, self.output) list(map(rpath.RPath.delete, rplist))
def testWriteDeltaGzip(self): """Same as above but delta is written gzipped""" rplist = [self.basis, self.new, self.delta, self.output] MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) map(rpath.RPath.setdata, [self.basis, self.new]) assert self.basis.lstat() and self.new.lstat() delta_gz = rpath.RPath(self.delta.conn, self.delta.path + ".gz") if delta_gz.lstat(): delta_gz.delete() Rdiff.write_delta(self.basis, self.new, delta_gz, 1) assert delta_gz.lstat() os.system("gunzip " + delta_gz.path) delta_gz.setdata() self.delta.setdata() Rdiff.patch_local(self.basis, self.delta, self.output) assert rpath.cmp(self.new, self.output) map(rpath.RPath.delete, rplist)
def testRdiffDeltaPatch(self): """Test making deltas and patching files""" rplist = [self.basis, self.new, self.delta, self.signature, self.output] for rp in rplist: if rp.lstat(): rp.delete() for i in range(2): MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) map(rpath.RPath.setdata, [self.basis, self.new]) assert self.basis.lstat() and self.new.lstat() self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) assert self.signature.lstat() self.delta.write_from_fileobj(Rdiff.get_delta_sigrp(self.signature, self.new)) assert self.delta.lstat() Rdiff.patch_local(self.basis, self.delta, self.output) assert rpath.cmp(self.new, self.output) map(rpath.RPath.delete, rplist)
def testRdiffDeltaPatch(self): """Test making deltas and patching files""" rplist = [ self.basis, self.new, self.delta, self.signature, self.output ] for rp in rplist: if rp.lstat(): rp.delete() for i in range(2): MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) list(map(rpath.RPath.setdata, [self.basis, self.new])) assert self.basis.lstat() and self.new.lstat() self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) assert self.signature.lstat() self.delta.write_from_fileobj( Rdiff.get_delta_sigrp(self.signature, self.new)) assert self.delta.lstat() Rdiff.patch_local(self.basis, self.delta, self.output) assert rpath.cmp(self.new, self.output) list(map(rpath.RPath.delete, rplist))
def _patch_to_temp(self, basis_rp, diff_rorp, new): """Patch basis_rp, writing output in new, which doesn't exist yet""" if diff_rorp.isflaglinked(): map_hardlinks.link_rp(diff_rorp, new, self.basis_root_rp) return if diff_rorp.get_attached_filetype() == 'snapshot': copy_report = rpath.copy(diff_rorp, new) else: assert diff_rorp.get_attached_filetype() == 'diff', ( "File '{drp}' must be of type '{dtype}'.".format( drp=diff_rorp, dtype='diff')) copy_report = Rdiff.patch_local(basis_rp, diff_rorp, new) self._check_hash(copy_report, diff_rorp) if new.lstat(): rpath.copy_attribs(diff_rorp, new)
def testRdiffDeltaPatchGzip(self): """Same as above by try gzipping patches""" rplist = [self.basis, self.new, self.delta, self.signature, self.output] for rp in rplist: if rp.lstat(): rp.delete() MakeRandomFile(self.basis.path) MakeRandomFile(self.new.path) map(rpath.RPath.setdata, [self.basis, self.new]) assert self.basis.lstat() and self.new.lstat() self.signature.write_from_fileobj(Rdiff.get_signature(self.basis)) assert self.signature.lstat() self.delta.write_from_fileobj(Rdiff.get_delta_sigrp(self.signature, self.new)) assert self.delta.lstat() os.system("gzip " + self.delta.path) os.system("mv %s %s" % (self.delta.path + ".gz", self.delta.path)) self.delta.setdata() Rdiff.patch_local(self.basis, self.delta, self.output, delta_compressed = 1) assert rpath.cmp(self.new, self.output) map(rpath.RPath.delete, rplist)