[Pkg-bazaar-commits] ./bzr-upload/unstable r51: Merge new upstream.

Jelmer Vernooij jelmer at debian.org
Tue May 5 16:47:55 UTC 2009


------------------------------------------------------------
revno: 51
committer: Jelmer Vernooij <jelmer at debian.org>
branch nick: debian
timestamp: Tue 2009-05-05 18:47:47 +0200
message:
  Merge new upstream.
added:
  NEWS
modified:
  README
  __init__.py
  debian/changelog
  debian/compat
  debian/control
  tests/test_auto_upload_hook.py
  tests/test_upload.py
    ------------------------------------------------------------
    revno: 43.1.11
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Mon 2009-01-19 10:08:28 +0100
    message:
      Let's start dev for a 1.0.
      
      * __init__.py: 
      (version_info): 1.0dev
    modified:
      __init__.py
    ------------------------------------------------------------
    revno: 43.1.12
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Mon 2009-01-19 10:21:31 +0100
    message:
      (garyvdm, vila) Allows uploading from remote branch
    modified:
      README
      __init__.py
      tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.1
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: upload
        timestamp: Wed 2008-09-17 22:53:15 +0200
        message:
           Don't require a working tree.
        modified:
          __init__.py
        ------------------------------------------------------------
        revno: 43.5.2
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Sun 2009-01-04 01:48:19 +0200
        message:
          Add documentation on adding hook to remote server.
        modified:
          README
        ------------------------------------------------------------
        revno: 43.5.3
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Sun 2009-01-04 10:38:06 +0200
        message:
          Add test for upload from remote. Not working.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.4
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Sun 2009-01-04 12:53:38 +0200
        message:
          Use cmd_push insted of self.run_bzr to avoid getinng asked for a password.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.5
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Tue 2009-01-06 15:03:42 +0200
        message:
          Push using lower level api to avoid output.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.6
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Tue 2009-01-06 15:46:47 +0200
        message:
          Correctly test auto when testing remote branches.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.7
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Sat 2009-01-10 11:03:59 +0200
        message:
          Clean up white space.
        modified:
          __init__.py
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.8
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Sat 2009-01-10 11:25:39 +0200
        message:
          Improve working in README.
        modified:
          README
        ------------------------------------------------------------
        revno: 43.5.9
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Mon 2009-01-12 01:15:04 +0200
        message:
          Add a check to make sure we are not uploading to an existing wt.
        modified:
          __init__.py
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.10
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Mon 2009-01-12 01:30:21 +0200
        message:
          Remove unnessary import.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.11
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Mon 2009-01-12 01:55:07 +0200
        message:
          Revert revision 57: Go back to using the cmd_object.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.12
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: nowt
        timestamp: Mon 2009-01-12 02:57:25 +0200
        message:
          In the auto tests, do a upload before checking that auto is not set to handle the from Remote cases correctly. Add some blank line for clarity.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.13
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sat 2009-01-17 18:09:59 +0100
        message:
          Fix PEP8 violations.
          
          * tests/test_upload.py:
          (TestUploadFromRemote): Space only lnes.
          (TestFullUploadFromRemote, TestIncrementalUploadFromRemote): Lines
          too long, 2 empty lines between classes.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.14
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 00:20:11 +0100
        message:
          Fix bzrlib.builtins import.
          
          * tests/test_upload.py:
          (TestUploadFromRemote.do_full_upload,
          TestUploadFromRemote.do_incremental_upload): Fix import.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.15
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 00:23:24 +0100
        message:
          Just use run_bzr to push.
          
          * tests/test_upload.py:
          (TestUploadFromRemote.do_full_upload,
          TestUploadFromRemote.do_incremental_upload): Since we don't intend
          to debug the pushes, we can use run_bzr.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.16
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 17:40:11 +0100
        message:
          Start refactoring for remote branch tests.
          
          * tests/test_upload.py:
          (UploadUtilsMixin, TestUploadMixin): Splitted for better re-use.
          (UploadUtilsMixin.make_branch_and_working_tree): Renamed from
          make_local_branch.
          (UploadUtilsMixin.upload_dir, UploadUtilsMixin.branch_dir): Delete
          leading '/' use osutils.pathjoin instead, fix all uses.
          (TestUploadMixin.test_no_upload_remote_wt): Deleted, not related
          to full/incremental.
          (TestUploadFromRemoteBranch): Start tests specific to remote
          branch uploads.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.17
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 18:47:42 +0100
        message:
          New remote branch test.
          
          * tests/test_upload.py:
          (TestUploadFromRemoteBranch.make_remote_branch_without_working_tree):
          Extracted from test_no_upload_to_remote_working_tree.
          (TestUploadFromRemoteBranch.test_upload_without_working_tree): New
          test.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.18
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 18:53:11 +0100
        message:
          Give a less controversial example for uploading from remote branch.
        modified:
          README
        ------------------------------------------------------------
        revno: 43.5.19
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 19:11:27 +0100
        message:
          Bzr has facilities for exceptions, let's use them.
          
          * __init__.py:
          (CannotUploadToWorkingTreeError): Use bzr exception facilities.
        modified:
          __init__.py
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.20
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 19:32:32 +0100
        message:
          Testing against remote branch and testing full/incremental are different.
          
          * tests/test_upload.py:
          (load_tests): Oops, add forgotten
          TestUploadFromRemoteBranch. Delete TestFullUploadFromRemote and
          TestIncrementalUploadFromRemote.
          (TestUploadFromRemote, TestFullUploadFromRemote,
          TestIncrementalUploadFromRemote): Deleted.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.21
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Sun 2009-01-18 19:41:23 +0100
        message:
          Revert test while keeping Gary's refactoring.
          
          * tests/test_upload.py:
          (TestUploadMixin.test_upload_auto): Revert to original semantic.
        modified:
          tests/test_upload.py
        ------------------------------------------------------------
        revno: 43.5.22
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: upload-from-remote-branch
        timestamp: Sun 2009-01-18 22:57:37 +0200
        message:
          Point out how to add hook that upload on push in README.
        modified:
          README
        ------------------------------------------------------------
        revno: 43.5.23
        committer: Gary van der Merwe <garyvdm at gmail.com>
        branch nick: upload-from-remote-branch
        timestamp: Sun 2009-01-18 22:59:12 +0200
        message:
          Take issue regarding Execution bits out of README because it is nolonger true.
        modified:
          README
        ------------------------------------------------------------
        revno: 43.5.24
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: remote-branch
        timestamp: Mon 2009-01-19 09:53:32 +0100
        message:
          Tweak Gary's tweaks :)
          
          * README: 
          Additional tweak.
          
          * __init__.py: 
          Clarify which chmod bits are not handled.
        modified:
          README
          __init__.py
    ------------------------------------------------------------
    revno: 43.1.13
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Tue 2009-02-10 09:41:52 +0100
    message:
      Small tweaks including doc fix (#275538).
      
      * tests/test_upload.py:
      (TransportAdapter._test_permutations): Be more robust against
      local_test_server variants.
      
      * NEWS: 
      Add a NEWS file as in bzr core.
      
      * __init__.py:
      (cmd_upload): Be explicit about changes handled (#275538).
    added:
      NEWS
    modified:
      __init__.py
      tests/test_upload.py
    ------------------------------------------------------------
    revno: 43.1.14
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Sat 2009-02-28 16:29:05 +0100
    message:
      Fix minor 2.4 compatibility bug.
      
      * tests/test_upload.py:
      (UploadUtilsMixin.assertUpPathModeEqual): Update comment.
      
      * __init__.py:
      (CannotUploadToWorkingTreeError): Fix 2.4 compatibility
      issue (StandardError, the grand-mother class was a type not an
      object in 2.4, so we can't us super() here). Besides, BzrError
      already provides facilities that doesn't require to redefine
      __init__, keyword arguments can be used in _fmt as long as they
      are passed as keyword arguments at construction time.
    modified:
      __init__.py
      tests/test_upload.py
    ------------------------------------------------------------
    revno: 43.1.15
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Fri 2009-03-13 10:51:19 +1000
    message:
      Make the test suite pass again catchiing up bzr.dev changes.
      
      * tests/test_upload.py:
      (get_transport_scenarios, load_tests): bzr.dev deleted all test
      adpaters, catch up.
      
      * tests/test_auto_upload_hook.py:
      (AutoPushHookTests.test_hook_is_registered): Catch up with bzr.dev
      changing the layout of self._preserved_hooks.
    modified:
      tests/test_auto_upload_hook.py
      tests/test_upload.py
    ------------------------------------------------------------
    revno: 43.1.16
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Fri 2009-03-13 11:02:54 +1000
    message:
      Make the test suite pass, but not the nearly empty one :).
      
      * tests/test_upload.py:
      (get_transport_scenarios): Oops, we want to check against the
      class module, not the class name.
    modified:
      tests/test_upload.py
-------------- next part --------------
=== added file 'NEWS'
--- a/NEWS	1970-01-01 00:00:00 +0000
+++ b/NEWS	2009-02-10 08:41:52 +0000
@@ -0,0 +1,31 @@
+--------------------
+bzr-upload Release Notes
+--------------------
+
+.. contents::
+
+IN DEVELOPMENT
+--------------
+
+  COMPATIBILITY BREAKS:
+
+  NEW FEATURES:
+
+    * Remote branches can be used to upload from.
+      (Gary van der Merwe, Vincent Ladeuil)
+
+  IMPROVEMENTS:
+
+  BUG FIXES:
+
+  DOCUMENTATION:
+
+    * Clarify 'changes' definition in online help.
+      (Vincent Ladeuil, #275538)
+
+  API CHANGES:
+
+  TESTING:
+
+  INTERNALS:
+

=== modified file 'README'
--- a/README	2008-08-01 18:59:59 +0000
+++ b/README	2009-01-19 08:53:32 +0000
@@ -65,6 +65,20 @@
 will disable the feature for that branch.
 
 
+Upload from Remote Location
+---------------------------
+
+It is possible to upload to a remote location from another remote location by
+specifying it with the --directory option:
+
+    bzr upload ftp://public.example.com --directory sftp://private.example.com 
+
+This, together with --auto, can be used to upload when you push to your
+central branch, rather than when you commit to your local branch.
+
+Note that you will consume more bandwith this way than uploading from a local
+branch.
+
 Collaborating
 -------------
 
@@ -80,6 +94,5 @@
 ------------
 
  * Symlinks are not supported
- * Execution bits aren't currently handled
 
 

=== modified file '__init__.py'
--- a/__init__.py	2008-11-08 18:14:34 +0000
+++ b/__init__.py	2009-05-05 16:47:47 +0000
@@ -25,7 +25,7 @@
 Known limitations:
 - Symlinks are ignored,
 
-- chmod bits are not supported.
+- chmod bits (other than the owner's execution bit) are not supported.
 """
 
 # TODO: the chmod bits *can* be supported via the upload protocols
@@ -49,6 +49,7 @@
 import stat
 
 from bzrlib import (
+    bzrdir,
     errors,
     revisionspec,
     transport,
@@ -58,7 +59,7 @@
     )
 """)
 
-version_info = (0, 1, 1)
+version_info = (1, 0, 0, 'dev', 0)
 plugin_name = 'upload'
 
 
@@ -323,11 +324,18 @@
             self.tree.unlock()
 
 
+class CannotUploadToWorkingTreeError(errors.BzrCommandError):
+
+    _fmt = 'Cannot upload to a bzr managed working tree: %(url)s".'
+
+
 class cmd_upload(commands.Command):
     """Upload a working tree, as a whole or incrementally.
 
     If no destination is specified use the last one used.
     If no revision is specified upload the changes since the last upload.
+
+    Changes include files added, renamed, modified or removed.
     """
     takes_args = ['location?']
     takes_options = [
@@ -357,13 +365,14 @@
             raise BzrCommandError("Your version of bzr does not have the "
                     "hooks necessary for --auto to work")
 
-        wt = workingtree.WorkingTree.open_containing(directory)[0]
-        changes = wt.changes_from(wt.basis_tree())
-
-        if revision is None and  changes.has_changed():
-            raise errors.UncommittedChanges(wt)
-
-        branch = wt.branch
+        (wt, branch,
+         relpath) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
+
+        if wt:
+            changes = wt.changes_from(wt.basis_tree())
+
+            if revision is None and  changes.has_changed():
+                raise errors.UncommittedChanges(wt)
 
         if location is None:
             stored_loc = get_upload_location(branch)
@@ -378,6 +387,20 @@
                 location = stored_loc
 
         to_transport = transport.get_transport(location)
+
+        # Check that we are not uploading to a existing working tree.
+        try:
+            to_bzr_dir = bzrdir.BzrDir.open_from_transport(to_transport)
+            has_wt = to_bzr_dir.has_workingtree()
+        except errors.NotBranchError:
+            has_wt = False
+        except errors.NotLocalUrl:
+            # The exception raised is a bit weird... but that's life.
+            has_wt = True
+
+        if has_wt:
+            raise CannotUploadToWorkingTreeError(url=location)
+
         if revision is None:
             rev_id = branch.last_revision()
         else:

=== modified file 'debian/changelog'
--- a/debian/changelog	2009-03-19 17:15:00 +0000
+++ b/debian/changelog	2009-05-05 16:47:47 +0000
@@ -1,10 +1,10 @@
-bzr-upload (0.1.1-1.1) UNRELEASED; urgency=low
+bzr-upload (0.1.1+bzr59-1) unstable; urgency=low
 
-  * Non-maintainer upload.
   * Move to section vcs.
   * Bump standards version to 3.8.1.
+  * New upstream snapshot.
 
- -- Jelmer Vernooij <jelmer at debian.org>  Thu, 19 Mar 2009 18:14:51 +0100
+ -- Jelmer Vernooij <jelmer at debian.org>  Tue, 05 May 2009 18:46:13 +0200
 
 bzr-upload (0.1.1-1) unstable; urgency=low
 

=== modified file 'debian/compat'
--- a/debian/compat	2008-06-14 16:43:13 +0000
+++ b/debian/compat	2009-05-05 16:47:47 +0000
@@ -1,1 +1,1 @@
-4
+5

=== modified file 'debian/control'
--- a/debian/control	2009-03-19 17:15:00 +0000
+++ b/debian/control	2009-05-05 16:47:47 +0000
@@ -2,18 +2,17 @@
 Section: vcs
 Priority: optional
 Maintainer: Debian Bazaar Maintainers <pkg-bazaar-maint at lists.alioth.debian.org>
-Uploaders: Jelmer Vernooij <jelmer at samba.org>
+Uploaders: Jelmer Vernooij <jelmer at debian.org>
 Homepage: https://launchpad.net/bzr-upload
 Build-Depends-Indep: bzr (>= 1.5)
 Build-Depends: python-central (>= 0.5), cdbs (>= 0.4.43), debhelper (>= 5.0.37.2), python-dev
 Standards-Version: 3.8.1
 XS-Python-Version: >= 2.4
 Vcs-Bzr: http://bzr.debian.org/pkg-bazaar/bzr-upload/unstable/
-DM-Upload-Allowed: yes
 
 Package: bzr-upload
 Architecture: all
-Depends: bzr (>= 1.5), ${python:Depends}
+Depends: bzr (>= 1.5), ${python:Depends}, ${misc:Depends}
 Enhances: bzr
 XB-Python-Version: ${python:Versions}
 Description: Bazaar plugin for uploading to web servers

=== modified file 'tests/test_auto_upload_hook.py'
--- a/tests/test_auto_upload_hook.py	2008-08-01 18:58:57 +0000
+++ b/tests/test_auto_upload_hook.py	2009-03-13 00:51:19 +0000
@@ -50,8 +50,8 @@
 
     def test_hook_is_registered(self):
         # Hooks are stored in self._preserved_hooks
-        self.assertTrue(auto_upload_hook in 
-                self._preserved_hooks[Branch]['post_change_branch_tip'])
+        self.assertTrue(auto_upload_hook in
+                self._preserved_hooks[Branch][1]['post_change_branch_tip'])
 
     def test_auto_push_on_commit(self):
         self.make_start_branch()

=== modified file 'tests/test_upload.py'
--- a/tests/test_upload.py	2008-09-16 06:51:08 +0000
+++ b/tests/test_upload.py	2009-03-13 01:02:54 +0000
@@ -38,120 +38,88 @@
     )
 
 
-from bzrlib.plugins.upload import cmd_upload, BzrUploader, get_upload_auto
-
-
-class TransportAdapter(
-    test_transport_implementations.TransportTestProviderAdapter):
-    """A tool to generate a suite testing all transports for a single test.
-
-    We restrict the transports to the ones we want to support.
-    """
-
-    def _test_permutations(self):
-        """Return a list of the klass, server_factory pairs to test."""
-        result = []
-        transport_modules =['bzrlib.transport.ftp',
-                            'bzrlib.transport.sftp']
-        for module in transport_modules:
-            try:
-                permutations = self.get_transport_test_permutations(
-                    reduce(getattr, (module).split('.')[1:],
-                           __import__(module)))
-                for (klass, server_factory) in permutations:
-                    scenario = (server_factory.__name__,
-                        {"transport_class":klass,
-                         "transport_server":server_factory})
-                    result.append(scenario)
-            except errors.DependencyNotPresent, e:
-                # Continue even if a dependency prevents us 
-                # from adding this test
-                pass
-        try:
-            import bzrlib.plugins.local_test_server
-            from bzrlib.plugins.local_test_server import test_server
-            if False:
-                # XXX: Disable since we can't get chmod working for anonymous
-                # user
-                scenario = ('vsftpd',
-                            {'transport_class': test_server.FtpTransport,
-                             'transport_server': test_server.Vsftpd,
-                             })
-                result.append(scenario)
-            if test_server.ProftpdFeature().available():
-                scenario = ('proftpd',
-                            {'transport_class': test_server.FtpTransport,
-                             'transport_server': test_server.Proftpd,
-                             })
-                result.append(scenario)
-        except ImportError:
-            pass
-        return result
+from bzrlib.plugins.upload import (
+    cmd_upload,
+    BzrUploader,
+    get_upload_auto,
+    CannotUploadToWorkingTreeError,
+    )
+
+
+def get_transport_scenarios():
+    result = []
+    basis = test_transport_implementations.transport_test_permutations()
+    # Keep only the interesting ones for upload
+    for name, d in basis:
+        t_class = d['transport_class']
+        if t_class.__module__ in ('bzrlib.transport.ftp',
+                                'bzrlib.transport.sftp'):
+           result.append((name, d))
+    try:
+        import bzrlib.plugins.local_test_server
+        from bzrlib.plugins.local_test_server import test_server
+        if False:
+            # XXX: Disable since we can't get chmod working for anonymous
+            # user
+            scenario = ('vsftpd',
+                        {'transport_class': test_server.FtpTransport,
+                         'transport_server': test_server.Vsftpd,
+                         })
+            result.append(scenario)
+        from test_server import ProftpdFeature
+        if ProftpdFeature().available():
+            scenario = ('proftpd',
+                        {'transport_class': test_server.FtpTransport,
+                         'transport_server': test_server.Proftpd,
+                         })
+            result.append(scenario)
+        # XXX: add support for pyftpdlib
+    except ImportError:
+        pass
+    return result
 
 
 def load_tests(standard_tests, module, loader):
     """Multiply tests for tranport implementations."""
     result = loader.suiteClass()
 
-    is_testing_for_transports = tests.condition_isinstance(
-        (TestFullUpload,
-         TestIncrementalUpload,))
-    transport_adapter = TransportAdapter()
-
-    is_testing_for_branches = tests.condition_isinstance(
-        (TestBranchUploadLocations,))
-    # Generate a list of branch formats and their associated bzrdir formats to
-    # use.
-    # XXX: This was copied from bzrlib.tests.branch_implementations.tests_suite
-    # and need to be shared in a better way.
-    combinations = [(format, format._matchingbzrdir) for format in
-         branch.BranchFormat._formats.values() + branch._legacy_formats]
-    BTPA = branch_implementations.BranchTestProviderAdapter
-    branch_adapter = BTPA(
-        # None here will cause the default vfs transport server to be used.
-        None,
-        # None here will cause a readonly decorator to be created
-        # by the TestCaseWithTransport.get_readonly_transport method.
-        None,
-        combinations)
-    branch_adapter_for_ss = BTPA(
-        smart_server.SmartTCPServer_for_testing,
-        smart_server.ReadonlySmartTCPServer_for_testing,
-        [(remote.RemoteBranchFormat(), remote.RemoteBzrDirFormat())],
-        # XXX: Report to bzr list, this parameter is not used in the
-        # constructor
-
-        # MemoryServer
-        )
-
-    for test_class in tests.iter_suite_tests(standard_tests):
-        # Each test class is either standalone or testing for some combination
-        # of transport or branch. Use the right adpater (or none) depending on
-        # the class.
-        if is_testing_for_transports(test_class):
-            result.addTests(transport_adapter.adapt(test_class))
-        elif is_testing_for_branches(test_class):
-            result.addTests(branch_adapter.adapt(test_class))
-            result.addTests(branch_adapter_for_ss.adapt(test_class))
-        else:
-            result.addTest(test_class)
+    # one for each transport implementation
+    t_tests, remaining_tests = tests.split_suite_by_condition(
+        standard_tests, tests.condition_isinstance((
+                TestFullUpload,
+                TestIncrementalUpload,
+                TestUploadFromRemoteBranch,
+                )))
+    tests.multiply_tests(t_tests, get_transport_scenarios(), result)
+
+    # one for each branch format
+    b_tests, remaining_tests = tests.split_suite_by_condition(
+        remaining_tests, tests.condition_isinstance((
+                TestBranchUploadLocations,
+                )))
+    tests.multiply_tests(b_tests, branch_implementations.branch_scenarios(),
+                         result)
+
+    # No parametrization for the remaining tests
+    result.addTests(remaining_tests)
+
     return result
 
 
-class TestUploadMixin(object):
-    """Helper class to share tests between full and incremental uploads.
+class UploadUtilsMixin(object):
+    """Helper class to write upload tests.
 
-    This class also provides helpers to simplify test writing. The emphasis is
-    on easy test writing, so each tree modification is committed. This doesn't
+    This class provides helpers to simplify test writing. The emphasis is on
+    easy test writing, so each tree modification is committed. This doesn't
     preclude writing tests spawning several revisions to upload more complex
     changes.
     """
 
-    upload_dir = 'upload/'
-    branch_dir = 'branch/'
+    upload_dir = 'upload'
+    branch_dir = 'branch'
 
-    def make_local_branch(self):
-        t = transport.get_transport('branch')
+    def make_branch_and_working_tree(self):
+        t = transport.get_transport(self.branch_dir)
         t.ensure_base()
         branch = bzrdir.BzrDir.create_branch_convenience(
             t.base,
@@ -161,7 +129,7 @@
         self.tree.commit('initial empty tree')
 
     def assertUpFileEqual(self, content, path, base=upload_dir):
-        self.assertFileEqual(content, base + path)
+        self.assertFileEqual(content, osutils.pathjoin(base, path))
 
     def assertUpPathModeEqual(self, path, expected_mode, base=upload_dir):
         # FIXME: the tests needing that assertion should depend on the server
@@ -169,66 +137,69 @@
         # against servers that can't. Note that some bzrlib transports define
         # _can_roundtrip_unix_modebits in a incomplete way, this property
         # should depend on both the client and the server, not the client only.
-        st = os.stat(base + path)
+        # But the client will know or can find if the server support chmod so
+        # that's the client that will report it anyway.
+        full_path = osutils.pathjoin(base, path)
+        st = os.stat(full_path)
         mode = st.st_mode & 0777
         if expected_mode == mode:
             return
         raise AssertionError(
             'For path %s, mode is %s not %s' %
-            (base + path, oct(mode), oct(expected_mode)))
+            (full_path, oct(mode), oct(expected_mode)))
 
     def failIfUpFileExists(self, path, base=upload_dir):
-        self.failIfExists(base + path)
+        self.failIfExists(osutils.pathjoin(base, path))
 
     def failUnlessUpFileExists(self, path, base=upload_dir):
-        self.failUnlessExists(base + path)
+        self.failUnlessExists(osutils.pathjoin(base, path))
 
-    def set_file_content(self, name, content, base=branch_dir):
-        f = file(base + name, 'wb')
+    def set_file_content(self, path, content, base=branch_dir):
+        f = file(osutils.pathjoin(base, path), 'wb')
         try:
             f.write(content)
         finally:
             f.close()
 
-    def add_file(self, name, content, base=branch_dir):
-        self.set_file_content(name, content, base)
-        self.tree.add(name)
-        self.tree.commit('add file %s' % name)
-
-    def modify_file(self, name, content, base=branch_dir):
-        self.set_file_content(name, content, base)
-        self.tree.commit('modify file %s' % name)
-
-    def chmod_file(self, name, mode, base=branch_dir):
-        path = base + name
-        os.chmod(path, mode)
-        self.tree.commit('change file %s mode to %s' % (name, oct(mode)))
-
-    def delete_any(self, name, base=branch_dir):
-        self.tree.remove([name], keep_files=False)
-        self.tree.commit('delete %s' % name)
-
-    def add_dir(self, name, base=branch_dir):
-        os.mkdir(base + name)
-        self.tree.add(name)
-        self.tree.commit('add directory %s' % name)
-
-    def rename_any(self, old_name, new_name):
-        self.tree.rename_one(old_name, new_name)
-        self.tree.commit('rename %s into %s' % (old_name, new_name))
-
-    def transform_dir_into_file(self, name, content, base=branch_dir):
-        osutils.delete_any(base + name)
-        self.set_file_content(name, content, base)
-        self.tree.commit('change %s from dir to file' % name)
-
-    def transform_file_into_dir(self, name, base=branch_dir):
+    def add_file(self, path, content, base=branch_dir):
+        self.set_file_content(path, content, base)
+        self.tree.add(path)
+        self.tree.commit('add file %s' % path)
+
+    def modify_file(self, path, content, base=branch_dir):
+        self.set_file_content(path, content, base)
+        self.tree.commit('modify file %s' % path)
+
+    def chmod_file(self, path, mode, base=branch_dir):
+        full_path = osutils.pathjoin(base, path)
+        os.chmod(full_path, mode)
+        self.tree.commit('change file %s mode to %s' % (path, oct(mode)))
+
+    def delete_any(self, path, base=branch_dir):
+        self.tree.remove([path], keep_files=False)
+        self.tree.commit('delete %s' % path)
+
+    def add_dir(self, path, base=branch_dir):
+        os.mkdir(osutils.pathjoin(base, path))
+        self.tree.add(path)
+        self.tree.commit('add directory %s' % path)
+
+    def rename_any(self, old_path, new_path):
+        self.tree.rename_one(old_path, new_path)
+        self.tree.commit('rename %s into %s' % (old_path, new_path))
+
+    def transform_dir_into_file(self, path, content, base=branch_dir):
+        osutils.delete_any(osutils.pathjoin(base, path))
+        self.set_file_content(path, content, base)
+        self.tree.commit('change %s from dir to file' % path)
+
+    def transform_file_into_dir(self, path, base=branch_dir):
         # bzr can't handle that kind change in a single commit without an
         # intervening bzr status (see bug #205636).
-        self.tree.remove([name], keep_files=False)
-        os.mkdir(base + name)
-        self.tree.add(name)
-        self.tree.commit('change %s from file to dir' % name)
+        self.tree.remove([path], keep_files=False)
+        os.mkdir(osutils.pathjoin(base, path))
+        self.tree.add(path)
+        self.tree.commit('change %s from file to dir' % path)
 
     def _get_cmd_upload(self):
         upload = cmd_upload()
@@ -240,23 +211,27 @@
 
     def do_full_upload(self, *args, **kwargs):
         upload = self._get_cmd_upload()
-        up_url = self.get_transport(self.upload_dir).external_url()
+        up_url = self.get_url(self.upload_dir)
         if kwargs.get('directory', None) is None:
-            kwargs['directory'] = 'branch'
+            kwargs['directory'] = self.branch_dir
         kwargs['full'] = True
         kwargs['quiet'] = True
         upload.run(up_url, *args, **kwargs)
 
     def do_incremental_upload(self, *args, **kwargs):
         upload = self._get_cmd_upload()
-        up_url = self.get_transport(self.upload_dir).external_url()
+        up_url = self.get_url(self.upload_dir)
         if kwargs.get('directory', None) is None:
-            kwargs['directory'] = 'branch'
+            kwargs['directory'] = self.branch_dir
         kwargs['quiet'] = True
         upload.run(up_url, *args, **kwargs)
 
+
+class TestUploadMixin(UploadUtilsMixin):
+    """Helper class to share tests between full and incremental uploads."""
+
     def test_create_file(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.do_full_upload()
         self.add_file('hello', 'foo')
 
@@ -265,7 +240,7 @@
         self.assertUpFileEqual('foo', 'hello')
 
     def test_create_file_in_subdir(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.do_full_upload()
         self.add_dir('dir')
         self.add_file('dir/goodbye', 'baz')
@@ -278,7 +253,7 @@
         self.assertUpPathModeEqual('dir', 0775)
 
     def test_modify_file(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'foo')
         self.do_full_upload()
         self.modify_file('hello', 'bar')
@@ -290,7 +265,7 @@
         self.assertUpFileEqual('bar', 'hello')
 
     def test_rename_one_file(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'foo')
         self.do_full_upload()
         self.rename_any('hello', 'goodbye')
@@ -302,7 +277,7 @@
         self.assertUpFileEqual('foo', 'goodbye')
 
     def test_rename_and_change_file(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'foo')
         self.do_full_upload()
         self.rename_any('hello', 'goodbye')
@@ -315,7 +290,7 @@
         self.assertUpFileEqual('bar', 'goodbye')
 
     def test_rename_two_files(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('a', 'foo')
         self.add_file('b', 'qux')
         self.do_full_upload()
@@ -333,7 +308,7 @@
         self.assertUpFileEqual('qux', 'c')
 
     def test_upload_revision(self):
-        self.make_local_branch() # rev1
+        self.make_branch_and_working_tree() # rev1
         self.do_full_upload()
         self.add_file('hello', 'foo') # rev2
         self.modify_file('hello', 'bar') # rev3
@@ -346,14 +321,14 @@
         self.assertUpFileEqual('foo', 'hello')
 
     def test_no_upload_when_changes(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('a', 'foo')
         self.set_file_content('a', 'bar')
 
         self.assertRaises(errors.UncommittedChanges, self.do_upload)
 
     def test_no_upload_when_conflicts(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('a', 'foo')
         self.run_bzr('branch branch other')
         self.modify_file('a', 'bar')
@@ -366,7 +341,7 @@
         self.assertRaises(errors.UncommittedChanges, self.do_upload)
 
     def test_change_file_into_dir(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'foo')
         self.do_full_upload()
         self.transform_file_into_dir('hello')
@@ -379,7 +354,7 @@
         self.assertUpFileEqual('bar', 'hello/file')
 
     def test_change_dir_into_file(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_dir('hello')
         self.add_file('hello/file', 'foo')
         self.do_full_upload()
@@ -393,7 +368,7 @@
         self.assertUpFileEqual('bar', 'hello')
 
     def test_make_file_executable(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'foo')
         self.chmod_file('hello', 0664)
         self.do_full_upload()
@@ -405,40 +380,47 @@
 
         self.assertUpPathModeEqual('hello', 0775)
 
+    def get_upload_auto(self):
+        return get_upload_auto(self.tree.branch)
+
     def test_upload_auto(self):
         """Test that upload --auto sets the upload_auto option"""
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
+
         self.add_file('hello', 'foo')
-        self.assertFalse(get_upload_auto(self.tree.branch))
+        self.assertFalse(self.get_upload_auto())
         self.do_full_upload(auto=True)
         self.assertUpFileEqual('foo', 'hello')
-        self.assertTrue(get_upload_auto(self.tree.branch))
+        self.assertTrue(self.get_upload_auto())
+
         # and check that it stays set until it is unset
         self.add_file('bye', 'bar')
         self.do_full_upload()
         self.assertUpFileEqual('bar', 'bye')
-        self.assertTrue(get_upload_auto(self.tree.branch))
+        self.assertTrue(self.get_upload_auto())
 
     def test_upload_noauto(self):
         """Test that upload --no-auto unsets the upload_auto option"""
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
+
         self.add_file('hello', 'foo')
-        self.assertFalse(get_upload_auto(self.tree.branch))
         self.do_full_upload(auto=True)
         self.assertUpFileEqual('foo', 'hello')
-        self.assertTrue(get_upload_auto(self.tree.branch))
+        self.assertTrue(self.get_upload_auto())
+
         self.add_file('bye', 'bar')
         self.do_full_upload(auto=False)
         self.assertUpFileEqual('bar', 'bye')
-        self.assertFalse(get_upload_auto(self.tree.branch))
+        self.assertFalse(self.get_upload_auto())
+
         # and check that it stays unset until it is set
         self.add_file('again', 'baz')
         self.do_full_upload()
         self.assertUpFileEqual('baz', 'again')
-        self.assertFalse(get_upload_auto(self.tree.branch))
+        self.assertFalse(self.get_upload_auto())
 
     def test_upload_from_subdir(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.build_tree(['branch/foo/', 'branch/foo/bar'])
         self.tree.add(['foo/', 'foo/bar'])
         self.tree.commit("Add directory")
@@ -450,14 +432,14 @@
     do_upload = TestUploadMixin.do_full_upload
 
     def test_full_upload_empty_tree(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
 
         self.do_full_upload()
 
         self.failUnlessUpFileExists(BzrUploader.bzr_upload_revid_file_name)
 
     def test_invalid_revspec(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         rev1 = revisionspec.RevisionSpec.from_string('1')
         rev2 = revisionspec.RevisionSpec.from_string('2')
 
@@ -465,7 +447,7 @@
                           self.do_incremental_upload, revision=[rev1, rev2])
 
     def test_create_remote_dir_twice(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_dir('dir')
         self.do_full_upload()
         self.add_file('dir/goodbye', 'baz')
@@ -485,7 +467,7 @@
     # XXX: full upload doesn't handle deletions....
 
     def test_delete_one_file(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'foo')
         self.do_full_upload()
         self.delete_any('hello')
@@ -497,7 +479,7 @@
         self.failIfUpFileExists('hello')
 
     def test_delete_dir_and_subdir(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_dir('dir')
         self.add_dir('dir/subdir')
         self.add_file('dir/subdir/a', 'foo')
@@ -516,7 +498,7 @@
         self.assertUpFileEqual('foo', 'a')
 
     def test_delete_one_file_rename_to_deleted(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('a', 'foo')
         self.add_file('b', 'bar')
         self.do_full_upload()
@@ -531,7 +513,7 @@
         self.assertUpFileEqual('bar', 'a')
 
     def test_rename_outside_dir_delete_dir(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_dir('dir')
         self.add_file('dir/a', 'foo')
         self.do_full_upload()
@@ -547,7 +529,7 @@
         self.assertUpFileEqual('foo', 'a')
 
     def test_upload_for_the_first_time_do_a_full_upload(self):
-        self.make_local_branch()
+        self.make_branch_and_working_tree()
         self.add_file('hello', 'bar')
 
         self.failIfUpFileExists(BzrUploader.bzr_upload_revid_file_name)
@@ -580,3 +562,37 @@
         config.set_user_option('upload_location', 'foo')
         self.assertEqual('foo', config.get_user_option('upload_location'))
 
+
+class TestUploadFromRemoteBranch(tests.TestCaseWithTransport,
+                                 UploadUtilsMixin):
+
+    remote_branch_dir = 'remote_branch'
+
+    def make_remote_branch_without_working_tree(self):
+        """Creates a branch without working tree to upload from.
+
+        It's created from the existing self.branch_dir one which still has its
+        working tree.
+        """
+        self.make_branch_and_working_tree()
+        self.add_file('hello', 'foo')
+
+        remote_branch_url = self.get_url(self.remote_branch_dir)
+        self.run_bzr(['push', remote_branch_url,
+                      '--directory', self.branch_dir])
+        return remote_branch_url
+
+    def test_no_upload_to_remote_working_tree(self):
+        remote_branch_url = self.make_remote_branch_without_working_tree()
+        upload = self._get_cmd_upload()
+        up_url = self.get_url(self.branch_dir)
+        # Let's try to upload from the just created remote branch into the
+        # branch (with has a working tree).
+        self.assertRaises(CannotUploadToWorkingTreeError,
+                          upload.run, up_url, directory=remote_branch_url)
+
+    def test_upload_without_working_tree(self):
+        remote_branch_url = self.make_remote_branch_without_working_tree()
+        self.do_full_upload(directory=remote_branch_url)
+        self.assertUpFileEqual('foo', 'hello')
+



More information about the Pkg-bazaar-commits mailing list