|
@@ -103,9 +103,19 @@ from dulwich.pack import (
|
|
)
|
|
)
|
|
from dulwich.refs import (
|
|
from dulwich.refs import (
|
|
read_info_refs,
|
|
read_info_refs,
|
|
|
|
+ ANNOTATED_TAG_SUFFIX,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
+class InvalidWants(Exception):
|
|
|
|
+ """Invalid wants."""
|
|
|
|
+
|
|
|
|
+ def __init__(self, wants):
|
|
|
|
+ Exception.__init__(
|
|
|
|
+ self,
|
|
|
|
+ "requested wants not in server provided refs: %r" % wants)
|
|
|
|
+
|
|
|
|
+
|
|
def _fileno_can_read(fileno):
|
|
def _fileno_can_read(fileno):
|
|
"""Check if a file descriptor is readable."""
|
|
"""Check if a file descriptor is readable."""
|
|
return len(select.select([fileno], [], [], 0)[0]) > 0
|
|
return len(select.select([fileno], [], [], 0)[0]) > 0
|
|
@@ -613,6 +623,19 @@ class GitClient(object):
|
|
pack_data(data)
|
|
pack_data(data)
|
|
|
|
|
|
|
|
|
|
|
|
+def check_wants(wants, refs):
|
|
|
|
+ """Check that a set of wants is valid.
|
|
|
|
+
|
|
|
|
+ :param wants: Set of object SHAs to fetch
|
|
|
|
+ :param refs: Refs dictionary to check against
|
|
|
|
+ """
|
|
|
|
+ missing = set(wants) - {
|
|
|
|
+ v for (k, v) in refs.items()
|
|
|
|
+ if not k.endswith(ANNOTATED_TAG_SUFFIX)}
|
|
|
|
+ if missing:
|
|
|
|
+ raise InvalidWants(missing)
|
|
|
|
+
|
|
|
|
+
|
|
class TraditionalGitClient(GitClient):
|
|
class TraditionalGitClient(GitClient):
|
|
"""Traditional Git client."""
|
|
"""Traditional Git client."""
|
|
|
|
|