Rev 4081: (mbp) add gnu-changelog log format in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Mar 5 09:12:22 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4081
revision-id: pqm at pqm.ubuntu.com-20090305091217-h813qd8f83wghtpr
parent: pqm at pqm.ubuntu.com-20090305070734-voo8r5npkyz1dicx
parent: mbp at sourcefrog.net-20090305083225-mq5kakoa8bzin4jt
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-03-05 09:12:17 +0000
message:
  (mbp) add gnu-changelog log format
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
  bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
  bzrlib/tests/test_branchbuilder.py test_branchbuilder.p-20070427022007-zlxpqz2lannhk6y8-2
  doc/developers/testing.txt     testing.txt-20080812140359-i70zzh6v2z7grqex-1
    ------------------------------------------------------------
    revno: 4070.4.12
    revision-id: mbp at sourcefrog.net-20090305083225-mq5kakoa8bzin4jt
    parent: mbp at sourcefrog.net-20090305021546-catovbht4xnwypto
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Thu 2009-03-05 19:32:25 +1100
    message:
      Kill trailing whitespace
    modified:
      bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
    ------------------------------------------------------------
    revno: 4070.4.11
    revision-id: mbp at sourcefrog.net-20090305021546-catovbht4xnwypto
    parent: mbp at sourcefrog.net-20090305005727-524hs3mn2xxl25qx
    parent: pqm at pqm.ubuntu.com-20090304163710-r7hhqdi9f3jsbe5g
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Thu 2009-03-05 13:15:46 +1100
    message:
      merge news
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/annotate.py             annotate.py-20050922133147-7c60541d2614f022
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
      bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
      bzrlib/revision.py             revision.py-20050309040759-e77802c08f3999d5
      bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
      bzrlib/tests/branch_implementations/test_last_revision_info.py test_last_revision_i-20070201133317-51mzi40m8hv1i0i9-1
      bzrlib/tests/test_annotate.py  test_annotate.py-20061213215015-sttc9agsxomls7q0-1
      bzrlib/tests/test_commit.py    test_commit.py-20050914060732-279f057f8c295434
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
      bzrlib/tests/test_options.py   testoptions.py-20051014093702-96457cfc86319a8f
      bzrlib/tests/test_revision.py  testrevision.py-20050804210559-46f5e1eb67b01289
      doc/developers/revision-properties.txt revisionproperties.t-20070807133526-w57m8zv5o7t5kugm-1
      doc/en/user-guide/recording_changes.txt recording_changes.tx-20071121073725-0corxykv5irjal00-4
    ------------------------------------------------------------
    revno: 4070.4.10
    revision-id: mbp at sourcefrog.net-20090305005727-524hs3mn2xxl25qx
    parent: mbp at sourcefrog.net-20090304065623-l2vub3zxscvhs17a
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Thu 2009-03-05 11:57:27 +1100
    message:
      Change literal tab character to \t
    modified:
      bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
    ------------------------------------------------------------
    revno: 4070.4.9
    revision-id: mbp at sourcefrog.net-20090304065623-l2vub3zxscvhs17a
    parent: mbp at sourcefrog.net-20090304063035-90s1mp8dd1jz8rbc
    parent: pqm at pqm.ubuntu.com-20090303085413-35seprvnu885xorz
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Wed 2009-03-04 17:56:23 +1100
    message:
      merge news
    added:
      doc/developers/ec2-windows.txt ec2windows.txt-20090219062112-2ga0nqpcm7n02njf-1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/smart/bzrdir.py         bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
      bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
      bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
      bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
      doc/developers/index.txt       index.txt-20070508041241-qznziunkg0nffhiw-1
      doc/developers/network-protocol.txt networkprotocol.txt-20070903044232-woustorrjbmg5zol-1
    ------------------------------------------------------------
    revno: 4070.4.8
    revision-id: mbp at sourcefrog.net-20090304063035-90s1mp8dd1jz8rbc
    parent: mbp at sourcefrog.net-20090303015414-3vibuc8g1tv5sxkv
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Wed 2009-03-04 17:30:35 +1100
    message:
      Rename format to gnu-changelog
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
    ------------------------------------------------------------
    revno: 4070.4.7
    revision-id: mbp at sourcefrog.net-20090303015414-3vibuc8g1tv5sxkv
    parent: mbp at sourcefrog.net-20090303015142-nbcttlt1rirtit7f
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 12:54:14 +1100
    message:
      NEWS about --log-format changelog
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 4070.4.6
    revision-id: mbp at sourcefrog.net-20090303015142-nbcttlt1rirtit7f
    parent: mbp at sourcefrog.net-20090303014942-t1rmvvzwy77okyli
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 12:51:42 +1100
    message:
      Force timestamp in tests for changelog format
    modified:
      bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
    ------------------------------------------------------------
    revno: 4070.4.5
    revision-id: mbp at sourcefrog.net-20090303014942-t1rmvvzwy77okyli
    parent: mbp at sourcefrog.net-20090303011242-t7340ejw7rczgu04
    parent: mbp at sourcefrog.net-20090303014532-d223fxy97cb1og8f
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 12:49:42 +1100
    message:
      Merge build_commit(timestamp=) changes so we can have better changelog tests
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
      bzrlib/tests/test_branchbuilder.py test_branchbuilder.p-20070427022007-zlxpqz2lannhk6y8-2
      doc/developers/testing.txt     testing.txt-20080812140359-i70zzh6v2z7grqex-1
        ------------------------------------------------------------
        revno: 4070.5.2
        revision-id: mbp at sourcefrog.net-20090303014532-d223fxy97cb1og8f
        parent: mbp at sourcefrog.net-20090303014355-st0wve4ka9a5tcem
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: branchbuilder
        timestamp: Tue 2009-03-03 12:45:32 +1100
        message:
          Recommend setting timestamp in BranchBuilder
        modified:
          doc/developers/testing.txt     testing.txt-20080812140359-i70zzh6v2z7grqex-1
        ------------------------------------------------------------
        revno: 4070.5.1
        revision-id: mbp at sourcefrog.net-20090303014355-st0wve4ka9a5tcem
        parent: pqm at pqm.ubuntu.com-20090302155409-89pygn9tisbc0lir
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: branchbuilder
        timestamp: Tue 2009-03-03 12:43:55 +1100
        message:
          BranchBuilder now takes a timestamp for commits
        modified:
          NEWS                           NEWS-20050323055033-4e00b5db738777ff
          bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
          bzrlib/tests/test_branchbuilder.py test_branchbuilder.p-20070427022007-zlxpqz2lannhk6y8-2
    ------------------------------------------------------------
    revno: 4070.4.4
    revision-id: mbp at sourcefrog.net-20090303011242-t7340ejw7rczgu04
    parent: mbp at sourcefrog.net-20090303011031-urdvx0hdgkl0odqm
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 12:12:42 +1100
    message:
      Add dodgy smoketest for gnu changelogs
    modified:
      bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
    ------------------------------------------------------------
    revno: 4070.4.3
    revision-id: mbp at sourcefrog.net-20090303011031-urdvx0hdgkl0odqm
    parent: mbp at sourcefrog.net-20090303005352-1h7l7yn0cvrf99gu
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 12:10:31 +1100
    message:
      Simplify make_branch_builder
    modified:
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
    ------------------------------------------------------------
    revno: 4070.4.2
    revision-id: mbp at sourcefrog.net-20090303005352-1h7l7yn0cvrf99gu
    parent: mbp at sourcefrog.net-20090303004618-imonoyb0c1devx1m
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 11:53:52 +1100
    message:
      Remove obsolete run_bzr wrapper from test_logformats
    modified:
      bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
    ------------------------------------------------------------
    revno: 4070.4.1
    revision-id: mbp at sourcefrog.net-20090303004618-imonoyb0c1devx1m
    parent: pqm at pqm.ubuntu.com-20090302155409-89pygn9tisbc0lir
    author: Andrea Bolognani <eof at kiyuko.org>
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: gnu-changelog
    timestamp: Tue 2009-03-03 11:46:18 +1100
    message:
      New GNU Changelog log format
    modified:
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/tests/blackbox/test_logformats.py test_logformats.py-20060216104208-ba5a16c83480b7e4
=== modified file 'NEWS'
--- a/NEWS	2009-03-05 03:30:30 +0000
+++ b/NEWS	2009-03-05 09:12:17 +0000
@@ -26,6 +26,9 @@
       in chapter 7 of the User Guide and ``bzr help view`` for details.
       (Ian Clatworthy)
 
