Create new changelog block from existing changelog

Jelmer Vernooij jelmer at jelmer.uk
Mon Nov 2 22:27:35 GMT 2020


Hi Brian,

On Mon, Nov 02, 2020 at 07:48:41PM +0000, Murrell, Brian wrote:
> Since this looks like a mailing-list, please CC me directly on any
> replies as I am not a list member.  I hope I don't have to subscribe
> first as I just followed a mailto: link in the documentation to start
> this e-mail.
> 
> Anyway, looking at
> 
> https://salsa.debian.org/python-debian-team/python-debian/-/blob/master/lib/debian/changelog.py#L20-26
> 
> it looks like I have to supply an amount of information (package,
> version, etc.) that debian.changelog could conceivably already know
> about by having opened the existing changelog with:
> 
> debian.changelog.Changelog(open("debian/changelog"))
> 
> I wonder why, if one does something like:
> 
> ch = debian.changelog.Changelog(open("debian/changelog"))
> ch.new_block(version="1.2.3)
> 
> one gets an exception:
> 
> debian.changelog.ChangelogCreateError: Package not specified
> 
> Surely, the package name is known already in the Changelog object and
> new_block() can just use that, yes?
> 
> Basically just an implied:
> 
> ch = debian.changelog.Changelog(open("debian/changelog"))
> ch.new_block(package=ch.get_package(),
>              version=1.2.3",
>              distributions=ch.distributions,
>              author="%s <%s>" % debian.changelog.get_maintainer(),
>              date=email.utils.formatdate(None, True))
> 
> Given the above, the only field that seems like it really needs to be
> mandatory and not have a reasonable default is the version field.

I agree it would make sense to have *a* way of creating a new changelog
entry as if the current user was running "dch". In that case,
distributions would be set to UNRELEASED per convention rather than to
the previous distributions.

Whether that should be the default Changelog.new_block() command is a
different question - Changelog is a fairly low-level interface. If it
defaulted to calling .get_maintainer() but then in some situations it
raised an exception because get_maintainer() didn't see the right
environment variables, I think that would be worse and more surprising
than the current situation where you need to be explicit but
have consistent behaviour regardless of the environment.

Perhaps we could add a DWIM-style function for adding changelog
entries?

Cheers,

Jelmer

-- 
Jelmer Vernooij <jelmer at jelmer.uk>
PGP Key: https://www.jelmer.uk/D729A457.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-python-debian-maint/attachments/20201102/2969e3d4/attachment.sig>


More information about the pkg-python-debian-maint mailing list