Rev 2368: Remove bzrlib 0.8 compatability where it was making the code unclear or messy. (Robert Collins) in file:///home/robertc/source/baz/cleanup-0.8/

Robert Collins robertc at robertcollins.net
Wed Mar 21 01:34:58 GMT 2007


At file:///home/robertc/source/baz/cleanup-0.8/

------------------------------------------------------------
revno: 2368
revision-id: robertc at robertcollins.net-20070321013441-x99h538fq62wwt46
parent: pqm at pqm.ubuntu.com-20070320223938-97fdc295a1111e36
committer: Robert Collins <robertc at robertcollins.net>
branch nick: cleanup-0.8
timestamp: Wed 2007-03-21 12:34:41 +1100
message:
  Remove bzrlib 0.8 compatability where it was making the code unclear or messy. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/externalcommand.py      externalcommand.py-20050901092254-b4fc642a55bb815b
  bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/weave.py                knit.py-20050627021749-759c29984154256b
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS	2007-03-20 22:39:38 +0000
+++ b/NEWS	2007-03-21 01:34:41 +0000
@@ -1,5 +1,10 @@
 IN DEVELOPMENT
 
+  INTERNALS:
+
+    * bzrlib API compatability with 0.8 has been dropped, cleaning up some
+      code paths. (Robert Collins)
+
   NOTES WHEN UPGRADING:
         
     * Release 0.15rc2 of bzr changes the ``bzr init-repo`` command to

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-03-13 01:00:34 +0000
+++ b/bzrlib/branch.py	2007-03-21 01:34:41 +0000
@@ -543,57 +543,12 @@
             raise InvalidRevisionNumber(revno)
 
     @needs_read_lock
-    def clone(self, *args, **kwargs):
+    def clone(self, to_bzrdir, revision_id=None):
         """Clone this branch into to_bzrdir preserving all semantic values.
         
         revision_id: if not None, the revision history in the new branch will
                      be truncated to end with revision_id.
         """
-        # for API compatibility, until 0.8 releases we provide the old api:
-        # def clone(self, to_location, revision=None, basis_branch=None, to_branch_format=None):
-        # after 0.8 releases, the *args and **kwargs should be changed:
-        # def clone(self, to_bzrdir, revision_id=None):
-        if (kwargs.get('to_location', None) or
-            kwargs.get('revision', None) or
-            kwargs.get('basis_branch', None) or
-            (len(args) and isinstance(args[0], basestring))):
-            # backwards compatibility api:
-            warn("Branch.clone() has been deprecated for BzrDir.clone() from"
-                 " bzrlib 0.8.", DeprecationWarning, stacklevel=3)
-            # get basis_branch
-            if len(args) > 2:
-                basis_branch = args[2]
-            else:
-                basis_branch = kwargs.get('basis_branch', None)
-            if basis_branch:
-                basis = basis_branch.bzrdir
-            else:
-                basis = None
-            # get revision
-            if len(args) > 1:
-                revision_id = args[1]
-            else:
-                revision_id = kwargs.get('revision', None)
-            # get location
-            if len(args):
-                url = args[0]
-            else:
-                # no default to raise if not provided.
-                url = kwargs.get('to_location')
-            return self.bzrdir.clone(url,
-                                     revision_id=revision_id,
-                                     basis=basis).open_branch()
-        # new cleaner api.
-        # generate args by hand 
-        if len(args) > 1:
-            revision_id = args[1]
-        else:
-            revision_id = kwargs.get('revision_id', None)
-        if len(args):
-            to_bzrdir = args[0]
-        else:
-            # no default to raise if not provided.
-            to_bzrdir = kwargs.get('to_bzrdir')
         result = self._format.initialize(to_bzrdir)
         self.copy_content_into(result, revision_id=revision_id)
         return  result
