Merge lp:~jelmer/brz/auto-upgrade-reference into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/auto-upgrade-reference
Merge into: lp:brz
Diff against target: 82 lines (+24/-17)
2 files modified
breezy/bzr/branch.py (+21/-17)
doc/en/release-notes/brz-3.1.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/auto-upgrade-reference
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+355883@code.launchpad.net

Commit message

Automatically upgrade to branch format 8 when setting branch references.

Description of the change

Automatically upgrade to branch format 8 when setting branch references.

I think this makes more sense than bothering users about an upgrade that involves creating a new file.

BzrBranchFormat8 has been included since bzr 1.15.

Note that just supporting tree references in branches doesn't mean support for nested trees is now available by default; for that you also need to have a repository that supports them, which is only available as part of development-subtree.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

We've discussed this in the past, and I think it's fair enough.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/branch.py'
2--- breezy/bzr/branch.py 2019-02-15 18:57:38 +0000
3+++ breezy/bzr/branch.py 2019-06-14 23:40:10 +0000
4@@ -540,14 +540,17 @@
5 with self.lock_read():
6 if self._reference_info is not None:
7 return self._reference_info
8- with self._transport.get('references') as rio_file:
9- stanzas = rio.read_stanzas(rio_file)
10- info_dict = {
11- s['tree_path']: (
12- s['branch_location'],
13- s['file_id'].encode('ascii')
14- if 'file_id' in s else None)
15- for s in stanzas}
16+ try:
17+ with self._transport.get('references') as rio_file:
18+ stanzas = rio.read_stanzas(rio_file)
19+ info_dict = {
20+ s['tree_path']: (
21+ s['branch_location'],
22+ s['file_id'].encode('ascii')
23+ if 'file_id' in s else None)
24+ for s in stanzas}
25+ except errors.NoSuchFile:
26+ info_dict = {}
27 self._reference_info = info_dict
28 return info_dict
29
30@@ -687,14 +690,11 @@
31 """A branch with support for a fallback repository."""
32
33 def set_reference_info(self, tree_path, branch_location, file_id=None):
34- Branch.set_reference_info(self, file_id, tree_path, branch_location)
35-
36- def get_reference_info(self, path):
37- Branch.get_reference_info(self, path)
38-
39- def reference_parent(self, path, file_id=None, possible_transports=None):
40- return Branch.reference_parent(
41- self, path, file_id, possible_transports)
42+ super(BzrBranch7, self).set_reference_info(
43+ tree_path, branch_location, file_id=file_id)
44+ format_string = BzrBranchFormat8.get_format_string()
45+ mutter('Upgrading branch to format %r', format_string)
46+ self._transport.put_bytes('format', format_string)
47
48
49 class BzrBranch6(BzrBranch7):
50@@ -862,6 +862,8 @@
51 def supports_set_append_revisions_only(self):
52 return True
53
54+ supports_reference_locations = True
55+
56
57 class BzrBranchFormat8(BranchFormatMetadir):
58 """Metadir format supporting storing locations of subtree branches."""
59@@ -945,7 +947,9 @@
60 """See breezy.branch.BranchFormat.make_tags()."""
61 return _mod_tag.BasicTags(branch)
62
63- supports_reference_locations = False
64+ # This is a white lie; as soon as you set a reference location, we upgrade
65+ # you to BzrBranchFormat8.
66+ supports_reference_locations = True
67
68
69 class BranchReferenceFormat(BranchFormatMetadir):
70
71=== modified file 'doc/en/release-notes/brz-3.1.txt'
72--- doc/en/release-notes/brz-3.1.txt 2019-06-03 23:26:04 +0000
73+++ doc/en/release-notes/brz-3.1.txt 2019-06-14 23:40:10 +0000
74@@ -37,6 +37,9 @@
75 ``brz propose``, for hosting sites that support it.
76 (Jelmer Vernooij)
77
78+* Automatically upgrade to branch format 8 when setting branch references.
79+ (Jelmer Vernooij)
80+
81 Bug Fixes
82 *********
83

Subscribers

People subscribed via source and target branches