+    * GNU Changelog output can now be produced by ``bzr log --format
+      gnu-changelog``.  (Andrea Bolognani, Martin Pool)
+
     * The ``-Dmemory`` flag now gives memory information on Windows.
       (John Arbash Meinel)
 
@@ -136,6 +139,9 @@
       Revision.get_apparent_authors(), which returns a list. The former
       now returns the first item that would be returned from the second.
 
+    * The ``BranchBuilder`` test helper now accepts a ``timestamp``
+      parameter to ``build_commit`` and ``build_snapshot``.  (Martin Pool)
+
     * The ``_fetch_*`` attributes on ``Repository`` are now on
       ``RepositoryFormat``, more accurately reflecting their intent (they
       describe a disk format capability, not state of a particular

=== modified file 'bzrlib/branchbuilder.py'
--- a/bzrlib/branchbuilder.py	2009-02-23 15:29:35 +0000
+++ b/bzrlib/branchbuilder.py	2009-03-05 08:32:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008 Canonical Ltd
+# Copyright (C) 2007, 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -75,13 +75,20 @@
             format=format, force_new_tree=False)
         self._tree = None
 
-    def build_commit(self):
-        """Build a commit on the branch."""
+    def build_commit(self, **commit_kwargs):
+        """Build a commit on the branch.
+
+        This makes a commit with no real file content for when you only want
+        to look at the revision graph structure.
+
+        :param commit_kwargs: Arguments to pass through to commit, such as
+             timestamp.
+        """
         tree = memorytree.MemoryTree.create_on_branch(self._branch)
         tree.lock_write()
         try:
             tree.add('')
-            return self._do_commit(tree)
+            return self._do_commit(tree, **commit_kwargs)
         finally:
             tree.unlock()
 
@@ -137,7 +144,7 @@
         self._tree = None
 
     def build_snapshot(self, revision_id, parent_ids, actions,
-                       message=None):
+                       message=None, timestamp=None):
         """Build a commit, shaped in a specific way.
 
         :param revision_id: The handle for the new commit, can be None
@@ -150,6 +157,8 @@
             ('rename', ('orig-path', 'new-path'))
         :param message: An optional commit message, if not supplied, a default
             commit message will be written.
+        :param timestamp: If non-None, set the timestamp of the commit to this
+            value.
         :return: The revision_id of the new commit
         """
         if parent_ids is not None:
@@ -210,7 +219,8 @@
             tree.add(to_add_files, to_add_file_ids, to_add_kinds)
             for file_id, content in new_contents.iteritems():
                 tree.put_file_bytes_non_atomic(file_id, content)
-            return self._do_commit(tree, message=message, rev_id=revision_id)
+            return self._do_commit(tree, message=message, rev_id=revision_id,
+                timestamp=timestamp)
         finally:
             tree.unlock()
 

=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py	2009-02-27 15:14:34 +0000
+++ b/bzrlib/log.py	2009-03-05 02:15:46 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -1371,6 +1371,43 @@
         return self.truncate(prefix + " ".join(out).rstrip('\n'), max_chars)
 
 
+class ChangeLogLogFormatter(LogFormatter):
+
+    supports_merge_revisions = True
+    supports_delta = True
+    supports_tags = True
+
+    def log_revision(self, revision):
+        """Log a revision, either merged or not."""
+        to_file = self.to_file
+
+        date_str = format_date(revision.rev.timestamp,
+                               revision.rev.timezone or 0,
+                               self.show_timezone,
+                               date_fmt='%Y-%m-%d',
+                               show_offset=False)
+        committer_str = revision.rev.committer.replace (' <', '  <')
+        to_file.write('%s  %s\n\n' % (date_str,committer_str))
+
+        if revision.delta is not None:
+            for c in revision.delta.added + revision.delta.removed + revision.delta.modified:
+                path, = c[:1]
+                to_file.write('\t* %s:\n' % (path,))
+            for c in revision.delta.renamed:
+                oldpath,newpath = c[:2]
+                # For renamed files, show both the old and the new path
+                to_file.write('\t* %s:\n\t* %s:\n' % (oldpath,newpath))
+            to_file.write('\n')
+
+        if not revision.rev.message:
+            to_file.write('\tNo commit message\n')
+        else:
+            message = revision.rev.message.rstrip('\r\n')
+            for l in message.split('\n'):
+                to_file.write('\t%s\n' % (l.lstrip(),))
+            to_file.write('\n')
+
+
 def line_log(rev, max_chars):
     lf = LineLogFormatter(None)
     return lf.log_string(None, rev, max_chars)
@@ -1400,6 +1437,9 @@
                                 'Detailed log format')
 log_formatter_registry.register('line', LineLogFormatter,
                                 'Log format with one line per revision')
+log_formatter_registry.register(
+    'gnu-changelog', ChangeLogLogFormatter,
+    'Format used by GNU ChangeLog files')
 
 
 def register_formatter(name, formatter):

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-03-03 05:50:55 +0000
+++ b/bzrlib/tests/__init__.py	2009-03-04 06:56:23 +0000
@@ -2114,9 +2114,8 @@
         return memorytree.MemoryTree.create_on_branch(b)
 
     def make_branch_builder(self, relpath, format=None):
-        url = self.get_url(relpath)
-        tran = get_transport(url)
-        return branchbuilder.BranchBuilder(get_transport(url), format=format)
+        return branchbuilder.BranchBuilder(self.get_transport(relpath),
+            format=format)
 
     def overrideEnvironmentForTesting(self):
         os.environ['HOME'] = self.test_home_dir

=== modified file 'bzrlib/tests/blackbox/test_logformats.py'
--- a/bzrlib/tests/blackbox/test_logformats.py	2009-01-17 01:30:58 +0000
+++ b/bzrlib/tests/blackbox/test_logformats.py	2009-03-05 00:57:27 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -13,11 +13,15 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
 """Black-box tests for default log_formats/log_formatters
 """
 
+
 import os
 
+
 from bzrlib.branch import Branch
 from bzrlib.tests import TestCaseInTempDir
 from bzrlib.config import (ensure_config_dir_exists, config_filename)
@@ -25,61 +29,60 @@
 
 class TestLogFormats(TestCaseInTempDir):
 
-    def bzr(self, *args, **kwargs):
-        return self.run_bzr(*args, **kwargs)[0]
-
     def test_log_default_format(self):
         self.setup_config()
 
-        self.bzr('init')
+        self.run_bzr('init')
         open('a', 'wb').write('foo\n')
-        self.bzr('add a')
+        self.run_bzr('add a')
 
-        self.bzr('commit -m 1')
+        self.run_bzr('commit -m 1')
         open('a', 'wb').write('baz\n')
 
-        self.bzr('commit -m 2')
+        self.run_bzr('commit -m 2')
 
         # only the lines formatter is this short
-        self.assertEquals(3, len(self.bzr('log').split('\n')))
+        self.assertEquals(3, len(self.run_bzr('log')[0].split('\n')))
 
     def test_log_format_arg(self):
-        self.bzr('init')
+        self.run_bzr('init')
         open('a', 'wb').write('foo\n')
-        self.bzr('add a')
+        self.run_bzr('add a')
 
-        self.bzr('commit -m 1')
+        self.run_bzr('commit -m 1')
         open('a', 'wb').write('baz\n')
 
-        self.bzr('commit -m 2')
+        self.run_bzr('commit -m 2')
 
         # only the lines formatter is this short
-        self.assertEquals(7, len(self.bzr('log --log-format short').split('\n')))
+        self.assertEquals(7,
+            len(self.run_bzr('log --log-format short')[0].split('\n')))
 
     def test_missing_default_format(self):
         self.setup_config()
 
         os.mkdir('a')
         os.chdir('a')
-        self.bzr('init')
+        self.run_bzr('init')
 
         open('a', 'wb').write('foo\n')
-        self.bzr('add a')
-        self.bzr('commit -m 1')
+        self.run_bzr('add a')
+        self.run_bzr('commit -m 1')
 
         os.chdir('..')
-        self.bzr('branch a b')
+        self.run_bzr('branch a b')
         os.chdir('a')
 
         open('a', 'wb').write('bar\n')
-        self.bzr('commit -m 2')
+        self.run_bzr('commit -m 2')
 
         open('a', 'wb').write('baz\n')
-        self.bzr('commit -m 3')
+        self.run_bzr('commit -m 3')
 
         os.chdir('../b')
 
-        self.assertEquals(5, len(self.bzr('missing', retcode=1).split('\n')))
+        self.assertEquals(5,
+            len(self.run_bzr('missing', retcode=1)[0].split('\n')))
 
         os.chdir('..')
 
@@ -88,29 +91,57 @@
 
         os.mkdir('a')
         os.chdir('a')
