From 2e1d2ee7db9b2b00c525f0207181af8c33f956f3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 1 Nov 2006 01:18:06 +0100 Subject: [PATCH] Don't barf on merge commits. Print todo list if something is left at the end. --- buildscripts/git-update-changelog.py | 51 ++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/buildscripts/git-update-changelog.py b/buildscripts/git-update-changelog.py index a1cb3cf2f9..23390b1127 100644 --- a/buildscripts/git-update-changelog.py +++ b/buildscripts/git-update-changelog.py @@ -9,6 +9,7 @@ import optparse def read_pipe (x): print 'pipe', x return os.popen (x).read () + def system (x): print x return os.system (x) @@ -45,6 +46,9 @@ class Commit: return files + def has_patch (self): + return self.touched_files () <> [] + def apply (self, add_del_files): def note_add_file (x): add_del_files.append (('add', x.group (1))) @@ -80,9 +84,17 @@ def parse_commit_log (log): c = Commit (locals ()) return c -def parse_add_changes (from_commit): - - log = read_pipe ('git log %(from_commit)s..' % locals ()) +def parse_add_changes (from_commit, max_count=0): + opt = '' + rest = '..' + if max_count: + + # fixme. + assert max_count == 1 + opt = '--max-count=%d' % max_count + rest = '' + + log = read_pipe ('git log %(opt)s %(from_commit)s%(rest)s' % locals ()) log = log[len ('commit '):] log = log.strip () @@ -131,14 +143,21 @@ Run this file from the CVS directory, with --git-dir log = open ('ChangeLog').read () - if not options.start: - print 'Must set start committish.' - sys.exit (1) - if options.gitdir: os.environ['GIT_DIR'] = options.gitdir - - commits = parse_add_changes (options.start) + + + if not args: + if not options.start: + print 'Must set start committish.' + sys.exit (1) + + commits = parse_add_changes (options.start) + else: + commits = [] + for a in args: + commits += parse_add_changes (a, max_count=1) + if not commits: return @@ -154,7 +173,14 @@ Run this file from the CVS directory, with --git-dir collated_log = '' collated_message = '' - for c in commits: + while commits: + c = commits[0] + commits = commits[1:] + + if not c.has_patch (): + print 'patchless commit (merge?)' + continue + print 'patch ', c.committish try: c.apply (file_adddel) @@ -199,6 +225,11 @@ Run this file from the CVS directory, with --git-dir open ('.msg','w').write (collated_message) print '\nCommit message\n**\n%s\n**\n' % collated_message print '\nRun:\n\n\tcvs commit -F .msg\n\n' + + + if commits: + print 'Commits left to do:' + print ' '.join ([c.committish for c in commits]) main () -- 2.39.5