Rev 2556: Merge bzr.dev and resolve conflits. (good use case for an enhanced merge in file:///v/home/vila/src/cleanup/run_bzr/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Jun 27 20:13:56 BST 2007


At file:///v/home/vila/src/cleanup/run_bzr/

------------------------------------------------------------
revno: 2556
revision-id: v.ladeuil+lp at free.fr-20070627191350-8ktbl3ac9gdi6hpr
parent: v.ladeuil+lp at free.fr-20070626203249-sqm4afiai5dxofum
parent: pqm at pqm.ubuntu.com-20070627080723-ci6ghe3bsm0snyit
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: run_bzr
timestamp: Wed 2007-06-27 21:13:50 +0200
message:
  Merge bzr.dev and resolve conflits. (good use case for an enhanced merge
  algorithm, many conflits should at least be presented in a better way).
added:
  bzrlib/api.py                  api.py-20070626082640-35lspz7j0ys7a8ld-1
  doc/developers/api-versioning.txt apiversioning.txt-20070626065626-iiihgmhgkv91uphz-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
  bzrlib/tests/blackbox/test_merge_directive.py test_merge_directive-20070302012039-zh7uhy39biairtn0-1
  bzrlib/tests/blackbox/test_outside_wt.py test_outside_wt.py-20060116200058-98edd33e7db8bdde
  bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
  bzrlib/tests/blackbox/test_too_much.py blackbox.py-20050620052131-a7370d756399f615
  bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
  bzrlib/tests/test_api.py       testapi.py-20051027033546-6f9be2d308d18a52
  bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
  bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
  bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
  doc/developers/index.txt       index.txt-20070508041241-qznziunkg0nffhiw-1
    ------------------------------------------------------------
    revno: 2552.1.5
    revision-id: pqm at pqm.ubuntu.com-20070627080723-ci6ghe3bsm0snyit
    parent: pqm at pqm.ubuntu.com-20070627051257-kgk2thfvi2k3k37o
    parent: mbp at sourcefrog.net-20070627073753-rrxu5bbux3vi5yda
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-06-27 09:07:23 +0100
    message:
      Give a cleaner error when failing to decode knit index entry.
        ------------------------------------------------------------
        revno: 2552.1.3.2.1
        revision-id: mbp at sourcefrog.net-20070627073753-rrxu5bbux3vi5yda
        parent: pqm at pqm.ubuntu.com-20070627023032-h316n5k05g1nqqem
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: knit-index-reader
        timestamp: Wed 2007-06-27 17:37:53 +1000
        message:
          Give a cleaner error when failing to decode knit index entry.
    ------------------------------------------------------------
    revno: 2552.1.4
    revision-id: pqm at pqm.ubuntu.com-20070627051257-kgk2thfvi2k3k37o
    parent: pqm at pqm.ubuntu.com-20070627023032-h316n5k05g1nqqem
    parent: mbp at sourcefrog.net-20070627043304-wn1incchxkxa0h2l
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-06-27 06:12:57 +0100
    message:
      Remove use of 'assert False' to raise an exception unconditionally
        ------------------------------------------------------------
        revno: 2552.1.3.1.1
        revision-id: mbp at sourcefrog.net-20070627043304-wn1incchxkxa0h2l
        parent: pqm at pqm.ubuntu.com-20070627023032-h316n5k05g1nqqem
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: trivial
        timestamp: Wed 2007-06-27 14:33:04 +1000
        message:
          Remove use of 'assert False' to raise an exception unconditionally
    ------------------------------------------------------------
    revno: 2552.1.3
    revision-id: pqm at pqm.ubuntu.com-20070627023032-h316n5k05g1nqqem
    parent: pqm at pqm.ubuntu.com-20070626234309-j6n7rdpbmjjfgicn
    parent: mbp at sourcefrog.net-20070627014303-z4ichnqm91hhm4ww
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-06-27 03:30:32 +0100
    message:
      Cleanup blackbox tests
        ------------------------------------------------------------
        revno: 2530.3.7
        revision-id: mbp at sourcefrog.net-20070627014303-z4ichnqm91hhm4ww
        parent: mbp at sourcefrog.net-20070626101529-omfq0howuazwtr3s
        parent: pqm at pqm.ubuntu.com-20070626234309-j6n7rdpbmjjfgicn
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Wed 2007-06-27 11:43:03 +1000
        message:
          merge trunk
        ------------------------------------------------------------
        revno: 2530.3.6
        revision-id: mbp at sourcefrog.net-20070626101529-omfq0howuazwtr3s
        parent: mbp at sourcefrog.net-20070626101427-b8x0vsdg7b1e6f4x
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Tue 2007-06-26 20:15:29 +1000
        message:
          Remove BzrTestBase alias (little used)
        ------------------------------------------------------------
        revno: 2530.3.5
        revision-id: mbp at sourcefrog.net-20070626101427-b8x0vsdg7b1e6f4x
        parent: mbp at sourcefrog.net-20070626101233-hrmvl09320gt6b8m
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Tue 2007-06-26 20:14:27 +1000
        message:
          NEWS on run_bzr changes
        ------------------------------------------------------------
        revno: 2530.3.4
        revision-id: mbp at sourcefrog.net-20070626101233-hrmvl09320gt6b8m
        parent: mbp at sourcefrog.net-20070626093507-6g30srio9kuy2j0e
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Tue 2007-06-26 20:12:33 +1000
        message:
          Deprecate run_bzr_captured in favour of just  run_bzr
        ------------------------------------------------------------
        revno: 2530.3.3
        revision-id: mbp at sourcefrog.net-20070626093507-6g30srio9kuy2j0e
        parent: mbp at sourcefrog.net-20070626084623-5l1ej6s026urooi1
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Tue 2007-06-26 19:35:07 +1000
        message:
          Clean up some callers that use varargs syntax for run_bzr, but don't 
          deprecate it yet because it's too widely used.
          
          Separate out _run_bzr_core from _run_bzr_autosplit.
          
          Remove long-deprecated TestCase.merge helper.
        ------------------------------------------------------------
        revno: 2530.3.2
        revision-id: mbp at sourcefrog.net-20070626084623-5l1ej6s026urooi1
        parent: mbp at sourcefrog.net-20070626080236-14ihgomtffc9tezj
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Tue 2007-06-26 18:46:23 +1000
        message:
          Refactoring run_bzr code into more of a common base.
        ------------------------------------------------------------
        revno: 2530.3.1
        revision-id: mbp at sourcefrog.net-20070626080236-14ihgomtffc9tezj
        parent: pqm at pqm.ubuntu.com-20070615082222-98j9j9nbl6p2dx0m
        committer: Martin Pool <mbp at sourcefrog.net>
        branch nick: cleanup-runbzr
        timestamp: Tue 2007-06-26 18:02:36 +1000
        message:
          Cleanup old variations on run_bzr in the test suite
    ------------------------------------------------------------
    revno: 2552.1.2
    revision-id: pqm at pqm.ubuntu.com-20070626234309-j6n7rdpbmjjfgicn
    parent: pqm at pqm.ubuntu.com-20070626191000-flte155pupv54bcs
    parent: robertc at robertcollins.net-20070626224643-50a7lzwugne0d8o0
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-06-27 00:43:09 +0100
    message:
      (robertc) Export explicit API compatibility for bzrlib.
        ------------------------------------------------------------
        revno: 2550.2.5
        revision-id: robertc at robertcollins.net-20070626224643-50a7lzwugne0d8o0
        parent: robertc at robertcollins.net-20070626085341-pb8fsoij016itqgf
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: api_api
        timestamp: Wed 2007-06-27 08:46:43 +1000
        message:
          NEWS entry was incorrectly capitalised.
        ------------------------------------------------------------
        revno: 2550.2.4
        revision-id: robertc at robertcollins.net-20070626085341-pb8fsoij016itqgf
        parent: robertc at robertcollins.net-20070626085220-iovhwfjflk8vffbh
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: api_api
        timestamp: Tue 2007-06-26 18:53:41 +1000
        message:
          NEWS.
        ------------------------------------------------------------
        revno: 2550.2.3
        revision-id: robertc at robertcollins.net-20070626085220-iovhwfjflk8vffbh
        parent: robertc at robertcollins.net-20070626082724-q95taws12ajox2io
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: api_api
        timestamp: Tue 2007-06-26 18:52:20 +1000
        message:
          Add require_api API.
        ------------------------------------------------------------
        revno: 2550.2.2
        revision-id: robertc at robertcollins.net-20070626082724-q95taws12ajox2io
        parent: robertc at robertcollins.net-20070626065720-w0btzadye6lpq104
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: api_api
        timestamp: Tue 2007-06-26 18:27:24 +1000
        message:
          Add helpers to get api versions from objects.
        ------------------------------------------------------------
        revno: 2550.2.1
        revision-id: robertc at robertcollins.net-20070626065720-w0btzadye6lpq104
        parent: pqm at pqm.ubuntu.com-20070625174647-pocypsjmp861qgv7
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: api_api
        timestamp: Tue 2007-06-26 16:57:20 +1000
        message:
          API Versioning proposal document.
    ------------------------------------------------------------
    revno: 2552.1.1
    revision-id: pqm at pqm.ubuntu.com-20070626191000-flte155pupv54bcs
    parent: pqm at pqm.ubuntu.com-20070626061722-8m49gdqd8cb8zc0c
    parent: john at arbash-meinel.com-20070626141056-zr6wslndfw8tkg5d
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Tue 2007-06-26 20:10:00 +0100
    message:
      (Adeodato Simó) fix bug #120591 by using exact encoding for merge directives.
    ------------------------------------------------------------
    revno: 2552.2.1
    revision-id: john at arbash-meinel.com-20070626141056-zr6wslndfw8tkg5d
    parent: pqm at pqm.ubuntu.com-20070626061722-8m49gdqd8cb8zc0c
    parent: dato at net.com.org.es-20070617161104-8mqczaz3oobfg0xy
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: jam-integration
    timestamp: Tue 2007-06-26 09:10:56 -0500
    message:
      (Adeodato Simó) fix bug #120591 by using exact encoding for merge directives.
    ------------------------------------------------------------
    revno: 2530.2.1
    revision-id: dato at net.com.org.es-20070617161104-8mqczaz3oobfg0xy
    parent: pqm at pqm.ubuntu.com-20070615082222-98j9j9nbl6p2dx0m
    committer: Adeodato Simó <dato at net.com.org.es>
    branch nick: bzr.merge_directive_exact_encoding
    timestamp: Sun 2007-06-17 17:11:04 +0100
    message:
      Add encoding_type = 'exact' to cmd_merge_directive. (LP #120591)
-------------- next part --------------
=== added file 'bzrlib/api.py'
--- a/bzrlib/api.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/api.py	2007-06-26 08:52:20 +0000
@@ -0,0 +1,82 @@
+# Copyright (C) 2007 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# 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
+
+"""Library API versioning support.
+
+Added in bzrlib 0.18 this allows export of compatibility information about
+bzrlib. Please see doc/developers/api-versioning.txt for design details and
+examples.
+"""
+
+import bzrlib
+from bzrlib.lazy_import import lazy_import
+lazy_import(globals(), """
+from bzrlib.errors import IncompatibleAPI
+""")
+
+
+def get_current_api_version(object_with_api):
+    """Return the API version tuple for object_with_api.
+
+    :param object_with_api: An object to look for an API version on. If the
+        object has a api_current_version attribute, that is used. Otherwise if
+        there is a version_info attribute, its first three elements are used.
+        Finally if there was no version_info attribute, the current api version
+        of bzrlib itself is used.
+
+    Added in bzrlib 0.18.
+    """
+    try:
+        return object_with_api.api_current_version
+    except AttributeError:
+        try:
+            return object_with_api.version_info[0:3]
+        except AttributeError:
+            return get_current_api_version(bzrlib)
+
+
+def get_minimum_api_version(object_with_api):
+    """Return the minimum API version supported by object_with_api.
+
+    :param object_with_api: An object to look for an API version on. If the
+        object has a api_minimum_version attribute, that is used. Otherwise the
+        minimum api version of bzrlib itself is used.
+
+    Added in bzrlib 0.18.
+    """
+    try:
+        return object_with_api.api_minimum_version
+    except AttributeError:
+        return get_minimum_api_version(bzrlib)
+
+
+def require_api(object_with_api, wanted_api):
+    """Check if object_with_api supports the api version wanted_api.
+
+    :param object_with_api: An object which exports an API minimum and current
+        version. See get_minimum_api_version and get_current_api_version for
+        details.
+    :param wanted_api: The API version for which support is required.
+    :return None:
+    :raises IncompatibleAPI: When the wanted_api is not supported by
+        object_with_api.
+
+    Added in bzrlib 0.18.
+    """
+    current = get_current_api_version(object_with_api)
+    minimum = get_minimum_api_version(object_with_api)
+    if wanted_api < minimum or wanted_api > current:
+        raise IncompatibleAPI(object_with_api, wanted_api, minimum, current)

=== added file 'doc/developers/api-versioning.txt'
--- a/doc/developers/api-versioning.txt	1970-01-01 00:00:00 +0000
+++ b/doc/developers/api-versioning.txt	2007-06-26 08:27:24 +0000
@@ -0,0 +1,130 @@
+==============
+API Versioning
+==============
+
+Status
+======
+
+:Date: 2007-06-26
+
+bzrlib has a rich API which is used both internally, and externally by
+plugins and scripts. To allow the API to change, specifically to allow
+support for features and methods to be removed, without causing hard to
+diagnose bugs in the clients of the API, bzrlib provides explicit API
+compatibility data, and a compact API to allow scripts and plugins to
+ascertain if the bzrlib they are using is compatible to the API they were
+written against.
+
+
+.. contents::
+
+
+Motivation
+==========
+
+To allow plugins to apply their own policy for compatibility with bzrlib,
+without requiring a new release on every library release. Plugins should
+also be able to use the API to export their own compatibility information
+for code reuse between plugins.
+
+
+Terminology
+===========
+
+An **API** is a collection of python objects/modules/packages which can be
+used by plugins and scripts. The ``bzrlib`` **API** covers all of bzrlib,
+but we can be more precise - e.g. the ``WorkingTree API``.
+An **API version** is a tuple ``(major, minor, point)``.
+
+
+API versions
+============
+
+For simplicity we treat API's as being compatible with a range of
+versions: the current release of the API, and some oldest version which is
+also compatible. While we could say that there is a set of older versions
+with which the current version is compatible, a range is easier to
+express, and easier for a human to look at and understand, and finally
+easier to manage. The oldest version with which the API for a python
+object is compatible is obtained by looking up the ``api_minimum_version``
+attribute on the python object handed to ``require_api``, and failing that
+the bzrlib ``api_minimum_version`` is returned. The current version of the
+API is obtained by looking for an ``api_current_version`` attribute, and
+if that is not found, an ``version_info`` attribute (of which the first 3
+elements are used). If no current version can be found, the bzrlib
+``version_info`` attribute is used to generate a current API version.
+This lookup sequence allows users with simple setups (and no python style
+``version_info`` tuple) to still export an API version, and for new API's
+to be managed more granularly later on with a smooth transition -
+everything starts off in lockstep with bzrlib's master version.
+
+API versions are compared lexically to answer the question 'is
+the requested version X <= the current version, and >= the minimum
+version'.
+
+Managing API versions
+=====================
+
+The minimum API versions should be adjusted to the **oldest** API version
+with which client code of the API will successfully run. It should not be
+changed simply because of adding things in a compatible manner, or
+deprecating features, but rather when errors will occur if client code is
+not updated.  Versions for API's from ``bzrlib`` are given the version
+numbers that ``bzrlib`` has had for consistency. Plugins should also take
+this approach and use the version numbering scheme the plugin used.
+
+Exported API's
+==============
+
+Currently we export a single API - the ``bzrlib API`` - and no finer
+grained APIs. The API versioning support was introduced in bzrlib 0.18.
+For plugins or tools that want to dynamically check for the presence of
+the API versioning API, you should compare ``bzrlib.version_info[0:3]``
+with ``(0, 18, 0)``.
+
++------------+---------------+
+| API        | Covers        | 
++============+===============+ 
+| bzrlib     | All of bzrlib |
++------------+---------------+
+
+Use Cases
+=========
+
+Some examples of using the API.
+
+Requiring bzrlib 0.18 in a plugin
+---------------------------------
+
+In the plugins __init__.py::
+
+  import bzrlib
+  from bzrlib.api import require_api
+  from bzrlib.errors import IncompatibleAPI
+  try:
+    require_api(bzrlib, (0, 18, 0))
+  except IncompatibleAPI:
+    raise ImportError("A bzrlib compatible with 0.18 is required.")
+
+Exporting an API from a plugin
+------------------------------
+
+In the plugin ``foo`` exporting the API (in __init__.py)::
+
+  version_info = (0, 0, 1, 'beta', 1)
+  api_version = (0, 0, 1)
+
+In a plugin depending on that plugin (in __init__.py)::
+
+  import bzrlib.plugins.foo
+  from bzrlib.api import require_api
+  from bzrlib.errors import IncompatibleAPI
+  try:
+    require_api(bzrlib.plugins.foo, (0, 0, 1))
+  except IncompatibleAPI:
+    raise ImportError("A bzrlib compatible with 0.0.1 is required.")
+
+
+..
+   vim: ft=rst tw=74 ai
+

=== modified file 'NEWS'
--- a/NEWS	2007-06-26 13:05:11 +0000
+++ b/NEWS	2007-06-27 19:13:50 +0000
@@ -46,6 +46,10 @@
     * The lsprof filename note is emitted via trace.note(), not standard
       output.  (Aaron Bentley)
 
+    * ``bzrlib`` now exports explicit API compatibility information to assist
+      library users and plugins. See the ``bzrlib.api`` module for details.
+      (Robert Collins)
+
   INTERNALS:
 
     * New SMTPConnection class to unify email handling.  (Adeodato Sim??)
@@ -61,7 +65,6 @@
       interface is now self.run_bzr.  The command to run can be passed as
       either a list of parameters, a string containing the command line, or
       (deprecated) varargs parameters.  (Martin Pool)
- 
 
   BUGFIXES:
 

=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2007-06-19 00:26:28 +0000
+++ b/bzrlib/__init__.py	2007-06-26 08:27:24 +0000
@@ -37,6 +37,9 @@
 
 version_info = (0, 18, 0, 'dev', 0)
 
+# API compatibility version: bzrlib is currently API compatible with 0.18.
+api_minimum_version = (0, 18, 0)
+
 if version_info[3] == 'final':
     version_string = '%d.%d.%d' % version_info[:3]
 else:

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-06-25 17:46:47 +0000
+++ b/bzrlib/builtins.py	2007-06-26 14:10:56 +0000
@@ -3536,6 +3536,8 @@
             help='Message to use when committing this merge')
         ]
 
