| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -214,6 +214,9 @@ def diff(self, other=None, paths=None, create_patch=False, **kwargs): | |||
| 214 | 214 | Note | |
| 215 | 215 | Rename detection will only work if create_patch is True | |
| 216 | 216 | """ | |
| 217 | + # import it in a retared fashion to avoid dependency cycle | ||
| 218 | + from git.diff import Diff | ||
| 219 | + | ||
| 217 | 220 | args = list(self._diff_args[:]) | |
| 218 | 221 | args.append( "--abbrev=40" ) # we need full shas | |
| 219 | 222 | args.append( "--full-index" ) # get full index paths, not only filenames | |
@@ -237,9 +240,9 @@ def diff(self, other=None, paths=None, create_patch=False, **kwargs): | |||
| 237 | 240 | kwargs['as_process'] = True | |
| 238 | 241 | proc = self.repo.git.diff(*args, **kwargs) | |
| 239 | 242 | ||
| 240 | - diff_method = diff.Diff._index_from_raw_format | ||
| 243 | + diff_method = Diff._index_from_raw_format | ||
| 241 | 244 | if create_patch: | |
| 242 | - diff_method = diff.Diff._index_from_patch_format(self.repo, proc.stdout) | ||
| 245 | + diff_method = Diff._index_from_patch_format | ||
| 243 | 246 | return diff_method(self.repo, proc.stdout) | |
| 244 | 247 | ||
| 245 | 248 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,5 +28,35 @@ def test_diff_with_rename(self): | |||
| 28 | 28 | assert_equal(diff.rename_from, 'AUTHORS') | |
| 29 | 29 | assert_equal(diff.rename_to, 'CONTRIBUTORS') | |
| 30 | 30 | ||
| 31 | + def test_diff_patch_format(self): | ||
| 32 | + # test all of the 'old' format diffs for completness - it should at least | ||
| 33 | + # be able to deal with it | ||
| 34 | + fixtures = ("diff_2", "diff_2f", "diff_f", "diff_i", "diff_mode_only", | ||
| 35 | + "diff_new_mode", "diff_numstat", "diff_p", "diff_rename", | ||
| 36 | + "diff_tree_numstat_root" ) | ||
| 37 | + | ||
| 38 | + for fixture_name in fixtures: | ||
| 39 | + diff_proc = ListProcessAdapter(fixture(fixture_name)) | ||
| 40 | + diffs = Diff._index_from_patch_format(self.repo, diff_proc.stdout) | ||
| 41 | + # END for each fixture | ||
| 42 | + | ||
| 31 | 43 | def test_diff_interface(self): | |
| 44 | + # test a few variations of the main diff routine | ||
| 45 | + for i, commit in enumerate(self.repo.iter_commits('0.1.6', max_count=10)): | ||
| 46 | + diff_item = commit | ||
| 47 | + if i%2 == 0: | ||
| 48 | + diff_item = commit.tree | ||
| 49 | + # END use tree every second item | ||
| 50 | + | ||
| 51 | + for other in (None, commit.parents[0]): | ||
| 52 | + for paths in (None, "CHANGES", ("CHANGES", "lib")): | ||
| 53 | + for create_patch in range(2): | ||
| 54 | + diff_index = diff_item.diff(other, paths, create_patch) | ||
| 55 | + assert diff_index | ||
| 56 | + # END for each patch option | ||
| 57 | + # END for each path option | ||
| 58 | + # END for each other side | ||
| 59 | + # END for each commit | ||
| 60 | + | ||
| 61 | + | ||
| 32 | 62 | self.fail( "TODO: Test full diff interface on commits, trees, index, patch and non-patch" ) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments