Merge lp:~jelmer/brz/submodule-errors into lp:brz/3.3

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7732
Merged at revision: 7727
Proposed branch: lp:~jelmer/brz/submodule-errors
Merge into: lp:brz/3.3
Diff against target: 1298 lines (+237/-125)
37 files modified
breezy/archive/__init__.py (+7/-4)
breezy/branch.py (+12/-12)
breezy/bzr/bundle/serializer/__init__.py (+2/-3)
breezy/bzr/chk_map.py (+2/-1)
breezy/bzr/inventorytree.py (+14/-7)
breezy/bzr/remote.py (+3/-2)
breezy/bzr/smart/request.py (+1/-1)
breezy/bzr/versionedfile.py (+2/-1)
breezy/bzr/workingtree.py (+5/-1)
breezy/bzr/workingtree_4.py (+13/-7)
breezy/config.py (+5/-5)
breezy/conflicts.py (+1/-1)
breezy/diff.py (+2/-2)
breezy/directory_service.py (+4/-2)
breezy/filters/__init__.py (+2/-2)
breezy/forge.py (+1/-1)
breezy/git/cache.py (+1/-1)
breezy/git/tests/test_remote.py (+2/-1)
breezy/git/tree.py (+15/-7)
breezy/git/workingtree.py (+12/-3)
breezy/inter.py (+17/-3)
breezy/log.py (+4/-3)
breezy/mail_client.py (+4/-3)
breezy/merge.py (+2/-1)
breezy/option.py (+2/-2)
breezy/registry.py (+30/-12)
breezy/repository.py (+2/-2)
breezy/revisionspec.py (+1/-1)
breezy/send.py (+2/-1)
breezy/tag.py (+5/-4)
breezy/tests/__init__.py (+2/-2)
breezy/tests/per_tree/test_test_trees.py (+13/-0)
breezy/transform.py (+2/-1)
breezy/transport/__init__.py (+2/-2)
breezy/tree.py (+40/-22)
breezy/urlutils.py (+1/-1)
breezy/version_info_formats/__init__.py (+2/-1)
To merge this branch: bzr merge lp:~jelmer/brz/submodule-errors
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+432912@code.launchpad.net

Commit message

Raise MissingNestedTree from get_nested_tree().

Description of the change

Raise MissingNestedTree from get_nested_tree().

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Download full text (71.6 KiB)

The attempt to merge lp:~jelmer/brz/submodule-errors into lp:brz/3.3 failed. Command exited with 2.
Below is the output from the failed tests.

Collecting setuptools-gettext
  Downloading setuptools_gettext-0.1.1-py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools>=46.1 in ./lib/python3.10/site-packages (from setuptools-gettext) (65.5.0)
Installing collected packages: setuptools-gettext
Successfully installed setuptools-gettext-0.1.1
Obtaining file:///tmp/tarmac/branch.e1se2p1p
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: fastbencode in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.12)
Requirement already satisfied: merge3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.8)
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.26.12)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (6.0)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (5.0.6)
Requirement already satisfied: dulwich>=0.20.46 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.20.50)
Requirement already satisfied: patiencediff in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.2.3)
Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (2.10.4)
Collecting testtools
  Downloading testtools-2.5.0-py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 182.0/182.0 kB 5.2 MB/s eta 0:00:00
Collecting python-subunit
  Downloading python_subunit-1.4.1-py3-none-any.whl (106 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 106.7/106.7 kB 6.0 MB/s eta 0:00:00
Requirement already satisfied: gpg in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.18.0)
Requirement already satisfied: launchpadlib>=1.6.3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.10.17)
Collecting sphinx
  Downloading sphinx-5.3.0-py3-none-any.whl (3.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 8.5 MB/s eta 0:00:00
Requirement already satisfied: setuptools in ./lib/python3.10/site-packages (from breezy==3.3.1.dev0) (65.5.0)
Collecting sphinx-epytext
  Downloading sphinx-epytext-0.0.4.tar.gz (3.6 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting fastimport
  Downloading fastimport-0.9.14.tar.gz (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.8/41.8 kB 3.2 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: httplib2 in /usr/lib/python3/dist-packages (fro...

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Download full text (25.3 KiB)

The attempt to merge lp:~jelmer/brz/submodule-errors into lp:brz/3.3 failed. Command exited with 2.
Below is the output from the failed tests.

Collecting setuptools-gettext
  Downloading setuptools_gettext-0.1.1-py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools>=46.1 in ./lib/python3.10/site-packages (from setuptools-gettext) (65.5.0)
Installing collected packages: setuptools-gettext
Successfully installed setuptools-gettext-0.1.1
Obtaining file:///tmp/tarmac/branch.26cy532d
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: fastbencode in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.12)
Requirement already satisfied: dulwich>=0.20.46 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.20.50)
Requirement already satisfied: merge3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.8)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (5.0.6)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (6.0)
Requirement already satisfied: patiencediff in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.2.3)
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.26.12)
Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (2.10.4)
Collecting python-subunit
  Downloading python_subunit-1.4.1-py3-none-any.whl (106 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 106.7/106.7 kB 158.5 kB/s eta 0:00:00
Collecting testtools
  Downloading testtools-2.5.0-py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 182.0/182.0 kB 5.9 MB/s eta 0:00:00
Requirement already satisfied: gpg in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.18.0)
Requirement already satisfied: setuptools in ./lib/python3.10/site-packages (from breezy==3.3.1.dev0) (65.5.0)
Collecting sphinx
  Downloading sphinx-5.3.0-py3-none-any.whl (3.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 7.6 MB/s eta 0:00:00
Collecting sphinx-epytext
  Downloading sphinx-epytext-0.0.4.tar.gz (3.6 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting fastimport
  Downloading fastimport-0.9.14.tar.gz (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.8/41.8 kB 3.6 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: launchpadlib>=1.6.3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.10.17)
Requirement already satisfied: httplib2 in /usr/lib/python3/dist-packages (fro...

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Download full text (71.5 KiB)

The attempt to merge lp:~jelmer/brz/submodule-errors into lp:brz/3.3 failed. Command exited with 2.
Below is the output from the failed tests.

Collecting setuptools-gettext
  Downloading setuptools_gettext-0.1.1-py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools>=46.1 in ./lib/python3.10/site-packages (from setuptools-gettext) (65.5.0)
Installing collected packages: setuptools-gettext
Successfully installed setuptools-gettext-0.1.1
Obtaining file:///tmp/tarmac/branch.y_8_ni9u
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: dulwich>=0.20.46 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.20.50)
Requirement already satisfied: fastbencode in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.12)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (5.0.6)
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.26.12)
Requirement already satisfied: merge3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.8)
Requirement already satisfied: patiencediff in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.2.3)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (6.0)
Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (2.10.4)
Collecting testtools
  Downloading testtools-2.5.0-py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 182.0/182.0 kB 2.7 MB/s eta 0:00:00
