Просмотр исходного кода

Fix use of deprecated FetchPackResult attributes. Fixes #590

Jelmer Vernooij 7 лет назад
Родитель
Сommit
b3fc64cfb9
3 измененных файлов с 12 добавлено и 10 удалено
  1. 4 2
      dulwich/client.py
  2. 7 7
      dulwich/porcelain.py
  3. 1 1
      dulwich/tests/test_client.py

+ 4 - 2
dulwich/client.py

@@ -1012,11 +1012,13 @@ class LocalGitClient(GitClient):
             to fetch. Receives dictionary of name->sha, should return
             list of shas to fetch. Defaults to all shas.
         :param progress: Optional progress function
-        :return: Dictionary with all remote refs (not just those fetched)
+        :return: FetchPackResult object
         """
         with self._open_repo(path) as r:
-            return r.fetch(target, determine_wants=determine_wants,
+            refs = r.fetch(target, determine_wants=determine_wants,
                            progress=progress)
+            return FetchPackResult(r.get_refs(), r.refs.get_symrefs(),
+                                   agent_string())
 
     def fetch_pack(self, path, determine_wants, graph_walker, pack_data,
                    progress=None):

+ 7 - 7
dulwich/porcelain.py

@@ -305,16 +305,16 @@ def clone(source, target=None, bare=False, checkout=None,
     else:
         r = Repo.init(target)
     try:
-        remote_refs = client.fetch(
+        fetch_result = client.fetch(
             host_path, r, determine_wants=r.object_store.determine_wants_all,
             progress=errstream.write)
         r.refs.import_refs(
             b'refs/remotes/' + origin,
-            {n[len(b'refs/heads/'):]: v for (n, v) in remote_refs.items()
+            {n[len(b'refs/heads/'):]: v for (n, v) in fetch_result.refs.items()
                 if n.startswith(b'refs/heads/')})
         r.refs.import_refs(
             b'refs/tags',
-            {n[len(b'refs/tags/'):]: v for (n, v) in remote_refs.items()
+            {n[len(b'refs/tags/'):]: v for (n, v) in fetch_result.refs.items()
                 if n.startswith(b'refs/tags/') and
                 not n.endswith(ANNOTATED_TAG_SUFFIX)})
         target_config = r.get_config()
@@ -328,7 +328,7 @@ def clone(source, target=None, bare=False, checkout=None,
         # TODO(jelmer): Support symref capability,
         # https://github.com/jelmer/dulwich/issues/485
         try:
-            head = r[remote_refs[b"HEAD"]]
+            head = r[fetch_result.refs[b"HEAD"]]
         except KeyError:
             head = None
         else:
@@ -814,12 +814,12 @@ def pull(repo, remote_location=None, refspecs=None,
             return [remote_refs[lh] for (lh, rh, force) in selected_refs]
         client, path = get_transport_and_path(
                 remote_location, config=r.get_config_stack())
-        remote_refs = client.fetch(
+        fetch_result = client.fetch(
             path, r, progress=errstream.write, determine_wants=determine_wants)
         for (lh, rh, force) in selected_refs:
-            r.refs[rh] = remote_refs[lh]
+            r.refs[rh] = fetch_result.refs[lh]
         if selected_refs:
-            r[b'HEAD'] = remote_refs[selected_refs[0][1]]
+            r[b'HEAD'] = fetch_result.refs[selected_refs[0][1]]
 
         # Perform 'git checkout .' - syncs staged changes
         tree = r[b"HEAD"].tree

+ 1 - 1
dulwich/tests/test_client.py

@@ -747,7 +747,7 @@ class LocalGitClientTests(TestCase):
         t = MemoryRepo()
         s = open_repo('a.git')
         self.addCleanup(tear_down_repo, s)
-        self.assertEqual(s.get_refs(), c.fetch(s.path, t))
+        self.assertEqual(s.get_refs(), c.fetch(s.path, t).refs)
 
     def test_fetch_empty(self):
         c = LocalGitClient()