Merge lp:~jelmer/bzr-builddeb/auto-tag into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jelmer/bzr-builddeb/auto-tag
Merge into: lp:bzr-builddeb
Diff against target: 49 lines (+32/-0)
1 file modified
__init__.py (+32/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/auto-tag
Reviewer Review Type Date Requested Status
Bzr-builddeb-hackers Pending
Review via email: mp+21854@code.launchpad.net

Description of the change

Implement a 'automatic_tag_name' hook that provides tag names based on the debian version.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

On Mon, 22 Mar 2010 14:03:21 -0000, Jelmer Vernooij <email address hidden> wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/bzr-builddeb/auto-tag into lp:bzr-builddeb.
>
> Requested reviews:
> Bzr-builddeb-hackers (bzr-builddeb-hackers)
>
>
> Implement a 'automatic_tag_name' hook that provides tag names based on the debian version.

Great.

Can we have the existing cmd_mark_uploaded command use this same code?

Thanks,

James

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I looked at that, but it seems like we'd end up with a more complex common function. The mark-uploaded code handles --force itself, allows more parameters and does the tag setting itself.

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 2010-02-12 19:45:37 +0000
3+++ __init__.py 2010-03-22 14:03:20 +0000
4@@ -27,6 +27,8 @@
5
6 import bzrlib
7 from bzrlib import (
8+ branch as _mod_branch,
9+ errors,
10 merge,
11 msgeditor,
12 )
13@@ -129,6 +131,36 @@
14 "the commit message")
15
16
17+def debian_tag_name(branch, revid):
18+ from bzrlib.plugins.builddeb.errors import MissingChangelogError
19+ from bzrlib.plugins.builddeb.import_dsc import (DistributionBranch,
20+ DistributionBranchSet)
21+ from bzrlib.plugins.builddeb.util import (debuild_config, find_changelog)
22+ t = branch.repository.revision_tree(revid)
23+ config = debuild_config(t, False, False)
24+ try:
25+ (changelog, larstiq) = find_changelog(t, config.merge)
26+ except MissingChangelogError:
27+ # Not a debian package
28+ return None
29+ if changelog.distributions == 'UNRELEASED':
30+ # The changelog still targets 'UNRELEASED', so apparently hasn't been
31+ # uploaded. XXX: Give a warning of some sort here?
32+ return None
33+ db = DistributionBranch(branch, None)
34+ dbs = DistributionBranchSet()
35+ dbs.add_branch(db)
36+ return db.tag_name(changelog.version)
37+
38+
39+try:
40+ _mod_branch.Branch.hooks.install_named_hook("automatic_tag_name",
41+ debian_tag_name,
42+ "Automatically determine tag names from Debian version")
43+except errors.UnknownHook:
44+ pass # bzr < 2.2 doesn't have this hook.
45+
46+
47 try:
48 from bzrlib.revisionspec import revspec_registry
49 revspec_registry.register_lazy("package:",

Subscribers

People subscribed via source and target branches