Collecting python-subunit
  Downloading python_subunit-1.4.1-py3-none-any.whl (106 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 106.7/106.7 kB 6.5 MB/s eta 0:00:00
Collecting sphinx
  Downloading sphinx-5.3.0-py3-none-any.whl (3.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 6.3 MB/s eta 0:00:00
Collecting sphinx-epytext
  Downloading sphinx-epytext-0.0.4.tar.gz (3.6 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: setuptools in ./lib/python3.10/site-packages (from breezy==3.3.1.dev0) (65.5.0)
Collecting fastimport
  Downloading fastimport-0.9.14.tar.gz (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.8/41.8 kB 3.0 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: gpg in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.18.0)
Requirement already satisfied: launchpadlib>=1.6.3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.10.17)
Requirement already satisfied: httplib2 in /usr/lib/python3/dist-packages (fro...

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Download full text (13.0 KiB)

The attempt to merge lp:~jelmer/brz/submodule-errors into lp:brz/3.3 failed. Command exited with 1.
Below is the output from the failed tests.

Collecting setuptools-gettext
  Using cached setuptools_gettext-0.1.1-py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools>=46.1 in ./lib/python3.10/site-packages (from setuptools-gettext) (65.5.0)
Installing collected packages: setuptools-gettext
Successfully installed setuptools-gettext-0.1.1
Obtaining file:///tmp/tarmac/branch.8xn6rxt_
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: merge3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.8)
Requirement already satisfied: fastbencode in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.12)
Requirement already satisfied: patiencediff in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.2.3)
Requirement already satisfied: dulwich>=0.20.46 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.20.50)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (5.0.6)
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.26.12)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (6.0)
Collecting testtools
  Using cached testtools-2.5.0-py3-none-any.whl (181 kB)
Collecting python-subunit
  Using cached python_subunit-1.4.1-py3-none-any.whl (106 kB)
Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (2.10.4)
Collecting sphinx
  Using cached sphinx-5.3.0-py3-none-any.whl (3.2 MB)
Requirement already satisfied: setuptools in ./lib/python3.10/site-packages (from breezy==3.3.1.dev0) (65.5.0)
Collecting sphinx-epytext
  Using cached sphinx-epytext-0.0.4.tar.gz (3.6 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting fastimport
  Using cached fastimport-0.9.14.tar.gz (41 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: launchpadlib>=1.6.3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.10.17)
Requirement already satisfied: gpg in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.18.0)
Requirement already satisfied: httplib2 in /usr/lib/python3/dist-packages (from launchpadlib>=1.6.3->breezy==3.3.1.dev0) (0.20.4)
Collecting keyring
  Using cached keyring-23.11.0-py3-none-any.whl (36 kB)
Requirement already satisfied: lazr.restfulclient>=0.9.19 in /usr/lib/python3/dist-packages (from launchpadlib>=1.6.3->breezy==3.3.1.dev0) (0.14.5)
Requirement already satisfied: lazr.uri...

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Download full text (12.9 KiB)

The attempt to merge lp:~jelmer/brz/submodule-errors into lp:brz/3.3 failed. Command exited with 1.
Below is the output from the failed tests.

Collecting setuptools-gettext
  Downloading setuptools_gettext-0.1.1-py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools>=46.1 in ./lib/python3.10/site-packages (from setuptools-gettext) (65.5.0)
