Show More
@@ -375,11 +375,18 b' class SvnRemote(object):' | |||
|
375 | 375 | |
|
376 | 376 | def diff(self, wire, rev1, rev2, path1=None, path2=None, |
|
377 | 377 | ignore_whitespace=False, context=3): |
|
378 | ||
|
378 | 379 | wire.update(cache=False) |
|
379 | 380 | repo = self._factory.repo(wire) |
|
380 | 381 | diff_creator = SvnDiffer( |
|
381 | 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 | 392 | class SvnDiffer(object): |
@@ -450,23 +457,30 b' class SvnDiffer(object):' | |||
|
450 | 457 | buf, change, path, self.tgt_path, path, self.src_path) |
|
451 | 458 | |
|
452 | 459 | def _generate_file_diff(self, buf): |
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
460 | change = None | |
|
461 | if self.src_kind == svn.core.svn_node_none: | |
|
462 | change = "add" | |
|
463 | elif self.tgt_kind == svn.core.svn_node_none: | |
|
464 | change = "delete" | |
|
465 | tgt_base, tgt_path = vcspath.split(self.tgt_path) | |
|
466 | src_base, src_path = vcspath.split(self.src_path) | |
|
467 | self._generate_node_diff( | |
|
468 | buf, change, tgt_path, tgt_base, src_path, src_base) | |
|
462 | 469 | |
|
463 | 470 | def _generate_node_diff( |
|
464 | 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 | 478 | tgt_full_path = vcspath.join(tgt_base, tgt_path) |
|
466 | 479 | src_full_path = vcspath.join(src_base, src_path) |
|
467 | 480 | |
|
468 | 481 | self.binary_content = False |
|
469 | 482 | mime_type = self._get_mime_type(tgt_full_path) |
|
483 | ||
|
470 | 484 | if mime_type and not mime_type.startswith('text'): |
|
471 | 485 | self.binary_content = True |
|
472 | 486 | buf.write("=" * 67 + '\n') |
@@ -480,11 +494,21 b' class SvnDiffer(object):' | |||
|
480 | 494 | if change == 'add': |
|
481 | 495 | # TODO: johbo: SVN is missing a zero here compared to git |
|
482 | 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 | 502 | buf.write("--- /dev/null\t(revision 0)\n") |
|
484 | 503 | src_lines = [] |
|
485 | 504 | else: |
|
486 | 505 | if change == 'delete': |
|
487 | 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 | 512 | buf.write("--- a/%s\t(revision %s)\n" % ( |
|
489 | 513 | src_path, self.src_rev)) |
|
490 | 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