+    encoding_type = 'exact'
+
     def run(self, submit_branch=None, public_branch=None, patch_type='bundle',
             sign=False, revision=None, mail_to=None, message=None):
         from bzrlib.revision import ensure_null, NULL_REVISION

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2007-06-25 13:17:32 +0000
+++ b/bzrlib/errors.py	2007-06-26 08:52:20 +0000
@@ -186,6 +186,18 @@
         self.class_name = class_name
 
 
+class IncompatibleAPI(BzrError):
+
+    _fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
+        'It supports versions "%(minimum)s" to "%(current)s".'
+
+    def __init__(self, api, wanted, minimum, current):
+        self.api = api
+        self.wanted = wanted
+        self.minimum = minimum
+        self.current = current
+
+
 class InvalidEntryName(BzrError):
     
     _fmt = "Invalid entry name: %(name)s"

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2007-06-21 03:29:39 +0000
+++ b/bzrlib/knit.py	2007-06-27 07:37:53 +0000
@@ -1185,14 +1185,26 @@
                 # or a different failure, and raise. RBC 20060407
                 continue
 
-            parents = []
-            for value in rec[4:-1]:
-                if value[0] == '.':
-                    # uncompressed reference
-                    parent_id = value[1:]
-                else:
-                    parent_id = history[int(value)]
-                parents.append(parent_id)
+            try:
+                parents = []
+                for value in rec[4:-1]:
+                    if value[0] == '.':
+                        # uncompressed reference
+                        parent_id = value[1:]
+                    else:
+                        parent_id = history[int(value)]
+                    parents.append(parent_id)
+            except (IndexError, ValueError), e:
+                # The parent could not be decoded to get its parent row. This
+                # at a minimum will cause this row to have wrong parents, or
+                # even to apply a delta to the wrong base and decode
+                # incorrectly. its therefore not usable, and because we have
+                # encountered a situation where a new knit index had this
+                # corrupt we can't asssume that no other rows referring to the
+                # index of this record actually mean the subsequent uncorrupt
+                # one, so we error.
+                raise errors.KnitCorrupt(self._filename,
+                    "line %r: %s" % (rec, e))
 
             version_id, options, pos, size = rec[:4]
             version_id = version_id

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-06-21 02:33:43 +0000
+++ b/bzrlib/remote.py	2007-06-27 04:33:04 +0000
@@ -110,7 +110,7 @@
         elif response == ('nobranch',):
             raise errors.NotBranchError(path=self.root_transport.base)
         else:
