From 00320a91755ec1dc638f58b422f277c2d51b8643 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 28 Oct 2006 21:14:22 +0000 Subject: [PATCH] * emacsclient.patch: * server.el.patch: move server/emacsclient to elisp/ * buildscripts/git-update-changelog.py (Commit.note_del_file): apply patches too * elisp/server.el.patch: move emacs patches. * elisp/emacsclient.patch: emacsclient too. * buildscripts/git-update-changelog.py: ignore ChangeLog * ChangeLog: * buildscripts/git-update-changelog.py: script to update ChangeLog with Git messages. --- ChangeLog | 21 ++++- buildscripts/git-update-changelog.py | 81 ++++++++++++++++---- emacsclient.patch => elisp/emacsclient.patch | 0 server.el.patch => elisp/server.el.patch | 0 4 files changed, 88 insertions(+), 14 deletions(-) rename emacsclient.patch => elisp/emacsclient.patch (100%) rename server.el.patch => elisp/server.el.patch (100%) diff --git a/ChangeLog b/ChangeLog index 91a218320b..32038e168f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,23 @@ -2006-10-28 Han-Wen Nienhuys +2006-10-28 Han-Wen Nienhuys + + git commit e5d9c526aec8d0c7c7727068b13c346c475ac7c3 + + * emacsclient.patch: + * server.el.patch: + move server/emacsclient to elisp/ + + git commit f6191da666fd8897411e866594616cd0f7ae6350 + + * buildscripts/git-update-changelog.py (Commit.note_del_file): + apply patches too + + * elisp/server.el.patch: + move emacs patches. + + git commit 80844c903201b9df79ae81d4edcfbd299e08a9f7 + + * elisp/emacsclient.patch: + emacsclient too. git commit 64179afe25bf5723fe9bb5a6631799c050d12de2 diff --git a/buildscripts/git-update-changelog.py b/buildscripts/git-update-changelog.py index a2c3e5356e..2817ff31f7 100644 --- a/buildscripts/git-update-changelog.py +++ b/buildscripts/git-update-changelog.py @@ -8,6 +8,12 @@ import optparse def read_pipe (x): print 'pipe', x return os.popen (x).read () +def system (x): + print x + return os.system (x) + +class PatchFailed(Exception): + pass class Commit: def __init__ (self, dict): @@ -21,29 +27,49 @@ class Commit: self.date = ' '.join (self.date.split (' ')[:-1]) self.date = time.strptime (self.date, '%a %b %d %H:%M:%S %Y') - + m = re.search ('(.*)<(.*)>', self.author) - self.email = m.group (2) - self.name = m.group (1) - + self.email = m.group (2).strip () + self.name = m.group (1).strip () + self.diff = read_pipe ('git show %s' % self.committish) def touched_files (self): files = [] def note_file (x): files.append (x.group (1)) return '' - - diff = read_pipe ('git show %s' % self.committish) + re.sub ('\n--- a/([^\n]+)\n', - note_file, diff) + note_file, self.diff) re.sub('\n--- /dev/null\n\\+\\+\\+ b/([^\n]+)', - note_file, diff) + note_file, self.diff) return files -def parse_commit_log (log): - print log + def apply (self, add_del_files): + def note_add_file (x): + add_del_files.append (('add', x.group (1))) + return '' + + def note_del_file (x): + add_del_files.append (('del', x.group (1))) + return '' + + + re.sub('\n--- /dev/null\n\\+\\+\\+ b/([^\n]+)', + note_add_file, self.diff) + + re.sub('\n--- a/([^\n]+)\n\\+\\+\\+ /dev/null', + note_del_file, self.diff) + + p = os.popen ('patch -f -p1 ', 'w') + p.write (self.diff) + + if p.close (): + raise PatchFailed, self.committish + +def parse_commit_log (log): committish = re.search ('^([^\n]+)', log).group (1) author = re.search ('\nAuthor:\s+([^\n]+)', log).group (1) date_match = re.search ('\nDate:\s+([^\n]+)', log) @@ -67,6 +93,7 @@ def parse_add_changes (from_commit): return [] commits = map (parse_commit_log, re.split ('\ncommit ', log)) + commits.reverse () return commits @@ -97,12 +124,23 @@ def find_last_checked_in_commit (log): def main (): - p = optparse.OptionParser ("usage git-update-changelog.py --options") + p = optparse.OptionParser (usage="usage git-update-changelog.py [options]", + description=""" +Apply GIT patches and update change log. + +Run this file from the CVS directory, with --git-dir +""") p.add_option ("--start", action='store', default='', dest="start", help="start of log messages to merge.") + + p.add_option ("--git-dir", + action='store', + default='', + dest="gitdir", + help="the GIT directory to merge.") (options, args) = p.parse_args () @@ -114,6 +152,9 @@ def main (): print 'processing commits from ', id, options.start + if options.gitdir: + os.environ['GIT_DIR'] = options.gitdir + commits = parse_add_changes (options.start) if not commits: return @@ -124,8 +165,15 @@ def main (): first = header (commits[0]) + '\n' if first == log[:len (first)]: log = log[len (first):] - + + file_adddel = [] for c in commits: + print 'patch ', c.committish + try: + c.apply (file_adddel) + except PatchFailed: + break + if c.touched_files () == ['ChangeLog']: continue @@ -138,12 +186,19 @@ def main (): new_log += changelog_body (c) last_commit = c + for (op, f) in file_adddel: + if op == 'del': + system ('cvs remove %(f)s' % locals ()) + if op == 'add': + system ('cvs add %(f)s' % locals ()) + new_log = header (last_commit) + new_log + '\n' log = new_log + log + try: os.unlink ('ChangeLog~') - except IOError: + except OSError: pass os.rename ('ChangeLog', 'ChangeLog~') diff --git a/emacsclient.patch b/elisp/emacsclient.patch similarity index 100% rename from emacsclient.patch rename to elisp/emacsclient.patch diff --git a/server.el.patch b/elisp/server.el.patch similarity index 100% rename from server.el.patch rename to elisp/server.el.patch -- 2.39.2