Bug#851635: possible addition, script to find the common ancestor version of two changelogs.

peter green plugwash at p10link.net
Tue Jan 17 04:34:38 UTC 2017


Package: devscripts
Severity: wishlist

I needed to find the common ancestor version from two changelogs.

I asked about it on irc and after not getting a quick response decided to implement it myself. The implementation I came up with was a small python3 script using python3-debian

The script takes two changelogs c1 and c2 and finds the first version in c2 that is also in c1.

pabs suggested it might be useful to put it in devscripts and that I should file a bugreport.


-------------- next part --------------
#!/usr/bin/python3
#(C) 2015 Peter Michael Green <plugwash at debian.org>
#This software is provided 'as-is', without any express or implied warranty. In
#no event will the authors be held liable for any damages arising from the use
#of this software.
#
#Permission is granted to anyone to use this software for any purpose, including
#commercial applications, and to alter it and redistribute it freely, subject to
#the following restrictions:
#
#1. The origin of this software must not be misrepresented; you must not claim.
#that you wrote the original software. If you use this software in a product,
#an acknowledgment in the product documentation would be appreciated but is.
#not required.
#
#2. Altered source versions must be plainly marked as such, and must not be
#misrepresented as being the original software.
#
#3. This notice may not be removed or altered from any source distribution.

from debian import changelog
import sys
changelog1 = sys.argv[1]
changelog2 = sys.argv[2]

f1 = open(changelog1,'rb')
f2 = open(changelog2,'rb')

c1 = changelog.Changelog(f1)
c2 = changelog.Changelog(f2)

s = set()

for entry in c1:
	s.add(entry.version)
	#print(repr(entry.version))

for entry in c2:
	if entry.version in s:
		commonparent = entry.version
		break

print(commonparent)

#for entry in c2:



sys.exit(0)

f=open(filetofix,'wb')

f.write((package+' ('+newversion+') '+distribution+'; urgency=medium\n').encode('utf-8'))
f.write(('\n').encode('utf-8'))
for entry in reversed(entries):
	lines = entry.changes()[:] #copy this so we don't modify the libraries
	                           #version of it.
	while (lines[0] == ''):
		 del lines[0]
	if ((lines[0].strip().upper())[0:8] != '[CHANGES'):
		f.write(('  [changes brought forward from '+str(entry.version)+' by '+entry.author+' at '+entry.date+']\n').encode('utf-8'))
	for line in lines:
		f.write((line+'\n').encode('utf-8'))

f.write((' -- Raspbian forward porter <root at raspbian.org>  '+date+'\n').encode('utf-8'))
f.write(('\n').encode('utf-8'))

for line in upstreamchangelog:
	f.write(line)

f.close()


More information about the devscripts-devel mailing list