-            assert False, 'unexpected response code %r' % (response,)
+            raise errors.UnexpectedSmartServerResponse(response)
 
     def open_branch(self, _unsupported=False):
         assert _unsupported == False, 'unsupported flag support not implemented yet.'
@@ -367,7 +367,7 @@
         elif response[0] == 'UnlockableTransport':
             raise errors.UnlockableTransport(self.bzrdir.root_transport)
         else:
-            assert False, 'unexpected response code %s' % (response,)
+            raise errors.UnexpectedSmartServerResponse(response)
 
     def lock_write(self, token=None):
         if not self._lock_mode:
@@ -416,7 +416,7 @@
         elif response[0] == 'TokenMismatch':
             raise errors.TokenMismatch(token, '(remote token)')
         else:
-            assert False, 'unexpected response code %s' % (response,)
+            raise errors.UnexpectedSmartServerResponse(response)
 
     def unlock(self):
         self._lock_count -= 1
@@ -849,7 +849,7 @@
         elif response[0] == 'ReadOnlyError':
             raise errors.ReadOnlyError(self)
         else:
-            assert False, 'unexpected response code %r' % (response,)
+            raise errors.UnexpectedSmartServerResponse(response)
             
     def lock_write(self, token=None):
         if not self._lock_mode:
@@ -899,7 +899,7 @@
             raise errors.TokenMismatch(
                 str((branch_token, repo_token)), '(remote tokens)')
         else:
-            assert False, 'unexpected response code %s' % (response,)
+            raise errors.UnexpectedSmartServerResponse(response)
 
     def unlock(self):
         self._lock_count -= 1

=== modified file 'bzrlib/tests/blackbox/test_merge.py'
--- a/bzrlib/tests/blackbox/test_merge.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py	2007-06-27 19:13:50 +0000
@@ -106,22 +106,22 @@
         print >> file('sub/c.txt', 'wb'), "hello"
         self.run_bzr('init')
         self.run_bzr('add')
-        self.run_bzr('commit -m added_a')
+        self.run_bzr(['commit', '-m', 'added a'])
         self.run_bzr('branch . ../b')
         print >> file('sub/a.txt', 'ab'), "there"
         print >> file('b.txt', 'ab'), "there"
         print >> file('sub/c.txt', 'ab'), "there"
-        self.run_bzr('commit -m Added_there')
+        self.run_bzr(['commit', '-m', 'Added there'])
         os.unlink('sub/a.txt')
         os.unlink('sub/c.txt')
         os.rmdir('sub')
         os.unlink('b.txt')
-        self.run_bzr('commit -m Removed_a.txt')
+        self.run_bzr(['commit', '-m', 'Removed a.txt'])
         os.chdir('../b')
         print >> file('sub/a.txt', 'ab'), "something"
         print >> file('b.txt', 'ab'), "something"
         print >> file('sub/c.txt', 'ab'), "something"