@@ -1183,25 +1138,12 @@
     it's writable, and can be accessed via the normal filesystem API.
     """
     
-    def __init__(self, transport=DEPRECATED_PARAMETER, init=DEPRECATED_PARAMETER,
-                 relax_version_check=DEPRECATED_PARAMETER, _format=None,
+    def __init__(self, _format=None,
                  _control_files=None, a_bzrdir=None, _repository=None):
-        """Create new branch object at a particular location.
-
-        transport -- A Transport object, defining how to access files.
-        
-        init -- If True, create new control files in a previously
-             unversioned directory.  If False, the branch must already
-             be versioned.
-
-        relax_version_check -- If true, the usual check for the branch
-            version is not applied.  This is intended only for
-            upgrade/recovery type use; it's not guaranteed that
-            all operations will work on old format branches.
-        """
+        """Create new branch object at a particular location."""
         Branch.__init__(self)
         if a_bzrdir is None:
-            self.bzrdir = bzrdir.BzrDir.open(transport.base)
+            raise ValueError('a_bzrdir must be supplied')
         else:
             self.bzrdir = a_bzrdir
         # self._transport used to point to the directory containing the
@@ -1213,32 +1155,6 @@
             raise ValueError('BzrBranch _control_files is None')
         self.control_files = _control_files
         self._transport = _control_files._transport
-        if deprecated_passed(init):
-            warn("BzrBranch.__init__(..., init=XXX): The init parameter is "
-                 "deprecated as of bzr 0.8. Please use Branch.create().",
-                 DeprecationWarning,
-                 stacklevel=2)
-            if init:
-                # this is slower than before deprecation, oh well never mind.
-                # -> its deprecated.
-                self._initialize(transport.base)
-        self._check_format(_format)
-        if deprecated_passed(relax_version_check):
-            warn("BzrBranch.__init__(..., relax_version_check=XXX_: The "
-                 "relax_version_check parameter is deprecated as of bzr 0.8. "
-                 "Please use BzrDir.open_downlevel, or a BzrBranchFormat's "
-                 "open() method.",
-                 DeprecationWarning,
-                 stacklevel=2)
-            if (not relax_version_check
-                and not self._format.is_supported()):
-                raise errors.UnsupportedFormatError(format=fmt)
-        if deprecated_passed(transport):
-            warn("BzrBranch.__init__(transport=XXX...): The transport "
-                 "parameter is deprecated as of bzr 0.8. "
-                 "Please use Branch.open, or bzrdir.open_branch().",
-                 DeprecationWarning,
-                 stacklevel=2)
         self.repository = _repository
 
     def __str__(self):
@@ -1279,22 +1195,6 @@
         """See Branch.abspath."""
         return self.control_files._transport.abspath(name)
 
-    def _check_format(self, format):
-        """Identify the branch format if needed.
-
-        The format is stored as a reference to the format object in
-        self._format for code that needs to check it later.
-
-        The format parameter is either None or the branch format class
-        used to open this branch.
-
-        FIXME: DELETE THIS METHOD when pre 0.8 support is removed.
-        """
-        if format is None:
-            format = BranchFormat.find_format(self.bzrdir)
-        self._format = format
-        mutter("got branch format %s", self._format)
-
     @needs_read_lock
     def get_root_id(self):
         """See Branch.get_root_id."""

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2007-02-28 18:39:16 +0000
+++ b/bzrlib/commands.py	2007-03-21 01:34:41 +0000
@@ -271,14 +271,6 @@
         # bogus. So set the attribute, so we can find the correct encoding later.
         self.outf.encoding = output_encoding
 
-    @deprecated_method(zero_eight)
-    def run_argv(self, argv):
-        """Parse command line and run.
-        
-        See run_argv_aliases for the 0.8 and beyond api.
-        """
-        return self.run_argv_aliases(argv)
-
     def run_argv_aliases(self, argv, alias_argv=None):
         """Parse the command line and run with extra aliases in alias_argv."""
         if argv is None:
@@ -596,12 +588,8 @@
     # 'command not found' error later.
 
     cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
-    if not getattr(cmd_obj.run_argv, 'is_deprecated', False):
-        run = cmd_obj.run_argv
-        run_argv = [argv]
-    else:
-        run = cmd_obj.run_argv_aliases
-        run_argv = [argv, alias_argv]
+    run = cmd_obj.run_argv_aliases
+    run_argv = [argv, alias_argv]
 
     try:
         if opt_lsprof:

=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2007-03-06 10:51:27 +0000
+++ b/bzrlib/commit.py	2007-03-21 01:34:41 +0000
@@ -159,7 +159,7 @@
             self.config = None
         
     def commit(self,
-               branch=DEPRECATED_PARAMETER, message=None,
+               message=None,
                timestamp=None,
                timezone=None,
                committer=None,
@@ -177,9 +177,6 @@
                recursive='down'):
         """Commit working copy as a new revision.
 
-        branch -- the deprecated branch to commit to. New callers should pass in 
-                  working_tree instead
-
         message -- the commit message (it or message_callback is required)
 
         timestamp -- if not None, seconds-since-epoch for a
