Show More
@@ -375,11 +375,18 b' class SvnRemote(object):' | |||||
375 |
|
375 | |||
376 | def diff(self, wire, rev1, rev2, path1=None, path2=None, |
|
376 | def diff(self, wire, rev1, rev2, path1=None, path2=None, | |
377 | ignore_whitespace=False, context=3): |
|
377 | ignore_whitespace=False, context=3): | |
|
378 | ||||
378 | wire.update(cache=False) |
|
379 | wire.update(cache=False) | |
379 | repo = self._factory.repo(wire) |
|
380 | repo = self._factory.repo(wire) | |
380 | diff_creator = SvnDiffer( |
|
381 | diff_creator = SvnDiffer( | |
381 | repo, rev1, path1, rev2, path2, ignore_whitespace, context) |
|
382 | repo, rev1, path1, rev2, path2, ignore_whitespace, context) | |
382 | return diff_creator.generate_diff() |
|
383 | try: | |
|
384 | return diff_creator.generate_diff() | |||
|
385 | except svn.core.SubversionException as e: | |||
|
386 | log.exception( | |||
|
387 | "Error during diff operation operation. " | |||
|
388 | "Path might not exist %s, %s" % (path1, path2)) | |||
|
389 | return "" | |||
383 |
|
390 | |||
384 |
|
391 | |||
385 | class SvnDiffer(object): |
|
392 | class SvnDiffer(object): | |
@@ -450,23 +457,30 b' class SvnDiffer(object):' | |||||
450 | buf, change, path, self.tgt_path, path, self.src_path) |
|
457 | buf, change, path, self.tgt_path, path, self.src_path) | |
451 |
|
458 | |||
452 | def _generate_file_diff(self, buf): |
|
459 | def _generate_file_diff(self, buf): | |
453 |
|
|
460 | change = None | |
454 |
|
|
461 | if self.src_kind == svn.core.svn_node_none: | |
455 |
|
|
462 | change = "add" | |
456 |
|
|
463 | elif self.tgt_kind == svn.core.svn_node_none: | |
457 |
|
|
464 | change = "delete" | |
458 |
|
|
465 | tgt_base, tgt_path = vcspath.split(self.tgt_path) | |
459 |
|
|
466 | src_base, src_path = vcspath.split(self.src_path) | |
460 |
|
|
467 | self._generate_node_diff( | |
461 |
|
|
468 | buf, change, tgt_path, tgt_base, src_path, src_base) | |
462 |
|
469 | |||
463 | def _generate_node_diff( |
|
470 | def _generate_node_diff( | |
464 | self, buf, change, tgt_path, tgt_base, src_path, src_base): |
|
471 | self, buf, change, tgt_path, tgt_base, src_path, src_base): | |
|
472 | ||||
|
473 | if self.src_rev == self.tgt_rev and tgt_base == src_base: | |||
|
474 | # makes consistent behaviour with git/hg to return empty diff if | |||
|
475 | # we compare same revisions | |||
|
476 | return | |||
|
477 | ||||
465 | tgt_full_path = vcspath.join(tgt_base, tgt_path) |
|
478 | tgt_full_path = vcspath.join(tgt_base, tgt_path) | |
466 | src_full_path = vcspath.join(src_base, src_path) |
|
479 | src_full_path = vcspath.join(src_base, src_path) | |
467 |
|
480 | |||
468 | self.binary_content = False |
|
481 | self.binary_content = False | |
469 | mime_type = self._get_mime_type(tgt_full_path) |
|
482 | mime_type = self._get_mime_type(tgt_full_path) | |
|
483 | ||||
470 | if mime_type and not mime_type.startswith('text'): |
|
484 | if mime_type and not mime_type.startswith('text'): | |
471 | self.binary_content = True |
|
485 | self.binary_content = True | |
472 | buf.write("=" * 67 + '\n') |
|
486 | buf.write("=" * 67 + '\n') | |
@@ -480,11 +494,21 b' class SvnDiffer(object):' | |||||
480 | if change == 'add': |
|
494 | if change == 'add': | |
481 | # TODO: johbo: SVN is missing a zero here compared to git |
|
495 | # TODO: johbo: SVN is missing a zero here compared to git | |
482 | buf.write("new file mode 10644\n") |
|
496 | buf.write("new file mode 10644\n") | |
|
497 | ||||
|
498 | #TODO(marcink): intro to binary detection of svn patches | |||
|
499 | # if self.binary_content: | |||
|
500 | # buf.write('GIT binary patch\n') | |||
|
501 | ||||
483 | buf.write("--- /dev/null\t(revision 0)\n") |
|
502 | buf.write("--- /dev/null\t(revision 0)\n") | |
484 | src_lines = [] |
|
503 | src_lines = [] | |
485 | else: |
|
504 | else: | |
486 | if change == 'delete': |
|
505 | if change == 'delete': | |
487 | buf.write("deleted file mode 10644\n") |
|
506 | buf.write("deleted file mode 10644\n") | |
|
507 | ||||
|
508 | #TODO(marcink): intro to binary detection of svn patches | |||
|
509 | # if self.binary_content: | |||
|
510 | # buf.write('GIT binary patch\n') | |||
|
511 | ||||
488 | buf.write("--- a/%s\t(revision %s)\n" % ( |
|
512 | buf.write("--- a/%s\t(revision %s)\n" % ( | |
489 | src_path, self.src_rev)) |
|
513 | src_path, self.src_rev)) | |
490 | src_lines = self._svn_readlines(self.src_root, src_full_path) |
|
514 | src_lines = self._svn_readlines(self.src_root, src_full_path) |
General Comments 0
You need to be logged in to leave comments.
Login now