-        self.bzr('init')
+        self.run_bzr('init')
 
         open('a', 'wb').write('foo\n')
-        self.bzr('add a')
-        self.bzr('commit -m 1')
+        self.run_bzr('add a')
+        self.run_bzr('commit -m 1')
 
         os.chdir('..')
-        self.bzr('branch a b')
+        self.run_bzr('branch a b')
         os.chdir('a')
 
         open('a', 'wb').write('bar\n')
-        self.bzr('commit -m 2')
+        self.run_bzr('commit -m 2')
 
         open('a', 'wb').write('baz\n')
-        self.bzr('commit -m 3')
+        self.run_bzr('commit -m 3')
 
         os.chdir('../b')
 
-        self.assertEquals(9, len(self.bzr('missing --log-format short',
-                                          retcode=1).split('\n')))
+        self.assertEquals(9,
+            len(self.run_bzr('missing --log-format short',
+                retcode=1)[0].split('\n')))
 
         os.chdir('..')
 
+    def test_logformat_gnu_changelog(self):
+        # from http://launchpad.net/bugs/29582/
+        self.setup_config()
+        repo_url = self.make_trivial_history()
+
+        out, err = self.run_bzr(
+            ['log', self.get_url('repo/a'),
+             '--log-format=gnu-changelog',
+             '--timezone=utc'])
+        self.assertEquals(err, '')
+        self.assertEqualDiff(out,
+"""2009-03-03  Joe Foo  <joe at foo.com>
+
+\tcommit 1
+
+""")
+
+    def make_trivial_history(self):
+        """Make a one-commit history and return the URL of the branch"""
+        repo = self.make_repository('repo', shared=True, format='1.6')
+        bb = self.make_branch_builder('repo/a')
+        bb.start_series()
+        bb.build_snapshot('rev-1', None,
+            [('add', ('', 'root-id', 'directory', ''))],
+            timestamp=1236045060)
+        bb.finish_series()
+        return self.get_url('repo/a')
 
     def setup_config(self):
         if os.path.isfile(config_filename()):

=== modified file 'bzrlib/tests/test_branchbuilder.py'
--- a/bzrlib/tests/test_branchbuilder.py	2009-01-17 01:30:58 +0000
+++ b/bzrlib/tests/test_branchbuilder.py	2009-03-03 01:43:55 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Canonical Ltd
+# Copyright (C) 2007, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -59,6 +59,20 @@
             'commit 1',
             branch.repository.get_revision(branch.last_revision()).message)
 
+    def test_build_commit_timestamp(self):
+        """You can set a date when committing."""
+        builder = self.make_branch_builder('foo')
+        rev_id = builder.build_commit(timestamp=1236043340)
+        branch = builder.get_branch()
+        self.assertEqual((1, rev_id), branch.last_revision_info())
+        rev = branch.repository.get_revision(branch.last_revision())
+        self.assertEqual(
+            'commit 1',
+            rev.message)
+        self.assertEqual(
+            1236043340,
+            int(rev.timestamp))
+
     def test_build_two_commits(self):
         """The second commit has the right parents and message."""
         builder = BranchBuilder(self.get_transport().clone('foo'))
@@ -130,6 +144,16 @@
                               (u'b', 'b-id', 'directory'),
                              ], rev_tree)
 
+    def test_commit_timestamp(self):
+        builder = self.make_branch_builder('foo')
+        rev_id = builder.build_snapshot(None, None,
+            [('add', (u'', None, 'directory', None))],
+            timestamp=1234567890)
+        rev = builder.get_branch().repository.get_revision(rev_id)
+        self.assertEqual(
+            1234567890,
+            int(rev.timestamp))
+
     def test_commit_message_default(self):
         builder = BranchBuilder(self.get_transport().clone('foo'))
         rev_id = builder.build_snapshot(None, None,

=== modified file 'doc/developers/testing.txt'
--- a/doc/developers/testing.txt	2008-08-28 07:11:13 +0000
+++ b/doc/developers/testing.txt	2009-03-03 01:45:32 +0000
@@ -516,6 +516,10 @@
 
 Please see bzrlib.branchbuilder for more details.
 
+If you're going to examine the commit timestamps e.g. in a test for log
+output, you should set the timestamp on the tree, rather than using fuzzy
+matches in the test.
+
 
 TreeBuilder
 ~~~~~~~~~~~




More information about the bazaar-commits mailing list