-        self.run_bzr('commit -m Modified_a.txt')
+        self.run_bzr(['commit', '-m', 'Modified a.txt'])
         self.run_bzr('merge ../a/', retcode=1)
         self.assert_(os.path.exists('sub/a.txt.THIS'))
         self.assert_(os.path.exists('sub/a.txt.BASE'))

=== modified file 'bzrlib/tests/blackbox/test_merge_directive.py'
--- a/bzrlib/tests/blackbox/test_merge_directive.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_merge_directive.py	2007-06-27 19:13:50 +0000
@@ -231,3 +231,8 @@
         os.chdir('foo')
         self.run_bzr_error(('No revisions to bundle.', ),
                             'merge-directive ../bar')
+
+    def test_encoding_exact(self):
+        tree1, tree2 = self.prepare_merge_directive()
+        tree1.commit(u'messag\xe9')
+        self.run_bzr('merge-directive', '../tree2') # no exception raised

=== modified file 'bzrlib/tests/blackbox/test_outside_wt.py'
--- a/bzrlib/tests/blackbox/test_outside_wt.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_outside_wt.py	2007-06-27 19:13:50 +0000
@@ -44,8 +44,10 @@
     def test_diff_ouside_tree(self):
         os.chdir(tempfile.mkdtemp())
         self.run_bzr('init branch1')
-        self.run_bzr('commit -m nothing --unchanged branch1')
-        self.run_bzr('commit -m nothing --unchanged branch1')
+        self.run_bzr(['commit', '-m', 'nothing',
+                               '--unchanged', 'branch1'])
+        self.run_bzr(['commit', '-m', 'nothing',
+                               '--unchanged', 'branch1'])
         # -r X..Y
         out, err = self.run_bzr('diff -r revno:2:branch2..revno:1', retcode=3)
         self.assertEquals('', out)

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2007-06-27 19:13:50 +0000
@@ -182,8 +182,8 @@
         old_root = TestCaseWithMemoryTransport.TEST_ROOT
         try:
             TestCaseWithMemoryTransport.TEST_ROOT = None
-            out, err = self.run_bzr(['selftest', '--benchmark',
-                                     'workingtree_implementations'])
+            out, err = self.run_bzr('selftest --benchmark'
+                                    ' workingtree_implementations')
         finally:
             TestCaseWithMemoryTransport.TEST_ROOT = old_root
         self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')

=== modified file 'bzrlib/tests/blackbox/test_too_much.py'
--- a/bzrlib/tests/blackbox/test_too_much.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_too_much.py	2007-06-27 19:13:50 +0000
@@ -205,7 +205,7 @@
         
     def test_unknown_command(self):
         """Handling of unknown command."""
-        out, err = self.run_bzr(['fluffy-badger'], retcode=3)
+        out, err = self.run_bzr('fluffy-badger', retcode=3)
         self.assertEquals(out, '')
         err.index('unknown command')
 

=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- a/bzrlib/tests/blackbox/test_upgrade.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_upgrade.py	2007-06-27 19:13:50 +0000
@@ -80,7 +80,7 @@
         # date
         (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
         self.assertEqual("This is a checkout. The branch (%s) needs to be "
-                         "upgraded separately.\n" 
+                         "upgraded separately.\n"
                          % get_transport(self.get_url('current_format_branch')).base,
                          out)
         self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "

=== modified file 'bzrlib/tests/test_api.py'
--- a/bzrlib/tests/test_api.py	2006-10-11 23:08:27 +0000
+++ b/bzrlib/tests/test_api.py	2007-06-26 08:52:20 +0000
@@ -21,10 +21,9 @@
 relevant test modules.
 """
 
-import os
-import sys
-
 import bzrlib
+import bzrlib.api
+from bzrlib.errors import IncompatibleAPI
 from bzrlib.tests import TestCase
 
 class APITests(TestCase):
@@ -35,3 +34,85 @@
         self.assert_(isinstance(bzrlib.version_string, str))
         self.assert_(isinstance(bzrlib.version_info, tuple))
         self.assertEqual(len(bzrlib.version_info), 5)
+
+
+class TrivialObject(object):
+    """This class allows assignment to any attribute."""
+
+
+class TestAPIVersioning(TestCase):
+
+    def test_get_minimum_api_version_reads_api_minimum_version(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (0, 1, 2)
+        self.assertEqual((0, 1, 2),
+            bzrlib.api.get_minimum_api_version(an_object))
+
+    def test_get_minimum_api_version_fallsback_to_bzr_minimum_version(self):
+        an_object = TrivialObject()
+        self.assertEqual(bzrlib.api_minimum_version,
+            bzrlib.api.get_minimum_api_version(an_object))
+
+    def test_get_current_api_version_reads_api_current_version(self):
+        an_object = TrivialObject()
+        an_object.api_current_version = (3, 2, 1)
+        an_object.version_info = (1, 2, 3, "final", 0)
+        self.assertEqual((3, 2, 1),
+            bzrlib.api.get_current_api_version(an_object))
+
+    def test_get_current_api_version_fallsback_to_version_info(self):
+        an_object = TrivialObject()
+        an_object.version_info = (1, 2, 3, "final", 0)
+        self.assertEqual((1, 2, 3),
+            bzrlib.api.get_current_api_version(an_object))
+
+    def test_get_current_api_version_fallsback_to_bzrlib_version_info(self):
+        an_object = TrivialObject()
+        self.assertEqual(bzrlib.version_info[0:3],
+            bzrlib.api.get_current_api_version(an_object))
+
+    def test_require_api_wanted_is_minimum_is_ok(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (1, 2, 3)
+        an_object.api_current_version = (4, 5, 6)
+        bzrlib.api.require_api(an_object, (1, 2, 3))
+
+    def test_require_api_wanted_is_current_is_ok(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (1, 2, 3)
+        an_object.api_current_version = (4, 5, 6)
+        bzrlib.api.require_api(an_object, (4, 5, 6))
+
+    def test_require_api_wanted_is_above_minimum_is_ok(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (1, 2, 3)
+        an_object.api_current_version = (4, 5, 6)
+        bzrlib.api.require_api(an_object, (1, 2, 4))
+
+    def test_require_api_wanted_is_below_current_is_ok(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (1, 2, 3)
+        an_object.api_current_version = (4, 5, 6)
+        bzrlib.api.require_api(an_object, (4, 5, 5))
+
+    def test_require_api_wanted_is_below_minimum_raises(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (1, 2, 3)
+        an_object.api_current_version = (4, 5, 6)
+        err = self.assertRaises(IncompatibleAPI,
+            bzrlib.api.require_api, an_object, (1, 2, 2))
+        self.assertEqual(err.api, an_object)
+        self.assertEqual(err.wanted, (1, 2, 2))
+        self.assertEqual(err.minimum, (1, 2, 3))
+        self.assertEqual(err.current, (4, 5, 6))
+
+    def test_require_api_wanted_is_above_current_raises(self):
+        an_object = TrivialObject()
+        an_object.api_minimum_version = (1, 2, 3)
+        an_object.api_current_version = (4, 5, 6)
+        err = self.assertRaises(IncompatibleAPI,
+            bzrlib.api.require_api, an_object, (4, 5, 7))
+        self.assertEqual(err.api, an_object)
+        self.assertEqual(err.wanted, (4, 5, 7))
+        self.assertEqual(err.minimum, (1, 2, 3))
+        self.assertEqual(err.current, (4, 5, 6))

=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py	2007-04-26 09:07:38 +0000
+++ b/bzrlib/tests/test_errors.py	2007-06-26 08:52:20 +0000
@@ -46,6 +46,13 @@
         self.assertEqualDiff('The prefix foo is in the help search path twice.',
             str(error))
 
+    def test_incompatibleAPI(self):
+        error = errors.IncompatibleAPI("module", (1, 2, 3), (4, 5, 6), (7, 8, 9))
+        self.assertEqualDiff(
+            'The API for "module" is not compatible with "(1, 2, 3)". '
+            'It supports versions "(4, 5, 6)" to "(7, 8, 9)".',
+            str(error))
+
     def test_inventory_modified(self):
         error = errors.InventoryModified("a tree to be repred")
         self.assertEqualDiff("The current inventory for the tree 'a tree to "

=== modified file 'bzrlib/transport/http/__init__.py'
--- a/bzrlib/transport/http/__init__.py	2007-05-06 06:59:57 +0000
+++ b/bzrlib/transport/http/__init__.py	2007-06-27 04:33:04 +0000
@@ -98,7 +98,6 @@
                 raise errors.InvalidHttpResponse(url,
                     'Opening header line did not start with HTTP: %s'
                     % (first_line,))
-                assert False, 'Opening header line was not HTTP'
             else:
                 break # We are done parsing
         first_header = False

=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py	2007-04-30 06:42:24 +0000
+++ b/bzrlib/transport/remote.py	2007-06-27 04:33:04 +0000
@@ -143,7 +143,7 @@
             return False
         else:
             self._translate_error(resp)
-        assert False, 'weird response %r' % (resp,)
+        raise errors.UnexpectedSmartServerResponse(resp)
 
     def get_smart_client(self):
         return self._medium

=== modified file 'doc/developers/index.txt'
--- a/doc/developers/index.txt	2007-06-21 03:06:32 +0000
+++ b/doc/developers/index.txt	2007-06-26 06:57:20 +0000
@@ -27,6 +27,10 @@
 Specifications
 ==============
 
+* `API versioning <api-versioning.htm>`_
+
+  bzrlib API versioning.
+
 * `Bundles <bundles.htm>`_
 
   All about bzr bundles.



More information about the bazaar-commits mailing list