@@ -206,14 +203,8 @@
         """
         mutter('preparing to commit')
 
-        if deprecated_passed(branch):
-            symbol_versioning.warn("Commit.commit (branch, ...): The branch parameter is "
-                 "deprecated as of bzr 0.8. Please use working_tree= instead.",
-                 DeprecationWarning, stacklevel=2)
-            self.branch = branch
-            self.work_tree = self.branch.bzrdir.open_workingtree()
-        elif working_tree is None:
-            raise BzrError("One of branch and working_tree must be passed into commit().")
+        if working_tree is None:
+            raise BzrError("working_tree must be passed into commit().")
         else:
             self.work_tree = working_tree
             self.branch = self.work_tree.branch

=== modified file 'bzrlib/externalcommand.py'
--- a/bzrlib/externalcommand.py	2006-10-11 23:08:27 +0000
+++ b/bzrlib/externalcommand.py	2007-03-21 01:34:41 +0000
@@ -56,7 +56,7 @@
     def run(self, *args, **kwargs):
         raise NotImplementedError('should not be called on %r' % self)
 
-    def run_argv(self, argv, alias_argv=None):
+    def run_argv_aliases(self, argv, alias_argv=None):
         return os.spawnv(os.P_WAIT, self.path, [self.path] + argv)
 
     def help(self):

=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2007-03-09 00:52:52 +0000
+++ b/bzrlib/merge.py	2007-03-21 01:34:41 +0000
@@ -1013,11 +1013,8 @@
                      branch.get_revision_tree(base_revision))'
         """
     if this_tree is None:
-        warnings.warn("bzrlib.merge.merge_inner requires a this_tree parameter as of "
-             "bzrlib version 0.8.",
-             DeprecationWarning,
-             stacklevel=2)
-        this_tree = this_branch.bzrdir.open_workingtree()
+        raise BzrError("bzrlib.merge.merge_inner requires a this_tree "
+            "parameter as of bzrlib version 0.8.")
     merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree,
                     pb=pb, change_reporter=change_reporter)
     merger.backup_files = backup_files

=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2007-03-10 04:37:39 +0000
+++ b/bzrlib/mutabletree.py	2007-03-21 01:34:41 +0000
@@ -153,9 +153,7 @@
         if not 'branch-nick' in revprops:
             revprops['branch-nick'] = self.branch.nick
         # args for wt.commit start at message from the Commit.commit method,
-        # but with branch a kwarg now, passing in args as is results in the
-        #message being used for the branch
-        args = (DEPRECATED_PARAMETER, message, ) + args
+        args = (message, ) + args
         committed_id = commit.Commit().commit(working_tree=self,
             revprops=revprops, *args, **kwargs)
         return committed_id

=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py	2007-01-17 15:37:08 +0000
+++ b/bzrlib/weave.py	2007-03-21 01:34:41 +0000
@@ -641,20 +641,6 @@
         """
         return len(other_parents.difference(my_parents)) == 0
 
-    def annotate(self, version_id):
-        if isinstance(version_id, int):
-            warnings.warn('Weave.annotate(int) is deprecated. Please use version names'
-                 ' in all circumstances as of 0.8',
-                 DeprecationWarning,
-                 stacklevel=2
-                 )
-            result = []
-            for origin, lineno, text in self._extract([version_id]):
-                result.append((origin, text))
-            return result
-        else:
-            return super(Weave, self).annotate(version_id)
-    
     def annotate_iter(self, version_id):
         """Yield list of (version-id, line) pairs for the specified version.
 

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-03-10 20:35:58 +0000
+++ b/bzrlib/workingtree.py	2007-03-21 01:34:41 +0000
@@ -208,41 +208,20 @@
                  _internal=False,
                  _format=None,
                  _bzrdir=None):
-        """Construct a WorkingTree for basedir.
+        """Construct a WorkingTree instance. This is not a public API.
 
-        If the branch is not supplied, it is opened automatically.
-        If the branch is supplied, it must be the branch for this basedir.
-        (branch.base is not cross checked, because for remote branches that
-        would be meaningless).
+        :param branch: A branch to override probing for the branch.
         """
         self._format = _format
         self.bzrdir = _bzrdir
         if not _internal:
-            # not created via open etc.
-            warnings.warn("WorkingTree() is deprecated as of bzr version 0.8. "
-                 "Please use bzrdir.open_workingtree or WorkingTree.open().",
-                 DeprecationWarning,
-                 stacklevel=2)
-            wt = WorkingTree.open(basedir)
-            self._branch = wt.branch
-            self.basedir = wt.basedir
-            self._control_files = wt._control_files
-            self._hashcache = wt._hashcache
-            self._set_inventory(wt._inventory, dirty=False)
-            self._format = wt._format
-            self.bzrdir = wt.bzrdir
+            raise errors.BzrError("Please use bzrdir.open_workingtree or "
+                "WorkingTree.open() to obtain a WorkingTree.")
         assert isinstance(basedir, basestring), \
             "base directory %r is not a string" % basedir
         basedir = safe_unicode(basedir)
         mutter("opening working tree %r", basedir)
         if deprecated_passed(branch):
-            if not _internal:
-                warnings.warn("WorkingTree(..., branch=XXX) is deprecated"
-                     " as of bzr 0.8. Please use bzrdir.open_workingtree() or"
-                     " WorkingTree.open().",
-                     DeprecationWarning,
-                     stacklevel=2
-                     )
             self._branch = branch
         else:
             self._branch = self.bzrdir.open_branch()



More information about the bazaar-commits mailing list