Merge lp:~jelmer/brz-debian/read-metadata into lp:brz-debian

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 804
Proposed branch: lp:~jelmer/brz-debian/read-metadata
Merge into: lp:brz-debian
Diff against target: 140 lines (+53/-2)
5 files modified
cmds.py (+1/-0)
config.py (+31/-0)
debian/changelog (+1/-0)
debian/control (+2/-2)
tests/test_config.py (+18/-0)
To merge this branch: bzr merge lp:~jelmer/brz-debian/read-metadata
Reviewer Review Type Date Requested Status
Breezy developers Pending
Review via email: mp+354529@code.launchpad.net

Description of the change

Read debian/upstream/metadata for upstream branch.

To post a comment you must log in.
lp:~jelmer/brz-debian/read-metadata updated
803. By Jelmer Vernooij

Add test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmds.py'
2--- cmds.py 2018-06-14 19:55:05 +0000
3+++ cmds.py 2018-09-08 23:10:53 +0000
4@@ -739,6 +739,7 @@
5 except NotBranchError:
6 upstream_branch = None
7 elif upstream_branch is None and config.upstream_branch is not None:
8+ note(gettext("Using upstream branch %s (from configuration)") % config.upstream_branch)
9 upstream_branch = Branch.open(config.upstream_branch)
10 else:
11 upstream_branch = None
12
13=== modified file 'config.py'
14--- config.py 2018-06-14 19:55:05 +0000
15+++ config.py 2018-09-08 23:10:53 +0000
16@@ -20,11 +20,14 @@
17
18 from __future__ import absolute_import
19
20+import yaml
21+
22 from ...config import (
23 configobj,
24 ConfigObj,
25 TreeConfig,
26 )
27+from ...errors import NoSuchFile
28 from ...trace import mutter, warning
29
30
31@@ -55,6 +58,28 @@
32 return None
33
34
35+class UpstreamMetadataConfig(object):
36+ """Config object that represents debian/upstream/metadata.
37+ """
38+
39+ filename = 'debian/upstream/metadata'
40+
41+ def __init__(self, text):
42+ self.metadata = yaml.safe_load(text)
43+
44+ def get_value(self, section, option):
45+ if section == "BUILDDEB":
46+ if option == "upstream-branch":
47+ return self.metadata.get('Repository')
48+ raise KeyError
49+
50+ def get_bool(self, section, option):
51+ raise KeyError
52+
53+ def as_bool(self, option):
54+ raise KeyError
55+
56+
57 class DebBuildConfig(object):
58 """Holds the configuration settings for builddeb. These are taken from
59 a hierarchy of config files. .bzr-builddeb/local.conf then
60@@ -129,6 +154,12 @@
61 pass # Not a svn tree
62 except ImportError:
63 pass # No svn, apparently
64+ try:
65+ upstream_metadata_text = tree.get_file_text(UpstreamMetadataConfig.filename)
66+ except NoSuchFile:
67+ pass
68+ else:
69+ self._config_files.append((UpstreamMetadataConfig(upstream_metadata_text), False))
70 self.user_config = None
71
72 def set_user_config(self, user_conf):
73
74=== modified file 'debian/changelog'
75--- debian/changelog 2018-05-19 14:32:42 +0000
76+++ debian/changelog 2018-09-08 23:10:53 +0000
77@@ -2,6 +2,7 @@
78
79 * Update Vcs-Bzr to reflect code hosting is now on code.breezy-
80 vcs.org.
81+ * Read upstream branch from debian/upstream/metadata. LP: #1791456
82
83 -- Jelmer Vernooij <jelmer@debian.org> Sat, 19 May 2018 15:32:40 +0100
84
85
86=== modified file 'debian/control'
87--- debian/control 2018-05-19 14:32:42 +0000
88+++ debian/control 2018-09-08 23:10:53 +0000
89@@ -4,7 +4,7 @@
90 Maintainer: Debian Bazaar Maintainers <pkg-bazaar-maint@lists.alioth.debian.org>
91 Uploaders: Jelmer Vernooij <jelmer@debian.org>
92 Build-Depends: debhelper (>= 9), python-all (>= 2.6.6-3), xz-utils
93-Build-Depends-Indep: brz, python-docutils, python-debian (>= 0.1.11), python-apt, patchutils, python-testtools (>= 0.9.2), pristine-tar, devscripts (>= 2.10.59), python-subunit, python-breezy.tests (>= 3.0.0~bzr6876), python-lzma, libalgorithm-merge-perl, python-distro-info, quilt, python-dulwich (>= 0.19)
94+Build-Depends-Indep: brz, python-docutils, python-debian (>= 0.1.11), python-apt, patchutils, python-testtools (>= 0.9.2), pristine-tar, devscripts (>= 2.10.59), python-subunit, python-breezy.tests (>= 3.0.0~bzr6876), python-lzma, libalgorithm-merge-perl, python-distro-info, quilt, python-dulwich (>= 0.19), python-yaml
95 Vcs-Bzr: https://code.breezy-vcs.org/breezy-debian/unstable
96 Vcs-Browser: https://code.breezy-vcs.org/breezy-debian/unstable
97 X-Python-Version: >= 2.4
98@@ -13,7 +13,7 @@
99
100 Package: brz-debian
101 Architecture: all
102-Depends: brz (>= 3.0.0~bzr6876), python-breezy (>= 3.0.0~bzr6876), python-debian (>= 0.1.11), python-apt, ${python:Depends}, dpkg-dev, fakeroot, devscripts (>= 2.10.59), patchutils, pristine-tar, quilt, ${misc:Depends}
103+Depends: brz (>= 3.0.0~bzr6876), python-breezy (>= 3.0.0~bzr6876), python-debian (>= 0.1.11), python-apt, ${python:Depends}, dpkg-dev, fakeroot, devscripts (>= 2.10.59), patchutils, pristine-tar, quilt, ${misc:Depends}, python-yaml
104 Recommends: python-launchpadlib, libalgorithm-merge-perl, python-distro-info
105 Suggests: python-lzma
106 Provides: brz-buildpackage
107
108=== modified file 'tests/test_config.py'
109--- tests/test_config.py 2017-06-17 12:44:22 +0000
110+++ tests/test_config.py 2018-09-08 23:10:53 +0000
111@@ -91,6 +91,23 @@
112 f.close()
113 DebBuildConfig([('invalid.conf', True, 'invalid.conf')])
114
115+ def test_upstream_metadata(self):
116+ cfg = DebBuildConfig([], tree=self.branch.basis_tree())
117+ self.assertIs(None, cfg.upstream_branch)
118+
119+ self.build_tree_contents([
120+ ('debian/',),
121+ ('debian/upstream/',),
122+ ('debian/upstream/metadata',
123+ b'Name: example\n'
124+ b'Repository: http://example.com/foo\n'
125+ )])
126+ self.tree.add(['debian', 'debian/upstream', 'debian/upstream/metadata'])
127+
128+ cfg = DebBuildConfig([], tree=self.tree)
129+ self.assertEquals("http://example.com/foo", cfg.upstream_branch)
130+
131+
132 try:
133 from ...svn.config import SubversionBuildPackageConfig
134 except ImportError:
135@@ -137,4 +154,5 @@
136 cfg = DebBuildConfig([], tree=branch.basis_tree())
137 self.assertEquals("someorigdir", cfg.orig_dir)
138
139+
140 # vim: ts=2 sts=2 sw=2

Subscribers

People subscribed via source and target branches

to all changes: