Merge lp:~jelmer/bzr-builddeb/gather-orig-files-non-utf8 into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Superseded
Proposed branch: lp:~jelmer/bzr-builddeb/gather-orig-files-non-utf8
Merge into: lp:bzr-builddeb
Diff against target: 98 lines (+47/-3)
4 files modified
__init__.py (+18/-1)
debian/changelog (+3/-1)
tests/test_upstream.py (+18/-0)
upstream/__init__.py (+8/-1)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/gather-orig-files-non-utf8
Reviewer Review Type Date Requested Status
Bzr-builddeb-hackers Pending
Review via email: mp+83964@code.launchpad.net

This proposal has been superseded by a proposal from 2011-11-30.

Description of the change

In gather_orig_files() we scan a directory for relevant orig tarballs. Cope with filenames that are not valid in the current file system locale - we are only interested in files with a particular prefix anyway.

The test isn't protected by a Feature. I'm not aware of a relevant feature, and bzr-builddeb is only used on POSIX-based systems anyway, which allow arbitrary byte filenames.

To post a comment you must log in.
652. By Jelmer Vernooij

Encode package/version as ascii rather than utf8.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2011-11-22 14:05:25 +0000
3+++ __init__.py 2011-11-30 15:41:24 +0000
4@@ -27,7 +27,10 @@
5
6 import bzrlib
7 from bzrlib.commands import plugin_cmds
8-from bzrlib.directory_service import directories
9+from bzrlib.directory_service import (
10+ AliasDirectory,
11+ directories,
12+ )
13
14 from info import (
15 bzr_plugin_version as version_info,
16@@ -69,6 +72,20 @@
17 'VcsDirectory',
18 "Directory that uses Debian Vcs-* control fields to look up branches")
19
20+branch_aliases = getattr(AliasDirectory, "branch_aliases", None)
21+if branch_aliases is not None:
22+ def upstream_branch_alias(b):
23+ from bzrlib.plugins.builddeb.util import debuild_config
24+ b.lock_read()
25+ try:
26+ tree = b.basis_tree()
27+ config = debuild_config(tree, False)
28+ return directories.dereference(config.upstream_branch)
29+ finally:
30+ b.unlock()
31+ branch_aliases.register("upstream", upstream_branch_alias,
32+ help="upstream branch (for packaging branches)")
33+
34
35 def debian_changelog_commit_message(commit, start_message):
36 if start_message is not None:
37
38=== modified file 'debian/changelog'
39--- debian/changelog 2011-11-29 14:39:05 +0000
40+++ debian/changelog 2011-11-30 15:41:24 +0000
41@@ -25,8 +25,10 @@
42 unless 'commit-message-from-changelog' is explicitly set to True. LP: #812749
43 * Support running dep3-patch against remote repositories, and with
44 open-ended revision ranges. LP: #893608
45+ * Fix finding orig tarballs in directories also containing filenames
46+ with non-utf8 characters. LP: #865753
47
48- -- Jelmer Vernooij <jelmer@debian.org> Sat, 26 Nov 2011 16:01:16 +0100
49+ -- Jelmer Vernooij <jelmer@debian.org> Wed, 30 Nov 2011 16:32:05 +0100
50
51 bzr-builddeb (2.7.9) unstable; urgency=low
52
53
54=== modified file 'tests/test_upstream.py'
55--- tests/test_upstream.py 2011-11-08 10:10:05 +0000
56+++ tests/test_upstream.py 2011-11-30 15:41:24 +0000
57@@ -1010,3 +1010,21 @@
58 self.assertEquals(
59 [os.path.join(self.test_dir, "mypkg_1.0.orig.tar.gz")],
60 gather_orig_files("mypkg", "1.0", "."))
61+
62+ def test_multiple(self):
63+ self.build_tree(["mypkg_1.0.orig.tar.gz", "mypkg_1.0.orig-foo.tar.gz"])
64+ self.assertEquals(
65+ set([os.path.join(self.test_dir, "mypkg_1.0.orig.tar.gz"),
66+ os.path.join(self.test_dir, "mypkg_1.0.orig-foo.tar.gz")]),
67+ set(gather_orig_files("mypkg", "1.0", ".")))
68+
69+ def test_utf8_invalid_file(self):
70+ f = open("\xf6o.tar.gz", "w")
71+ try:
72+ f.write("foo")
73+ finally:
74+ f.close()
75+ self.build_tree(["mypkg_1.0.orig.tar.gz"])
76+ self.assertEquals(
77+ [os.path.join(self.test_dir, "mypkg_1.0.orig.tar.gz")],
78+ gather_orig_files(u"mypkg", "1.0", "."))
79
80=== modified file 'upstream/__init__.py'
81--- upstream/__init__.py 2011-11-08 10:10:05 +0000
82+++ upstream/__init__.py 2011-11-30 15:41:24 +0000
83@@ -372,7 +372,14 @@
84
85
86 def gather_orig_files(package, version, path):
87- prefix = "%s_%s.orig" % (package, version)
88+ """Grab the orig files for a particular package.
89+
90+ :param package: package name
91+ :param version: package upstream version string
92+ :return: List of orig tarfile paths, or None if none were found
93+ """
94+ prefix = "%s_%s.orig" % (osutils.safe_utf8(package),
95+ osutils.safe_utf8(version))
96 ret = []
97 path = os.path.abspath(path)
98 if not os.path.isdir(path):

Subscribers

People subscribed via source and target branches