def _do_diff(self, base_path, path): if base_path is None: print("Added: " + path) label = path elif path is None: print("Removed: " + base_path) label = base_path else: print("Modified: " + path) label = path print("===============================================================" + \ "===============") args = [] args.append("-L") args.append(label + "\t(original)") args.append("-L") args.append(label + "\t(new)") args.append("-u") differ = fs.FileDiff(self.base_root, base_path, self.root, path, diffoptions=args) pobj = differ.get_pipe() while True: line = pobj.readline() if not line: break sys.stdout.write("%s " % line) print("")
def _do_diff(self, base_path, path): if base_path is None: print "Added: " + path label = path elif path is None: print "Removed: " + path label = base_path else: print "Modified: " + path label = path print "===============================================================" + \ "===============" args = [] args.append("-L") args.append(label + "\t(original)") args.append("-L") args.append(label + "\t(new)") args.append("-u") differ = fs.FileDiff(self.base_root, base_path, self.root, path, diffoptions=args) pobj = differ.get_pipe() while 1: line = pobj.readline() if not line: break print line, print ""
def test_diff_repos_paths_internal(self): """Test diffing of a repository path using the internal diff.""" # Test standard internal diff fdiff = fs.FileDiff(fs.revision_root(self.fs, self.commitedrev), "/trunk/UniTest.txt", None, None, diffoptions=None) diffp = fdiff.get_pipe() diffoutput = diffp.read().decode('utf8') self.assertTrue(diffoutput.find(u'-' + self.unistr) > 0)
def test_diff_repos_paths_external(self): """Test diffing of a repository path using an external diff (if available).""" # Test if this environment has the diff command, if not then skip the test try: diffout, differr = Popen(["diff"], stdin=PIPE, stderr=PIPE).communicate() except OSError as err: if err.errno == errno.ENOENT: self.skipTest("'diff' command not present") else: raise err fdiff = fs.FileDiff(fs.revision_root(self.fs, self.commitedrev), "/trunk/UniTest.txt", None, None, diffoptions=[]) diffp = fdiff.get_pipe() diffoutput = diffp.read().decode('utf8') self.assertTrue(diffoutput.find(u'< ' + self.unistr) > 0)