Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions breezy/git/tests/test_blackbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,34 +321,17 @@ def test_diff_format(self):
["diff", "--color=never", "--format=git"], retcode=1
)
self.assertEqual(error, "")
# Some older versions of Dulwich (< 0.19.12) formatted diffs slightly
# differently.
from dulwich import __version__ as dulwich_version

if dulwich_version < (0, 19, 12):
self.assertEqual(
output,
"diff --git /dev/null b/a\n"
"old mode 0\n"
"new mode 100644\n"
"index 0000000..c197bd8 100644\n"
"--- /dev/null\n"
"+++ b/a\n"
"@@ -0,0 +1 @@\n"
"+contents of a\n",
)
else:
self.assertEqual(
output,
"diff --git a/a b/a\n"
"old file mode 0\n"
"new file mode 100644\n"
"index 0000000..c197bd8 100644\n"
"--- /dev/null\n"
"+++ b/a\n"
"@@ -0,0 +1 @@\n"
"+contents of a\n",
)
self.assertEqual(
output,
"diff --git a/a b/a\n"
"old file mode 0\n"
"new file mode 100644\n"
"index 0000000..c197bd8 100644\n"
"--- /dev/null\n"
"+++ b/a\n"
"@@ -0,0 +1 @@\n"
"+contents of a\n",
)

def test_git_import_uncolocated(self):
r = GitRepo.init("a", mkdir=True)
Expand Down
99 changes: 48 additions & 51 deletions breezy/git/tests/test_workingtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import os
import stat

from dulwich import __version__ as dulwich_version
from dulwich.diff_tree import RenameDetector, tree_changes
from dulwich.diff_tree import TreeChange as DulwichTreeChange
from dulwich.index import ConflictedIndexEntry, IndexEntry
Expand Down Expand Up @@ -264,23 +263,22 @@ def test_renamed_file(self):
],
tree_id=oldt.id,
)
if dulwich_version >= (0, 19, 15):
self.expectDelta(
[
DulwichTreeChange(
type="modify",
old=TreeEntry(b"", stat.S_IFDIR, oldt.id),
new=TreeEntry(b"", stat.S_IFDIR, newt.id),
),
DulwichTreeChange(
type="rename",
old=TreeEntry(b"a", stat.S_IFREG | 0o644, a.id),
new=TreeEntry(b"b", stat.S_IFREG | 0o644, a.id),
),
],
tree_id=oldt.id,
rename_detector=RenameDetector(self.store),
)
self.expectDelta(
[
DulwichTreeChange(
type="modify",
old=TreeEntry(b"", stat.S_IFDIR, oldt.id),
new=TreeEntry(b"", stat.S_IFDIR, newt.id),
),
DulwichTreeChange(
type="rename",
old=TreeEntry(b"a", stat.S_IFREG | 0o644, a.id),
new=TreeEntry(b"b", stat.S_IFREG | 0o644, a.id),
),
],
tree_id=oldt.id,
rename_detector=RenameDetector(self.store),
)

def test_copied_file(self):
self.build_tree(["a"])
Expand Down Expand Up @@ -311,39 +309,38 @@ def test_copied_file(self):
tree_id=oldt.id,
)

if dulwich_version >= (0, 19, 15):
self.expectDelta(
[
DulwichTreeChange(
type="modify",
old=TreeEntry(b"", stat.S_IFDIR, oldt.id),
new=TreeEntry(b"", stat.S_IFDIR, newt.id),
),
DulwichTreeChange(
type="copy",
old=TreeEntry(b"a", stat.S_IFREG | 0o644, a.id),
new=TreeEntry(b"b", stat.S_IFREG | 0o644, a.id),
),
],
tree_id=oldt.id,
rename_detector=RenameDetector(self.store, find_copies_harder=True),
)
self.expectDelta(
[
DulwichTreeChange(
type="modify",
old=TreeEntry(b"", stat.S_IFDIR, oldt.id),
new=TreeEntry(b"", stat.S_IFDIR, newt.id),
),
DulwichTreeChange(
type="add",
old=None,
new=TreeEntry(b"b", stat.S_IFREG | 0o644, a.id),
),
],
tree_id=oldt.id,
rename_detector=RenameDetector(self.store, find_copies_harder=False),
)
self.expectDelta(
[
DulwichTreeChange(
type="modify",
old=TreeEntry(b"", stat.S_IFDIR, oldt.id),
new=TreeEntry(b"", stat.S_IFDIR, newt.id),
),
DulwichTreeChange(
type="copy",
old=TreeEntry(b"a", stat.S_IFREG | 0o644, a.id),
new=TreeEntry(b"b", stat.S_IFREG | 0o644, a.id),
),
],
tree_id=oldt.id,
rename_detector=RenameDetector(self.store, find_copies_harder=True),
)
self.expectDelta(
[
DulwichTreeChange(
type="modify",
old=TreeEntry(b"", stat.S_IFDIR, oldt.id),
new=TreeEntry(b"", stat.S_IFDIR, newt.id),
),
DulwichTreeChange(
type="add",
old=None,
new=TreeEntry(b"b", stat.S_IFREG | 0o644, a.id),
),
],
tree_id=oldt.id,
rename_detector=RenameDetector(self.store, find_copies_harder=False),
)

def test_added_unknown_file(self):
self.build_tree(["a"])
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"fastbencode",
"patiencediff",
"merge3",
"dulwich>=0.24.3",
"dulwich>=0.24.3,<0.26",
"urllib3>=1.24.1",
"pyyaml",
"tzlocal",
Expand Down
Loading