Re: merging debian changelog

2008-01-11 Thread martin f krafft
also sprach Pierre Habouzit <[EMAIL PROTECTED]> [2008.01.11.1535 +0100]:
> To madduck: it's not mailman's fault, rather pipermail, that is
> a real PoS. Us mhonarch if you want a better archive, or anything
> else but pipermail. It's usually really easy to plug in mailman,
> either as a fake subscriber, or using the builtin hooks in
> mailman.

I can't afford the time to research this. If someone shoves a howto
in my face, I'll do it though. mhonarc or lurker.

-- 
 .''`.   martin f. krafft <[EMAIL PROTECTED]>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
 
"in the figure of the president, george w. bush, the incompetence,
 stupidity, and sheer inhumanity that characterize so much of
 america's money-mad corporate elite find their quintessentially
 repulsive expression."
 -- journalist, aftermath of katrina


digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg

Re: merging debian changelog

2008-01-11 Thread Pierre Habouzit
On Fri, Jan 11, 2008 at 01:18:15PM +, Junichi Uekawa wrote:
> Hi,
> 
> >   Here is a better version, that I believe can be used as a git merge
> > driver using this configuration snipplet:
> > 
> > [merge "merge-debchangelog"]
> > name = Debian Changelog merge driver
> > driver = /path/to/merge-debchangelog.py %O %A %B %A
> > 
> > and then, if I'm correct, you can in the .gitattribute of your debian/
> > directory set:
> > 
> > 8<
> > /changelog merge=merge-debchangelog
> > >8
> > 
> 
> I'm excited about your code. This is great.

  Well actually it has many pitfalls, like the fact that it reorders
every single changelog entry, which isn't very nice, I should rather try
to keep the ordering, and detect reordering and mark them as conflicts
(which they are actually). Well, some more love is needed, but I settle
some grounds for it, and we'll see where it goes :)

> While I wanted to point this to others, apparently, the list archive
> doesn't like PGP signed mail, so I can't just point people the URL.
> 
> http://lists.madduck.net/pipermail/vcs-pkg/2008-January/000102.html

To madduck: it's not mailman's fault, rather pipermail, that is a real
PoS. Us mhonarch if you want a better archive, or anything else but
pipermail. It's usually really easy to plug in mailman, either as a fake
subscriber, or using the builtin hooks in mailman.

-- 
·O·  Pierre Habouzit
··O[EMAIL PROTECTED]
OOOhttp://www.madism.org


pgphWDVqBWHPA.pgp
Description: PGP signature
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg

Re: merging debian changelog

2008-01-11 Thread Junichi Uekawa
Hi,

>   Here is a better version, that I believe can be used as a git merge
> driver using this configuration snipplet:
> 
> [merge "merge-debchangelog"]
> name = Debian Changelog merge driver
> driver = /path/to/merge-debchangelog.py %O %A %B %A
> 
> and then, if I'm correct, you can in the .gitattribute of your debian/
> directory set:
> 
> 8<
> /changelog merge=merge-debchangelog
> >8
> 

I'm excited about your code. This is great.


While I wanted to point this to others, apparently, the list archive
doesn't like PGP signed mail, so I can't just point people the URL.

http://lists.madduck.net/pipermail/vcs-pkg/2008-January/000102.html



regards,
junichi
-- 
[EMAIL PROTECTED],netfort.gr.jp}   Debian Project
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg


Re: merging debian changelog

2008-01-07 Thread Pierre Habouzit
On Mon, Jan 07, 2008 at 11:21:44PM +, James Westby wrote:
> On (07/01/08 23:43), Pierre Habouzit wrote:
> >   I know this is a painful thing to do (if you consider the inherent
> > triviality of it), hence I ended up writing a custom merger. This is all
> > very sketchy, but I'm sure people will enhance it :)
> > 
> 
> Hi Pierre,
> 
> I have heard tell of another attempt to do this, and I am currently
> trying to get my hands on that code. Hopefully when I have that we can
> compare the two versions and try and see if any improvements can be made
> to them.
> 
> Thanks,

  Well, I'm quite happy with my last version, that evens "fake" bpo
version to be greater so that the usual debian changelog ordering is
preserved (I never realized that because of backports.org changelogs
weren't ordered by version number …). Anyways, my up to date version
should live here for some time, until I decide to put it in a VCS ;)

  [0] http://madism.org/~madcoder/tmp/merge-debchangelog.py

-- 
·O·  Pierre Habouzit
··O[EMAIL PROTECTED]
OOOhttp://www.madism.org


pgpAGJqTAaptr.pgp
Description: PGP signature
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg


Re: merging debian changelog

2008-01-07 Thread Pierre Habouzit
On Mon, Jan 07, 2008 at 11:55:07PM +, Pierre Habouzit wrote:
> On lun, jan 07, 2008 at 10:43:58 +, Pierre Habouzit wrote:
> >   I know this is a painful thing to do (if you consider the inherent
> > triviality of it), hence I ended up writing a custom merger. This is all
> > very sketchy, but I'm sure people will enhance it :)
> 
>   Here is a better version, that I believe can be used as a git merge
> driver using this configuration snipplet:
> 
> [merge "merge-debchangelog"]
> name = Debian Changelog merge driver
> driver = /path/to/merge-debchangelog.py %O %A %B %A
> 
> and then, if I'm correct, you can in the .gitattribute of your debian/
> directory set:
> 
> 8<
> /changelog merge=merge-debchangelog
> >8

  ok, it's actually in debian/.gitattributes with an 's' and the line
is without a leading slash:
changelog merge=merge-debchangelog

  and it works remarkably well \o/ Now $someone just has to make the
merge of a given version chunk more intelligent (using diff3 e.g. and
disregarding the trailing line, or keeping the one with the "biggest"
date, whichever you see fit) and it should merge debian/changelogs
without a glitch in 99% of the cases :)

some merge-debchangelog pr0n:

$ git merge debian-experimental
merging debian/changelog using Debian Changelog merge driver
Merge made by recursive.
 debian/changelog |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)


-- 
·O·  Pierre Habouzit
··O[EMAIL PROTECTED]
OOOhttp://www.madism.org


pgplQUMjuC6RD.pgp
Description: PGP signature
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg


Re: merging debian changelog

2008-01-07 Thread James Westby
On (07/01/08 23:43), Pierre Habouzit wrote:
>   I know this is a painful thing to do (if you consider the inherent
> triviality of it), hence I ended up writing a custom merger. This is all
> very sketchy, but I'm sure people will enhance it :)
> 

Hi Pierre,

I have heard tell of another attempt to do this, and I am currently
trying to get my hands on that code. Hopefully when I have that we can
compare the two versions and try and see if any improvements can be made
to them.

Thanks,

James

-- 
  James Westby   --GPG Key ID: B577FE13-- http://jameswestby.net/
  seccure key - (3+)k7|M*edCX/.A:n*N!>|&7U.L#9E)Tu)T0>AM - secp256r1/nistp256
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg


Re: merging debian changelog

2008-01-07 Thread Pierre Habouzit
On lun, jan 07, 2008 at 10:43:58 +, Pierre Habouzit wrote:
>   I know this is a painful thing to do (if you consider the inherent
> triviality of it), hence I ended up writing a custom merger. This is all
> very sketchy, but I'm sure people will enhance it :)

  Here is a better version, that I believe can be used as a git merge
driver using this configuration snipplet:

[merge "merge-debchangelog"]
name = Debian Changelog merge driver
driver = /path/to/merge-debchangelog.py %O %A %B %A

and then, if I'm correct, you can in the .gitattribute of your debian/
directory set:

8<
/changelog merge=merge-debchangelog
>8

  I'm not 100% sure it will work, but I think so, and by the way, the
script is fully reusable for other SCM. Its usage is:

  merge-debchangelog.py ANCESTOR YOURS OTHER [OUTPUT]

it's safe to reuse any of the three other argument as the output file,
else stdout is used.

  I didn't put a copyright statement, but consider it be under the BSD
license.
-- 
·O·  Pierre Habouzit
··O[EMAIL PROTECTED]
OOOhttp://www.madism.org
#!/usr/bin/python
import re, sys, apt_pkg, difflib

apt_pkg.InitSystem()

header_re = re.compile('^\S+ \((?P.*)\) 
.*;.*urgency=(?P\w+).*')
footer_re = re.compile('^ --(?: (.*)  (\w\w\w, +(\d| \d|\d\d) \w\w\w \d\d\d\d ' 
+
   '\d\d:\d\d:\d\d [-+]\d\d\d\d( \(.*\))?))?\s*$')
diff_strs = ["<<<\n", "===\n", ">>>\n"]
diff_auto = {' ': 0, '-': 1, '+': 2}

def parse_changelog(file):
chunks = {}
cur = ""
ver = None
for line in open(file).readlines():
match = header_re.match(line)
if match:
if ver: chunks[ver] = cur.strip()
ver = match.group('version')
cur = ''
cur += line
if ver: chunks[ver] = cur.strip()
return chunks

def to_state(l, old, new):
while old != new:
l.append(diff_strs[old])
old = (old + 1) % 3
return new

def do_merge(orig, left, right):
o = parse_changelog(orig) # unused for now
l = parse_changelog(left)
r = parse_changelog(right)
state = 0
conflict = False
res = []
versions = list(set(l.keys() + r.keys()))
versions.sort(lambda x, y: -apt_pkg.VersionCompare(x, y))
for ver in versions:
if ver in l and ver in r and l[ver] != r[ver]:
conflict = True
for line in difflib.ndiff(l[ver].split('\n'), r[ver].split('\n')):
state = to_state(res, state, diff_auto[line[0]])
res.append(line[2:] + "\n")
state = to_state(res, state, 0)
else:
res.append((l.get(ver) or r.get(ver)) + "\n")
res.append("\n")
return conflict, res

if len(sys.argv) not in (4, 5):
sys.stderr.write("""\
usage: merge-debchangelog.py ORIGIN YOURS OTHER [OUTPUT]

  if OUTPUT isn't specified, standard out is assumed
""")

conflict, res = do_merge(sys.argv[1], sys.argv[2], sys.argv[3])
if len(sys.argv) is 4:
sys.stdout.writelines(res)
else:
open(sys.argv[4], "w+").writelines(res)
sys.exit(conflict)


pgpnK3957GU6H.pgp
Description: PGP signature
___
vcs-pkg mailing list
vcs-pkg@lists.madduck.net
http://lists.madduck.net/listinfo/vcs-pkg