Installing collected packages: setuptools-gettext
Successfully installed setuptools-gettext-0.1.1
Obtaining file:///tmp/tarmac/branch.0cd3dkat
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: dulwich>=0.20.46 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.20.50)
Requirement already satisfied: merge3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.8)
Requirement already satisfied: fastbencode in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.0.12)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (5.0.6)
Requirement already satisfied: patiencediff in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (0.2.3)
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.26.12)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (6.0)
Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (2.10.4)
Collecting python-subunit
  Downloading python_subunit-1.4.1-py3-none-any.whl (106 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 106.7/106.7 kB 3.0 MB/s eta 0:00:00
Collecting testtools
  Downloading testtools-2.5.0-py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 182.0/182.0 kB 5.7 MB/s eta 0:00:00
Requirement already satisfied: launchpadlib>=1.6.3 in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.10.17)
Collecting fastimport
  Downloading fastimport-0.9.14.tar.gz (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.8/41.8 kB 2.2 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting sphinx-epytext
  Downloading sphinx-epytext-0.0.4.tar.gz (3.6 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: setuptools in ./lib/python3.10/site-packages (from breezy==3.3.1.dev0) (65.5.0)
Collecting sphinx
  Downloading sphinx-5.3.0-py3-none-any.whl (3.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 7.6 MB/s eta 0:00:00
Requirement already satisfied: gpg in /usr/lib/python3/dist-packages (from breezy==3.3.1.dev0) (1.18.0)
Requirement already satisfied: httplib2 in /usr/lib/python3/dist-packages (fro...

lp:~jelmer/brz/submodule-errors updated
7732. By Jelmer Vernooij

Fix tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/archive/__init__.py'
2--- breezy/archive/__init__.py 2022-10-28 13:46:03 +0000
3+++ breezy/archive/__init__.py 2022-11-15 00:30:45 +0000
4@@ -19,6 +19,7 @@
5
6 import os
7 import time
8+from typing import Iterator, cast
9 import warnings
10
11 from .. import (
12@@ -77,14 +78,16 @@
13
14
15 def create_archive(format, tree, name, root=None, subdir=None,
16- force_mtime=None, recurse_nested=False):
17+ force_mtime=None, recurse_nested=False) -> Iterator[bytes]:
18 try:
19 archive_fn = format_registry.get(format)
20 except KeyError as exc:
21 raise errors.NoSuchExportFormat(format) from exc
22- return archive_fn(tree, name, root=root, subdir=subdir,
23- force_mtime=force_mtime,
24- recurse_nested=recurse_nested)
25+ return cast(Iterator[bytes],
26+ archive_fn(
27+ tree, name, root=root, subdir=subdir,
28+ force_mtime=force_mtime,
29+ recurse_nested=recurse_nested))
30
31
32 format_registry = ArchiveFormatRegistry()
33
34=== modified file 'breezy/branch.py'
35--- breezy/branch.py 2022-10-30 14:30:21 +0000
36+++ breezy/branch.py 2022-11-15 00:30:45 +0000
37@@ -16,7 +16,7 @@
38
39 __docformat__ = "google"
40
41-from typing import Optional, Tuple, List, Type
42+from typing import Optional, Tuple, List, Type, cast
43
44 from .lazy_import import lazy_import
45 lazy_import(globals(), """
46@@ -708,7 +708,7 @@
47 return InterBranch.get(from_branch, self).fetch(
48 stop_revision, limit=limit, lossy=lossy)
49
50- def get_bound_location(self):
51+ def get_bound_location(self) -> Optional[str]:
52 """Return the URL of the branch we are bound to.
53
54 Older format branches cannot bind, please be sure to use a metadir
55@@ -1088,7 +1088,7 @@
56 """Return `Tree` object for last revision."""
57 return self.repository.revision_tree(self.last_revision())
58
59- def get_parent(self):
60+ def get_parent(self) -> Optional[str]:
61 """Return the parent location of the branch.
62
63 This is the default location for pull/missing. The usual
64@@ -1120,26 +1120,26 @@
65 url = urlutils.relative_url(self.base, url)
66 config.set(name, url)
67
68- def _get_config_location(self, name, config=None):
69+ def _get_config_location(self, name: str, config=None) -> Optional[str]:
70 if config is None:
71 config = self.get_config_stack()
72 location = config.get(name)
73 if location == '':
74 location = None
75- return location
76+ return cast(Optional[str], location)
77
78 def get_child_submit_format(self):
79 """Return the preferred format of submissions to this branch."""
80 return self.get_config_stack().get('child_submit_format')
81
82- def get_submit_branch(self):
83+ def get_submit_branch(self) -> Optional[str]:
84 """Return the submit location of the branch.
85
86 This is the default location for bundle. The usual
87 pattern is that the user can override it by specifying a
88 location.
89 """
90- return self.get_config_stack().get('submit_branch')
91+ return cast(Optional[str], self.get_config_stack().get('submit_branch'))
92
93 def set_submit_branch(self, location):
94 """Return the submit location of the branch.
95@@ -1150,7 +1150,7 @@
96 """
97 self.get_config_stack().set('submit_branch', location)
98
99- def get_public_branch(self):
100+ def get_public_branch(self) -> Optional[str]:
101 """Return the public location of the branch.
102
103 This is used by merge directives.
104@@ -1166,9 +1166,9 @@
105 """
106 self._set_config_location('public_branch', location)
107
108- def get_push_location(self):
109+ def get_push_location(self) -> Optional[str]:
110 """Return None or the location to push this branch to."""
111- return self.get_config_stack().get('push_location')
112+ return cast(str, self.get_config_stack().get('push_location'))
113
114 def set_push_location(self, location):
115 """Set a new push location for this branch."""
116@@ -2091,7 +2091,7 @@
117 note(gettext('found error:%s'), error)
118
119
120-class InterBranch(InterObject):
121+class InterBranch(InterObject[Branch]):
122 """This class represents operations taking place between two branches.
123
124 Its instances have methods like pull() and push() and contain
125@@ -2099,7 +2099,7 @@
126 can be carried out on.
127 """
128
129- _optimisers: List[Type["InterBranch"]] = []
130+ _optimisers = []
131 """The available optimised InterBranch types."""
132
133 @classmethod
134
135=== modified file 'breezy/bzr/bundle/serializer/__init__.py'
136--- breezy/bzr/bundle/serializer/__init__.py 2020-02-18 01:57:45 +0000
137+++ breezy/bzr/bundle/serializer/__init__.py 2022-11-15 00:30:45 +0000
138@@ -39,9 +39,6 @@
139 br'^# Bazaar-NG changeset v(?P<version>\d+[\w.]*)(?P<lineending>\r?)\n$')
140
141
142-serializer_registry = registry.Registry()
143-
144-
145 def _get_bundle_header(version):
146 return b''.join([BUNDLE_HEADER, version.encode('ascii'), b'\n'])
147
148@@ -157,6 +154,8 @@
149 to_file.write(b'\n')
150
151
152+serializer_registry = registry.Registry[str, BundleSerializer]()
153+
154 serializer_registry.register_lazy(
155 '0.8', __name__ + '.v08', 'BundleSerializerV08')
156 serializer_registry.register_lazy(
157
158=== modified file 'breezy/bzr/chk_map.py'
159--- breezy/bzr/chk_map.py 2022-07-16 12:50:01 +0000
160+++ breezy/bzr/chk_map.py 2022-11-15 00:30:45 +0000
161@@ -39,6 +39,7 @@
162
163 import heapq
164 import threading
165+from typing import Callable
166
167 from .. import (
168 errors,
169@@ -91,7 +92,7 @@
170 return b'\x00'.join(key)
171
172
173-search_key_registry = registry.Registry()
174+search_key_registry = registry.Registry[bytes, Callable[[bytes], bytes]]()
175 search_key_registry.register(b'plain', _search_key_plain)
176
177
178
179=== modified file 'breezy/bzr/inventorytree.py'
180--- breezy/bzr/inventorytree.py 2022-10-29 11:59:45 +0000
181+++ breezy/bzr/inventorytree.py 2022-11-15 00:30:45 +0000
182@@ -304,11 +304,15 @@
183 def iter_entries(inv):
184 for p, e in inv.iter_entries_by_dir(specific_file_ids=inventory_file_ids):
185 if e.kind == 'tree-reference' and recurse_nested:
186- subtree = self._get_nested_tree(p, e.file_id, e.reference_revision)
187- with subtree.lock_read():
188- subinv = subtree.root_inventory
189- for subp, e in iter_entries(subinv):
190- yield (osutils.pathjoin(p, subp) if subp else p), e
191+ try:
192+ subtree = self._get_nested_tree(p, e.file_id, e.reference_revision)
193+ except errors.NotBranchError:
194+ yield p, e
195+ else:
196+ with subtree.lock_read():
197+ subinv = subtree.root_inventory
198+ for subp, e in iter_entries(subinv):
199+ yield (osutils.pathjoin(p, subp) if subp else p), e
200 else:
201 yield p, e
202 return iter_entries(self.root_inventory)
203@@ -1043,8 +1047,11 @@
204
205 def _get_nested_tree(self, path, file_id, reference_revision):
206 # Just a guess..
207- subdir = ControlDir.open_from_transport(
208- self._repository.user_transport.clone(path))
209+ try:
210+ subdir = ControlDir.open_from_transport(
211+ self._repository.user_transport.clone(path))
212+ except errors.NotBranchError as e:
213+ raise MissingNestedTree(path) from e
214 subrepo = subdir.find_repository()
215 try:
216 revtree = subrepo.revision_tree(reference_revision)
217
218=== modified file 'breezy/bzr/remote.py'
219--- breezy/bzr/remote.py 2022-10-29 02:25:39 +0000
220+++ breezy/bzr/remote.py 2022-11-15 00:30:45 +0000
221@@ -18,6 +18,7 @@
222 import os
223 import re
224 import sys
225+from typing import Callable
226 import zlib
227
228 import fastbencode as bencode
229@@ -4401,8 +4402,8 @@
230 return self._bzrdir._real_bzrdir
231
232
233-error_translators = registry.Registry()
234-no_context_error_translators = registry.Registry()
235+error_translators = registry.Registry[bytes, Callable]()
236+no_context_error_translators = registry.Registry[bytes, Callable]()
237
238
239 def _translate_error(err, **context):
240
241=== modified file 'breezy/bzr/smart/request.py'
242--- breezy/bzr/smart/request.py 2022-08-22 18:19:46 +0000
243+++ breezy/bzr/smart/request.py 2022-11-15 00:30:45 +0000
244@@ -542,7 +542,7 @@
245 # mutate State is updated in a way that replaying that request results in a
246 # different state. For example 'append' writes more bytes to a given
247 # file. If append succeeds, it moves the file pointer.
248-request_handlers = registry.Registry()
249+request_handlers = registry.Registry[bytes, SmartServerRequest]()
250 request_handlers.register_lazy(
251 b'append', 'breezy.bzr.smart.vfs', 'AppendRequest', info='mutate')
252 request_handlers.register_lazy(
253
254=== modified file 'breezy/bzr/versionedfile.py'
255--- breezy/bzr/versionedfile.py 2022-09-24 17:01:11 +0000
256+++ breezy/bzr/versionedfile.py 2022-11-15 00:30:45 +0000
257@@ -21,6 +21,7 @@
258 import itertools
259 import os
260 import struct
261+from typing import Tuple, Any
262 from zlib import adler32
263
264
265@@ -54,7 +55,7 @@
266 )
267
268
269-adapter_registry = Registry()
270+adapter_registry = Registry[Tuple[str, str], Any]()
271 adapter_registry.register_lazy(('knit-annotated-delta-gz', 'knit-delta-gz'),
272 'breezy.bzr.knit', 'DeltaAnnotatedToUnannotated')
273 adapter_registry.register_lazy(('knit-annotated-ft-gz', 'knit-ft-gz'),
274
275=== modified file 'breezy/bzr/workingtree.py'
276--- breezy/bzr/workingtree.py 2022-10-28 18:05:19 +0000
277+++ breezy/bzr/workingtree.py 2022-11-15 00:30:45 +0000
278@@ -78,6 +78,7 @@
279 from ..trace import mutter, note
280 from ..tree import (
281 get_canonical_path,
282+ MissingNestedTree,
283 TreeDirectory,
284 TreeEntry,
285 TreeFile,
286@@ -507,7 +508,10 @@
287 self.apply_inventory_delta(inv_delta)
288
289 def get_nested_tree(self, path):
290- return WorkingTree.open(self.abspath(path))
291+ try:
292+ return WorkingTree.open(self.abspath(path))
293+ except errors.NotBranchError as e:
294+ raise MissingNestedTree(path) from e
295
296 def _get_nested_tree(self, path, file_id, reference_revision):
297 return self.get_nested_tree(path)
298
299=== modified file 'breezy/bzr/workingtree_4.py'
300--- breezy/bzr/workingtree_4.py 2022-09-23 04:11:55 +0000
301+++ breezy/bzr/workingtree_4.py 2022-11-15 00:30:45 +0000
302@@ -467,14 +467,17 @@
303 # referenced tree's revision is whatever's currently there
304 try:
305 return self.get_nested_tree(path).last_revision()
306- except errors.NotBranchError:
307+ except MissingNestedTree:
308 entry = self._get_entry(path=path)
309 if entry == (None, None):
310- return False
311+ raise NoSuchFile(self, path)
312 return entry[1][0][1]
313
314 def get_nested_tree(self, path):
315- return WorkingTree.open(self.abspath(path))
316+ try:
317+ return WorkingTree.open(self.abspath(path))
318+ except errors.NotBranchError as e:
319+ raise MissingNestedTree(path)
320
321 def id2path(self, file_id, recurse='down'):
322 "Convert a file-id to a path."
323@@ -1793,12 +1796,15 @@
324 return self._get_nested_tree(path, None, nested_revid)
325
326 def _get_nested_tree(self, path, file_id, reference_revision):
327- branch = _mod_branch.Branch.open_from_transport(
328- self._nested_tree_transport.clone(path))
329+ try:
330+ branch = _mod_branch.Branch.open_from_transport(
331+ self._nested_tree_transport.clone(path))
332+ except errors.NotBranchError as e:
333+ raise MissingNestedTree(path) from e
334 try:
335 revtree = branch.repository.revision_tree(reference_revision)
336- except errors.NoSuchRevision:
337- raise MissingNestedTree(path)
338+ except errors.NoSuchRevision as e:
339+ raise MissingNestedTree(path) from e
340 if file_id is not None and revtree.path2id('') != file_id:
341 raise AssertionError('mismatching file id: %r != %r' % (
342 revtree.path2id(''), file_id))
343
344=== modified file 'breezy/config.py'
345--- breezy/config.py 2022-09-23 06:05:37 +0000
346+++ breezy/config.py 2022-11-15 00:30:45 +0000
347@@ -82,7 +82,7 @@
348 import configobj
349 from io import BytesIO
350
351-from typing import Tuple, Iterable, Dict
352+from typing import Tuple, Iterable, Dict, Callable, cast
353
354 import breezy
355 from .lazy_import import lazy_import
356@@ -286,8 +286,8 @@
357 return configobj.tsquot
358 return configobj.tdquot
359
360- def get_bool(self, section, key):
361- return self[section].as_bool(key)
362+ def get_bool(self, section, key) -> bool:
363+ return cast(bool, self[section].as_bool(key))
364
365 def get_value(self, section, name):
366 # Try [] for the old DEFAULT section.
367@@ -4065,9 +4065,9 @@
368 # The registered object should be a callable receiving a test instance
369 # parameter (inheriting from tests.TestCaseWithTransport) and returning a Store
370 # object.
371-test_store_builder_registry = registry.Registry()
372+test_store_builder_registry = registry.Registry[str, Callable]()
373
374 # The registered object should be a callable receiving a test instance
375 # parameter (inheriting from tests.TestCaseWithTransport) and returning a Stack
376 # object.
377-test_stack_builder_registry = registry.Registry()
378+test_stack_builder_registry = registry.Registry[str, Callable]()
379
380=== modified file 'breezy/conflicts.py'
381--- breezy/conflicts.py 2022-10-08 17:46:49 +0000
382+++ breezy/conflicts.py 2022-11-15 00:30:45 +0000
383@@ -71,7 +71,7 @@
384 self.outf.write(str(conflict) + '\n')
385
386
387-resolve_action_registry = registry.Registry()
388+resolve_action_registry = registry.Registry[str, str]()
389
390
391 resolve_action_registry.register(
392
393=== modified file 'breezy/diff.py'
394--- breezy/diff.py 2022-10-08 17:46:49 +0000
395+++ breezy/diff.py 2022-11-15 00:30:45 +0000
396@@ -19,7 +19,7 @@
397 import os
398 import re
399 import sys
400-from typing import Optional, List, Union
401+from typing import Optional, List, Union, Type
402
403 from .lazy_import import lazy_import
404 lazy_import(globals(), """
405@@ -1126,5 +1126,5 @@
406 raise errors.NoDiffFound(error_path)
407
408
409-format_registry = Registry()
410+format_registry = Registry[str, Type[DiffTree]]()
411 format_registry.register('default', DiffTree)
412
413=== modified file 'breezy/directory_service.py'
414--- breezy/directory_service.py 2021-03-22 21:07:08 +0000
415+++ breezy/directory_service.py 2022-11-15 00:30:45 +0000
416@@ -20,14 +20,16 @@
417 to true URLs. Examples include lp:urls and per-user location aliases.
418 """
419
420+from typing import Callable, Optional
421+
422 from . import (
423+ branch as _mod_branch,
424 errors,
425 registry,
426 )
427 from .lazy_import import lazy_import
428 lazy_import(globals(), """
429 from breezy import (
430- branch as _mod_branch,
431 controldir as _mod_controldir,
432 urlutils,
433 )
434@@ -114,7 +116,7 @@
435 supported. On error, a subclass of DirectoryLookupFailure will be raised.
436 """
437
438- branch_aliases = registry.Registry()
439+ branch_aliases = registry.Registry[str, Callable[[_mod_branch.Branch], Optional[str]]]()
440 branch_aliases.register('parent', lambda b: b.get_parent(),
441 help="The parent of this branch.")
442 branch_aliases.register('submit', lambda b: b.get_submit_branch(),
443
444=== modified file 'breezy/filters/__init__.py'
445--- breezy/filters/__init__.py 2022-10-30 14:30:21 +0000
446+++ breezy/filters/__init__.py 2022-11-15 00:30:45 +0000
447@@ -45,7 +45,7 @@
448 BytesIO,
449 )
450
451-from typing import List, Tuple, Dict
452+from typing import List, Tuple, Dict, Callable
453
454 from .. import (
455 errors,
456@@ -178,7 +178,7 @@
457
458
459 # The registry of filter stacks indexed by name.
460-filter_stacks_registry = registry.Registry()
461+filter_stacks_registry = registry.Registry[str, Callable[[str], List[ContentFilter]]]()
462
463
464 # Cache of preferences -> stack
465
466=== modified file 'breezy/forge.py'
467--- breezy/forge.py 2022-11-03 13:55:57 +0000
468+++ breezy/forge.py 2022-11-15 00:30:45 +0000
469@@ -530,4 +530,4 @@
470 raise UnsupportedForge(url)
471
472
473-forges = registry.Registry()
474+forges = registry.Registry[str, Type[Forge]]()
475
476=== modified file 'breezy/git/cache.py'
477--- breezy/git/cache.py 2022-10-08 17:46:49 +0000
478+++ breezy/git/cache.py 2022-11-15 00:30:45 +0000
479@@ -945,7 +945,7 @@
480 yield key[1]
481
482
483-formats = registry.Registry()
484+formats = registry.Registry[str, BzrGitCacheFormat]()
485 formats.register(TdbGitCacheFormat().get_format_string(),
486 TdbGitCacheFormat())
487 formats.register(SqliteGitCacheFormat().get_format_string(),
488
489=== modified file 'breezy/git/tests/test_remote.py'
490--- breezy/git/tests/test_remote.py 2022-09-23 04:11:55 +0000
491+++ breezy/git/tests/test_remote.py 2022-11-15 00:30:45 +0000
492@@ -53,6 +53,7 @@
493 RemoteGitBranchFormat,
494 _git_url_and_path_from_transport,
495 )
496+from ..tree import MissingNestedTree
497
498 from dulwich import porcelain
499 from dulwich.errors import HangupException
500@@ -354,7 +355,7 @@
501 self.remote_real.head()),
502 local.open_branch().last_revision())
503 self.assertRaises(
504- NotBranchError,
505+ MissingNestedTree,
506 local.open_workingtree().get_nested_tree, 'nested')
507
508 def test_sprout_submodule_relative(self):
509
510=== modified file 'breezy/git/tree.py'
511--- breezy/git/tree.py 2022-10-29 11:59:45 +0000
512+++ breezy/git/tree.py 2022-11-15 00:30:45 +0000
513@@ -389,8 +389,11 @@
514 if not nested_repo_transport.has('.'):
515 nested_repo_transport = self._repository.controldir.user_transport.clone(
516 posixpath.join(decode_git_path(section), '.git'))
517- nested_controldir = _mod_controldir.ControlDir.open_from_transport(
518- nested_repo_transport)
519+ try:
520+ nested_controldir = _mod_controldir.ControlDir.open_from_transport(
521+ nested_repo_transport)
522+ except errors.NotBranchError as e:
523+ raise MissingNestedTree(decode_git_path(relpath)) from e
524 return nested_controldir.find_repository()
525
526 def _get_submodule_store(self, relpath):
527@@ -614,9 +617,13 @@
528 child_path = posixpath.join(path, name)
529 child_path_decoded = decode_git_path(child_path)
530 if recurse_nested and S_ISGITLINK(mode):
531- mode = stat.S_IFDIR
532- substore = self._get_submodule_store(child_path)
533- hexsha = substore[hexsha].tree
534+ try:
535+ substore = self._get_submodule_store(child_path)
536+ except errors.NotBranchError:
537+ substore = store
538+ else:
539+ mode = stat.S_IFDIR
540+ hexsha = substore[hexsha].tree
541 else:
542 substore = store
543 if stat.S_ISDIR(mode):
544@@ -683,7 +690,7 @@
545 if S_ISGITLINK(mode):
546 try:
547 nested_repo = self._get_submodule_repository(encode_git_path(path))
548- except errors.NotBranchError:
549+ except MissingNestedTree:
550 return self.mapping.revision_id_foreign_to_bzr(hexsha)
551 else:
552 try:
553@@ -1429,7 +1436,8 @@
554 key = (posixpath.dirname(path), path)
555 if key not in ret and self.is_versioned(path):
556 ret[key] = self._get_dir_ie(path, self.path2id(key[0]))
557- return ((path, ie) for ((_, path), ie) in sorted(ret.items()))
558+ for ((_, path), ie) in sorted(ret.items()):
559+ yield path, ie
560
561 def iter_references(self):
562 if self.supports_tree_reference():
563
564=== modified file 'breezy/git/workingtree.py'
565--- breezy/git/workingtree.py 2022-09-23 03:17:56 +0000
566+++ breezy/git/workingtree.py 2022-11-15 00:30:45 +0000
567@@ -217,11 +217,17 @@
568 info = self._submodule_info()[relpath]
569 except KeyError:
570 submodule_transport = self.user_transport.clone(decode_git_path(relpath))
571- submodule_dir = self._format._matchingcontroldir.open(submodule_transport)
572+ try:
573+ submodule_dir = self._format._matchingcontroldir.open(submodule_transport)
574+ except errors.NotBranchError as e:
575+ raise tree.MissingNestedTree(relpath) from e
576 else:
577 submodule_transport = self.control_transport.clone(
578 posixpath.join('modules', decode_git_path(info[1])))
579- submodule_dir = BareLocalGitControlDirFormat().open(submodule_transport)
580+ try:
581+ submodule_dir = BareLocalGitControlDirFormat().open(submodule_transport)
582+ except errors.NotBranchError as e:
583+ raise tree.MissingNestedTree(relpath) from e
584 return Index(submodule_dir.control_transport.local_abspath('index'))
585
586 def lock_read(self):
587@@ -1314,7 +1320,10 @@
588 return self.branch.lookup_foreign_revision_id(hexsha)
589
590 def get_nested_tree(self, path):
591- return workingtree.WorkingTree.open(self.abspath(path))
592+ try:
593+ return workingtree.WorkingTree.open(self.abspath(path))
594+ except errors.NotBranchError as e:
595+ raise tree.MissingNestedTree(path) from e
596
597 def _directory_is_tree_reference(self, relpath):
598 # as a special case, if a directory contains control files then
599
600=== modified file 'breezy/inter.py'
601--- breezy/inter.py 2020-06-23 01:02:30 +0000
602+++ breezy/inter.py 2022-11-15 00:30:45 +0000
603@@ -16,6 +16,8 @@
604
605 """Inter-object utility class."""
606
607+from typing import Generic, TypeVar, List, Type
608+
609 from .errors import BzrError
610 from .lock import LogicalLockResult
611 from .pyutils import get_named_object
612@@ -31,7 +33,10 @@
613 self.target = target
614
615
616-class InterObject(object):
617+T = TypeVar('T')
618+
619+
620+class InterObject(Generic[T]):
621 """This class represents operations taking place between two objects.
622
623 Its instances have methods like join or copy_content or fetch, and contain
624@@ -52,10 +57,15 @@
625 registered first.
626 """
627
628+ source: T
629+ target: T
630+
631+ _optimisers: List[Type["InterObject[T]"]]
632+
633 # _optimisers = list()
634 # Each concrete InterObject type should have its own optimisers list.
635
636- def __init__(self, source, target):
637+ def __init__(self, source: T, target: T):
638 """Construct a default InterObject instance. Please use 'get'.
639
640 Only subclasses of InterObject should call
641@@ -80,7 +90,7 @@
642 raise
643
644 @classmethod
645- def get(klass, source, target):
646+ def get(klass, source: T, target: T):
647 """Retrieve a Inter worker object for these objects.
648
649 :param source: the object to be the 'source' member of
650@@ -100,6 +110,10 @@
651 raise NoCompatibleInter(source, target)
652
653 @classmethod
654+ def is_compatible(cls, source, target):
655+ raise NotImplementedError(cls.is_compatible)
656+
657+ @classmethod
658 def iter_optimisers(klass):
659 for provider in klass._optimisers:
660 if isinstance(provider, tuple):
661
662=== modified file 'breezy/log.py'
663--- breezy/log.py 2022-08-22 18:19:46 +0000
664+++ breezy/log.py 2022-11-15 00:30:45 +0000
665@@ -52,6 +52,7 @@
666 import itertools
667 import re
668 import sys
669+from typing import Callable, List, Dict
670 from warnings import (
671 warn,
672 )
673@@ -65,7 +66,6 @@
674 diff,
675 foreign,
676 lazy_regex,
677- revision as _mod_revision,
678 )
679 from breezy.i18n import gettext, ngettext
680 """)
681@@ -73,6 +73,7 @@
682 from . import (
683 errors,
684 registry,
685+ revision as _mod_revision,
686 revisionspec,
687 trace,
688 transport as _mod_transport,
689@@ -1934,7 +1935,7 @@
690 return [rev.committer]
691
692
693-author_list_registry = registry.Registry()
694+author_list_registry = registry.Registry[str, Callable[[_mod_revision.Revision], List[str]]]()
695
696 author_list_registry.register('all', author_list_all,
697 'All authors')
698@@ -2191,7 +2192,7 @@
699 return None
700
701
702-properties_handler_registry = registry.Registry()
703+properties_handler_registry = registry.Registry[str, Callable[[Dict[str, str]], Dict[str, str]]]()
704
705 # Use the properties handlers to print out bug information if available
706
707
708=== modified file 'breezy/mail_client.py'
709--- breezy/mail_client.py 2022-09-22 22:55:28 +0000
710+++ breezy/mail_client.py 2022-11-15 00:30:45 +0000
711@@ -19,6 +19,7 @@
712 import subprocess
713 import sys
714 import tempfile
715+from typing import Type
716
717 import breezy
718 from . import (
719@@ -31,9 +32,6 @@
720 registry,
721 )
722
723-mail_client_registry = registry.Registry()
724-
725-
726 class MailClientNotFound(errors.BzrError):
727
728 _fmt = "Unable to find mail client with the following names:"\
729@@ -110,6 +108,9 @@
730 return ''
731
732
733+mail_client_registry = registry.Registry[str, Type[MailClient]]()
734+
735+
736 class Editor(MailClient):
737 __doc__ = """DIY mail client that uses commit message editor"""
738
739
740=== modified file 'breezy/merge.py'
741--- breezy/merge.py 2022-10-06 05:49:43 +0000
742+++ breezy/merge.py 2022-11-15 00:30:45 +0000
743@@ -16,6 +16,7 @@
744
745 import contextlib
746 import tempfile
747+from typing import Type
748
749 from .lazy_import import lazy_import
750 lazy_import(globals(), """
751@@ -1867,7 +1868,7 @@
752 return merger.do_merge()
753
754
755-merge_type_registry = registry.Registry()
756+merge_type_registry = registry.Registry[str, Type[Merge3Merger]]()
757 merge_type_registry.register('diff3', Diff3Merger,
758 "Merge using external diff3.")
759 merge_type_registry.register('lca', LCAMerger,
760
761=== modified file 'breezy/option.py'
762--- breezy/option.py 2022-10-30 14:30:21 +0000
763+++ breezy/option.py 2022-11-15 00:30:45 +0000
764@@ -21,7 +21,7 @@
765
766 import optparse
767 import re
768-from typing import Dict
769+from typing import Dict, Callable
770
771 from . import (
772 errors,
773@@ -590,6 +590,6 @@
774 type=str,
775 help='Display timezone as local, original, or utc.')
776
777-diff_writer_registry = _mod_registry.Registry()
778+diff_writer_registry = _mod_registry.Registry[str, Callable]()
779 diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')
780 diff_writer_registry.default_key = 'plain'
781
782=== modified file 'breezy/registry.py'
783--- breezy/registry.py 2020-02-18 01:57:45 +0000
784+++ breezy/registry.py 2022-11-15 00:30:45 +0000
785@@ -16,6 +16,19 @@
786
787 """Classes to provide name-to-object registry-like support."""
788
789+from typing import (
790+ TypeVar,
791+ Generic,
792+ Optional,
793+ Any,
794+ cast,
795+ Union,
796+ Callable,
797+ Dict,
798+ Iterator,
799+ Tuple,
800+)
801+
802 from .pyutils import get_named_object
803
804
805@@ -79,7 +92,11 @@
806 self._module_name, self._member_name, self._imported)
807
808
809-class Registry(object):
810+K = TypeVar('K')
811+V = TypeVar('V')
812+
813+
814+class Registry(Generic[K, V]):
815 """A class that registers objects to a name.
816
817 There are many places that want to collect related objects and access them
818@@ -101,7 +118,7 @@
819 # Map from key => (is_lazy, info)
820 self._dict = {}
821 self._aliases = {}
822- self._help_dict = {}
823+ self._help_dict: Dict[str, Union[Callable[[Registry[K, V], Optional[K]], str], str]] = {}
824 self._info_dict = {}
825
826 def aliases(self):
827@@ -114,8 +131,9 @@
828 ret.setdefault(target, []).append(alias)
829 return ret
830
831- def register(self, key, obj, help=None, info=None,
832- override_existing=False):
833+ def register(self, key: K, obj: V, help: Optional[str] = None,
834+ info: Optional[Any] = None,
835+ override_existing: bool = False):
836 """Register a new object to a name.
837
838 :param key: This is the key to use to request the object later.
839@@ -137,9 +155,9 @@
840 self._dict[key] = _ObjectGetter(obj)
841 self._add_help_and_info(key, help=help, info=info)
842
843- def register_lazy(self, key, module_name, member_name,
844- help=None, info=None,
845- override_existing=False):
846+ def register_lazy(self, key: K, module_name: str, member_name: str,
847+ help: Optional[str] = None, info: Optional[Any] = None,
848+ override_existing: bool = False) -> None:
849 """Register a new object to be loaded on request.
850
851 :param key: This is the key to use to request the object later.
852@@ -161,7 +179,7 @@
853 self._dict[key] = _LazyObjectGetter(module_name, member_name)
854 self._add_help_and_info(key, help=help, info=info)
855
856- def register_alias(self, key, target, info=None):
857+ def register_alias(self, key: str, target: str, info: Optional[Any] = None):
858 """Register an alias.
859
860 :param key: Alias name
861@@ -180,7 +198,7 @@
862 self._help_dict[key] = help
863 self._info_dict[key] = info
864
865- def get(self, key=None):
866+ def get(self, key: Optional[K] = None) -> V:
867 """Return the object register()'ed to the given key.
868
869 May raise ImportError if the object was registered lazily and
870@@ -197,7 +215,7 @@
871 :raises AttributeError: If registered lazily, and the module does not
872 contain the registered member.
873 """
874- return self._dict[self._get_key_or_default(key)].get_obj()
875+ return cast(V, self._dict[self._get_key_or_default(key)].get_obj())
876
877 def _get_module(self, key):
878 """Return the module the object will be or was loaded from.
879@@ -227,7 +245,7 @@
880 else:
881 return self.default_key
882
883- def get_help(self, key=None):
884+ def get_help(self, key: Optional[K] = None) -> Optional[str]:
885 """Get the help text associated with the given key"""
886 the_help = self._help_dict[self._get_key_or_default(key)]
887 if callable(the_help):
888@@ -252,7 +270,7 @@
889 """Get a list of registered entries"""
890 return sorted(self._dict)
891
892- def iteritems(self):
893+ def iteritems(self) -> Iterator[Tuple[K, V]]:
894 for key in self._dict:
895 yield key, self._dict[key].get_obj()
896
897
898=== modified file 'breezy/repository.py'
899--- breezy/repository.py 2022-10-30 14:30:21 +0000
900+++ breezy/repository.py 2022-11-15 00:30:45 +0000
901@@ -1541,7 +1541,7 @@
902 )
903
904
905-class InterRepository(InterObject):
906+class InterRepository(InterObject[Repository]):
907 """This class represents operations taking place between two repositories.
908
909 Its instances have methods like copy_content and fetch, and contain
910@@ -1553,7 +1553,7 @@
911 InterRepository.get(other).method_name(parameters).
912 """
913
914- _optimisers: List[Type["InterRepository"]] = []
915+ _optimisers = []
916 """The available optimised InterRepository types."""
917
918 def copy_content(self, revision_id=None):
919
920=== modified file 'breezy/revisionspec.py'
921--- breezy/revisionspec.py 2022-09-24 17:01:11 +0000
922+++ breezy/revisionspec.py 2022-11-15 00:30:45 +0000
923@@ -974,7 +974,7 @@
924 RevisionSpec_dwim.append_possible_revspec(RevisionSpec_date)
925 RevisionSpec_dwim.append_possible_revspec(RevisionSpec_branch)
926
927-revspec_registry = registry.Registry()
928+revspec_registry = registry.Registry[str, RevisionSpec]()
929
930
931 def _register_revspec(revspec):
932
933=== modified file 'breezy/send.py'
934--- breezy/send.py 2022-01-09 13:12:27 +0000
935+++ breezy/send.py 2022-11-15 00:30:45 +0000
936@@ -16,6 +16,7 @@
937
938 import os
939 import time
940+from typing import Callable
941
942 from . import (
943 controldir,
944@@ -33,7 +34,7 @@
945 )
946
947
948-format_registry = registry.Registry()
949+format_registry = registry.Registry[str, Callable]()
950
951
952 def send(target_branch, revision, public_branch, remember,
953
954=== modified file 'breezy/tag.py'
955--- breezy/tag.py 2022-09-24 17:01:11 +0000
956+++ breezy/tag.py 2022-11-15 00:30:45 +0000
957@@ -27,7 +27,7 @@
958 import itertools
959 import re
960 import sys
961-from typing import List, Type
962+from typing import List, Type, Callable
963
964 # NOTE: I was going to call this tags.py, but vim seems to think all files
965 # called tags* are ctags files... mbp 20070220.
966@@ -36,6 +36,7 @@
967 from .registry import Registry
968
969 from . import (
970+ branch as _mod_branch,
971 errors,
972 )
973
974@@ -183,11 +184,11 @@
975 return {}
976
977
978-class InterTags(InterObject):
979+class InterTags(InterObject[Tags]):
980 """Operations between sets of tags.
981 """
982
983- _optimisers: List[Type["InterTags"]] = []
984+ _optimisers = []
985 """The available optimised InterTags types."""
986
987 @classmethod
988@@ -353,7 +354,7 @@
989 tags.sort(key=lambda x: timestamps[x[1]])
990
991
992-tag_sort_methods = Registry()
993+tag_sort_methods = Registry[str, Callable[[_mod_branch.Branch, List[str]], List[str]]]()
994 tag_sort_methods.register("natural", sort_natural,
995 'Sort numeric substrings as numbers. (default)')
996 tag_sort_methods.register("alpha", sort_alpha, 'Sort tags lexicographically.')
997
998=== modified file 'breezy/tests/__init__.py'
999--- breezy/tests/__init__.py 2022-10-27 11:57:11 +0000
1000+++ breezy/tests/__init__.py 2022-11-15 00:30:45 +0000
1001@@ -51,7 +51,7 @@
1002 import threading
1003 import time
1004 import traceback
1005-from typing import Set
1006+from typing import Set, Callable
1007 import unittest
1008 import warnings
1009
1010@@ -3372,7 +3372,7 @@
1011
1012
1013 # A registry where get() returns a suite decorator.
1014-parallel_registry = registry.Registry()
1015+parallel_registry = registry.Registry[str, Callable]()
1016
1017
1018 def fork_decorator(suite):
1019
1020=== modified file 'breezy/tests/per_tree/test_test_trees.py'
1021--- breezy/tests/per_tree/test_test_trees.py 2022-07-02 13:44:01 +0000
1022+++ breezy/tests/per_tree/test_test_trees.py 2022-11-15 00:30:45 +0000
1023@@ -16,7 +16,10 @@
1024
1025 """Tests for the test trees used by the per_tree tests."""
1026
1027+import shutil
1028+
1029 from breezy import errors
1030+from breezy.tree import MissingNestedTree
1031 from breezy.tests import per_tree
1032 from breezy.tests import (
1033 TestNotApplicable,
1034@@ -489,3 +492,13 @@
1035 actual = [(path, ie.kind)
1036 for path, ie in path_entries]
1037 self.assertEqual(expected, actual)
1038+
1039+ def test_iter_entries_with_missing_reference(self):
1040+ tree, subtree = self.create_nested()
1041+ shutil.rmtree('wt/subtree')
1042+ expected = [
1043+ ('', 'directory'),
1044+ ('subtree', 'tree-reference')]
1045+ with tree.lock_read():
1046+ self.assertRaises(
1047+ MissingNestedTree, list, tree.iter_entries_by_dir(recurse_nested=True))
1048
1049=== modified file 'breezy/transform.py'
1050--- breezy/transform.py 2022-08-22 18:19:46 +0000
1051+++ breezy/transform.py 2022-11-15 00:30:45 +0000
1052@@ -19,6 +19,7 @@
1053 import errno
1054 from stat import S_ISREG, S_IEXEC
1055 import time
1056+from typing import Callable
1057
1058 from . import (
1059 config as _mod_config,
1060@@ -583,7 +584,7 @@
1061 raise OrphaningForbidden('never')
1062
1063
1064-orphaning_registry = registry.Registry()
1065+orphaning_registry = registry.Registry[str, Callable[[TreeTransform, bytes, bytes], None]]()
1066 orphaning_registry.register(
1067 u'conflict', refuse_orphan,
1068 'Leave orphans in place and create a conflict on the directory.')
1069
1070=== modified file 'breezy/transport/__init__.py'
1071--- breezy/transport/__init__.py 2022-10-30 14:42:01 +0000
1072+++ breezy/transport/__init__.py 2022-11-15 00:30:45 +0000
1073@@ -29,7 +29,7 @@
1074 import errno
1075 from io import BytesIO
1076 import sys
1077-from typing import Dict, Any
1078+from typing import Dict, Any, Callable
1079
1080 from stat import S_ISDIR
1081
1082@@ -1777,7 +1777,7 @@
1083 'HintingSSHTransport')
1084
1085
1086-transport_server_registry = registry.Registry()
1087+transport_server_registry = registry.Registry[str, Callable]()
1088 transport_server_registry.register_lazy('bzr', 'breezy.bzr.smart.server',
1089 'serve_bzr', help="The Bazaar smart server protocol over TCP. (default port: 4155)")
1090 transport_server_registry.default_key = 'bzr'
1091
1092=== modified file 'breezy/tree.py'
1093--- breezy/tree.py 2022-10-30 14:42:01 +0000
1094+++ breezy/tree.py 2022-11-15 00:30:45 +0000
1095@@ -19,7 +19,7 @@
1096
1097 __docformat__ = "google"
1098
1099-from typing import List, Type, TYPE_CHECKING, Optional
1100+from typing import List, Type, TYPE_CHECKING, Optional, Iterator, Dict, Union, cast
1101
1102 from . import (
1103 errors,
1104@@ -302,11 +302,12 @@
1105 """
1106 return False
1107
1108- def all_versioned_paths(self):
1109+ def all_versioned_paths(self) -> Iterator[str]:
1110 """Iterate through all paths, including paths for missing files."""
1111 raise NotImplementedError(self.all_versioned_paths)
1112
1113- def iter_entries_by_dir(self, specific_files=None, recurse_nested=False):
1114+ def iter_entries_by_dir(self, specific_files: Optional[List[str]] = None,
1115+ recurse_nested: bool = False):
1116 """Walk the tree in 'by_dir' order.
1117
1118 This will yield each entry in the tree as a (path, entry) tuple.
1119@@ -634,7 +635,7 @@
1120 """
1121 raise errors.NoSuchRevisionInTree(self, revision_id)
1122
1123- def unknowns(self):
1124+ def unknowns(self) -> Iterator[str]:
1125 """What files are present in this tree and unknown.
1126
1127 Returns: an iterator over the unknown files.
1128@@ -752,8 +753,10 @@
1129 searcher = default_searcher
1130 return searcher
1131
1132- def archive(self, format, name, root='', subdir=None,
1133- force_mtime=None, recurse_nested=False):
1134+ def archive(self, format: str, name: str, root: str = '',
1135+ subdir: Optional[str] = None,
1136+ force_mtime: Optional[Union[int, float]] = None,
1137+ recurse_nested: bool = False) -> Iterator[bytes]:
1138 """Create an archive of this tree.
1139
1140 Args:
1141@@ -779,7 +782,7 @@
1142 raise NotImplementedError(self.preview_transform)
1143
1144
1145-class InterTree(InterObject):
1146+class InterTree(InterObject[Tree]):
1147 """This class represents operations taking place between two Trees.
1148
1149 Its instances have methods like 'compare' and contain references to the
1150@@ -798,7 +801,7 @@
1151 _matching_from_tree_format: Optional["WorkingTreeFormat"] = None
1152 _matching_to_tree_format: Optional["WorkingTreeFormat"] = None
1153
1154- _optimisers: List[Type["InterTree"]] = []
1155+ _optimisers = []
1156
1157 @classmethod
1158 def is_compatible(kls, source, target):
1159@@ -806,9 +809,16 @@
1160 # it works for all trees.
1161 return True
1162
1163- def compare(self, want_unchanged=False, specific_files=None,
1164- extra_trees=None, require_versioned=False, include_root=False,
1165- want_unversioned=False):
1166+ @classmethod
1167+ def get(cls, source: Tree, target: Tree) -> "InterTree":
1168+ return cast(InterTree, super(InterTree, cls).get(source, target))
1169+
1170+ def compare(self, want_unchanged: bool = False,
1171+ specific_files: Optional[List[str]] = None,
1172+ extra_trees: Optional[List[Tree]] = None,
1173+ require_versioned: bool = False,
1174+ include_root: bool = False,
1175+ want_unversioned: bool = False):
1176 """Return the changes from source to target.
1177
1178 Returns: A TreeDelta.
1179@@ -827,18 +837,20 @@
1180 want_unversioned: Scan for unversioned paths.
1181 """
1182 from . import delta
1183- trees = (self.source,)
1184+ trees = [self.source]
1185 if extra_trees is not None:
1186- trees = trees + tuple(extra_trees)
1187+ trees = trees + extra_trees
1188 with self.lock_read():
1189 return delta._compare_trees(self.source, self.target, want_unchanged,
1190 specific_files, include_root, extra_trees=extra_trees,
1191 require_versioned=require_versioned,
1192 want_unversioned=want_unversioned)
1193
1194- def iter_changes(self, include_unchanged=False,
1195- specific_files=None, pb=None, extra_trees=[],
1196- require_versioned=True, want_unversioned=False):
1197+ def iter_changes(self, include_unchanged: bool = False,
1198+ specific_files: Optional[List[str]] = None,
1199+ pb=None, extra_trees: List[Tree] = [],
1200+ require_versioned: bool = True,
1201+ want_unversioned: bool = False):
1202 """Generate an iterator of changes between trees.
1203
1204 A TreeChange object is returned.
1205@@ -874,7 +886,7 @@
1206 raise NotImplementedError(self.iter_changes)
1207
1208 def file_content_matches(
1209- self, source_path, target_path,
1210+ self, source_path: str, target_path: str,
1211 source_stat=None, target_stat=None):
1212 """Check if two files are the same in the source and target trees.
1213
1214@@ -909,7 +921,8 @@
1215 target_sha1 = target_verifier_data
1216 return (source_sha1 == target_sha1)
1217
1218- def find_target_path(self, path, recurse='none'):
1219+ def find_target_path(self, path: str,
1220+ recurse: str = 'none') -> Optional[str]:
1221 """Find target tree path.
1222
1223 Args:
1224@@ -920,7 +933,8 @@
1225 """
1226 raise NotImplementedError(self.find_target_path)
1227
1228- def find_source_path(self, path, recurse='none'):
1229+ def find_source_path(self, path: str,
1230+ recurse: str = 'none') -> Optional[str]:
1231 """Find the source tree path.
1232
1233 Args:
1234@@ -931,7 +945,8 @@
1235 """
1236 raise NotImplementedError(self.find_source_path)
1237
1238- def find_target_paths(self, paths, recurse='none'):
1239+ def find_target_paths(self, paths: List[str],
1240+ recurse='none') -> Dict[str, Optional[str]]:
1241 """Find target tree paths.
1242
1243 Args:
1244@@ -944,7 +959,8 @@
1245 ret[path] = self.find_target_path(path, recurse=recurse)
1246 return ret
1247
1248- def find_source_paths(self, paths, recurse='none'):
1249+ def find_source_paths(self, paths: List[str],
1250+ recurse: str = 'none') -> Dict[str, Optional[str]]:
1251 """Find source tree paths.
1252
1253 Args:
1254@@ -958,7 +974,9 @@
1255 return ret
1256
1257
1258-def find_previous_paths(from_tree, to_tree, paths, recurse='none'):
1259+def find_previous_paths(from_tree: Tree, to_tree: Tree,
1260+ paths: List[str],
1261+ recurse: str = 'none') -> Dict[str, Optional[str]]:
1262 """Find previous tree paths.
1263
1264 Args:
1265
1266=== modified file 'breezy/urlutils.py'
1267--- breezy/urlutils.py 2022-10-30 14:42:01 +0000
1268+++ breezy/urlutils.py 2022-11-15 00:30:45 +0000
1269@@ -142,7 +142,7 @@
1270 return _url_scheme_re.match(url) is not None
1271
1272
1273-def join(base, *args):
1274+def join(base: str, *args) -> str:
1275 """Create a URL by joining sections.
1276
1277 This will normalize '..', assuming that paths are absolute
1278
1279=== modified file 'breezy/version_info_formats/__init__.py'
1280--- breezy/version_info_formats/__init__.py 2022-07-07 15:36:19 +0000
1281+++ breezy/version_info_formats/__init__.py 2022-11-15 00:30:45 +0000
1282@@ -17,6 +17,7 @@
1283 """Routines for extracting all version information from a bzr branch."""
1284
1285 import time
1286+from typing import Type
1287
1288 from breezy.osutils import local_time_offset, format_date
1289 from breezy import (
1290@@ -186,7 +187,7 @@
1291 raise NotImplementedError(VersionInfoBuilder.generate)
1292
1293
1294-format_registry = registry.Registry()
1295+format_registry = registry.Registry[str, Type[VersionInfoBuilder]]()
1296
1297
1298 format_registry.register_lazy(

Subscribers

People subscribed via source and target branches