Exemple #1
0
 def testGzipDiff(self):
     """Test making gzipped diffs"""
     Globals.compression = 1
     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, delta_compressed=1)
     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()
Exemple #3
0
 def testDiff(self):
     """Test making diffs"""
     Globals.compression = None
     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)
     assert rpath.cmp(rf2, out2)
     rp.delete()
     out2.delete()
Exemple #4
0
    def testCopy(self):
        """Using rdiff to copy two files"""
        rplist = [self.basis, self.new]
        for rp in rplist:
            if rp.lstat(): rp.delete()

        MakeRandomFile(self.basis.path)
        MakeRandomFile(self.new.path)
        list(map(rpath.RPath.setdata, rplist))
        Rdiff.copy_local(self.basis, self.new)
        assert rpath.cmp(self.basis, self.new)
        list(map(rpath.RPath.delete, rplist))
Exemple #5
0
	def testCopy(self):
		"""Using rdiff to copy two files"""
		rplist = [self.basis, self.new]
		for rp in rplist:
			if rp.lstat(): rp.delete()

		MakeRandomFile(self.basis.path)
		MakeRandomFile(self.new.path)
		map(rpath.RPath.setdata, rplist)
		Rdiff.copy_local(self.basis, self.new)
		assert rpath.cmp(self.basis, self.new)
		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()
Exemple #7
0
	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)		
Exemple #8
0
    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))
Exemple #9
0
    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()
Exemple #10
0
    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))
Exemple #11
0
    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))
Exemple #12
0
	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)
Exemple #13
0
	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)		
Exemple #14
0
	def testRdiffSig(self):
		"""Test making rdiff signatures"""
		sig = rpath.RPath(self.lc,
						  "testfiles/various_file_types/regular_file.sig")
		sigfp = sig.open("r")
		rfsig = Rdiff.get_signature(RPath(self.lc, "testfiles/various_file_types/regular_file"), 2048)
		assert rpath.cmpfileobj(sigfp, rfsig)
		sigfp.close()
		rfsig.close()
Exemple #15
0
 def testRdiffSig(self):
     """Test making rdiff signatures"""
     sig = rpath.RPath(self.lc,
                       "testfiles/various_file_types/regular_file.sig")
     sigfp = sig.open("r")
     rfsig = Rdiff.get_signature(
         RPath(self.lc, "testfiles/various_file_types/regular_file"), 2048)
     assert rpath.cmpfileobj(sigfp, rfsig)
     sigfp.close()
     rfsig.close()
Exemple #16
0
	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)
Exemple #17
0
    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))
Exemple #18
0
 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)
Exemple #19
0
	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)
Exemple #20
0
 def testRdiffSig(self):
     """Test making rdiff signatures"""
     sig = rpath.RPath(
         self.lc,
         os.path.join(old_test_dir, b"various_file_types",
                      b"regular_file.sig"))
     sigfp = sig.open("rb")
     rfsig = Rdiff.get_signature(
         rpath.RPath(
             self.lc,
             os.path.join(old_test_dir, b"various_file_types",
                          b"regular_file")), 2048)
     assert rpath.cmpfileobj(sigfp, rfsig)
     sigfp.close()
     rfsig.close()