Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ jobs:
if: "matrix.os == 'windows-latest'"
- name: Run mypy
run: |
python -m pip install mypy types-PyYAML types-paramiko types-setuptools
python -m pip install mypy types-PyYAML types-paramiko types-setuptools typing-extensions
python -m mypy breezy
if: "matrix.python-version != 'pypy3'"
24 changes: 17 additions & 7 deletions breezy/git/filegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def find_last_change_revision(self, path, commit_id):
store = self.store
while True:
commit = store[commit_id]
if path == b"":
# For the root directory, use the tree itself
# TODO: dulwich >= 0.24.0 supports passing b"" to tree_lookup_path()
# This workaround can be removed when the minimum dulwich version is >= 0.24.0
target_mode = stat.S_IFDIR
target_sha = commit.tree
break
try:
target_mode, target_sha = tree_lookup_path(
store.__getitem__, commit.tree, path
Expand All @@ -52,24 +59,27 @@ def find_last_change_revision(self, path, commit_id):
path = posixpath.relpath(path, e.path)
else:
break
if path == b"":
target_mode = stat.S_IFDIR
if target_mode is None:
raise AssertionError(f"sha {target_sha!r} for {path!r} in {commit_id!r}")
while True:
parent_commits = []
for parent_id in commit.parents:
try:
parent_commit = store[parent_id]
mode, sha = tree_lookup_path(
store.__getitem__, parent_commit.tree, path
)
if path == b"":
# For the root directory, use the tree itself
# TODO: dulwich >= 0.24.0 supports passing b"" to tree_lookup_path()
# This workaround can be removed when the minimum dulwich version is >= 0.24.0
mode = stat.S_IFDIR
sha = parent_commit.tree
else:
mode, sha = tree_lookup_path(
store.__getitem__, parent_commit.tree, path
)
except (KeyError, NotTreeError):
continue
else:
parent_commits.append(parent_commit)
if path == b"":
mode = stat.S_IFDIR
# Candidate found iff, mode or text changed,
# or is a directory that didn't previously exist.
if mode != target_mode or (
Expand Down
7 changes: 7 additions & 0 deletions breezy/git/transportgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,13 @@ def _remove_loose_object(self, sha):
path = osutils.joinpath(self._split_loose_object(sha))
self.transport.delete(urlutils.quote(path))

def delete_loose_object(self, sha):
"""Delete a loose object.

This method is called by dulwich's pack_loose_objects method.
"""
self._remove_loose_object(sha)

def _get_loose_object(self, sha):
path = osutils.joinpath(self._split_loose_object(sha))
try:
Expand Down
Loading