Rev 2755: Merge commit refactoring. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Mon Sep 10 00:02:00 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2755
revision-id: robertc at robertcollins.net-20070909230147-uqkvnsc986bpxwj1
parent: robertc at robertcollins.net-20070909222846-nahsjm9iyel6vtoa
parent: robertc at robertcollins.net-20070909224707-s1vrl45nvle0k51m
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Mon 2007-09-10 09:01:47 +1000
message:
  Merge commit refactoring.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
  bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
  bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
  bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
    ------------------------------------------------------------
    revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.43
    revision-id: robertc at robertcollins.net-20070909224707-s1vrl45nvle0k51m
    parent: robertc at robertcollins.net-20070906010906-2so4bg4lr3y8wlqd
    parent: pqm at pqm.ubuntu.com-20070907145828-hjh5941jv7y8d9z8
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: commit
    timestamp: Mon 2007-09-10 08:47:07 +1000
    message:
      Merge bzr.dev.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/store/revision/knit.py  knit.py-20060303020652-de5fa299e941a3c7
      bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
      bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
      bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
      bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
      bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
      bzrlib/weave.py                knit.py-20050627021749-759c29984154256b
      doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
        ------------------------------------------------------------
        revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.18.1.9.1.2
        revision-id: pqm at pqm.ubuntu.com-20070907145828-hjh5941jv7y8d9z8
        parent: pqm at pqm.ubuntu.com-20070906063814-iiwx3hccoukt499k
        parent: v.ladeuil+lp at free.fr-20070907134117-hv955pzvsv3ofap9
        committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
        branch nick: +trunk
        timestamp: Fri 2007-09-07 15:58:28 +0100
        message:
          Fix bug #137044: ftp password handling broken
        modified:
          NEWS                           NEWS-20050323055033-4e00b5db738777ff
          bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
          bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
            ------------------------------------------------------------
            revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.18.1.9.1.1.1.1
            revision-id: v.ladeuil+lp at free.fr-20070907134117-hv955pzvsv3ofap9
            parent: pqm at pqm.ubuntu.com-20070906063814-iiwx3hccoukt499k
            parent: v.ladeuil+lp at free.fr-20070907133303-0c0ro056pn6owz10
            committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
            branch nick: bzr.integration
            timestamp: Fri 2007-09-07 15:41:17 +0200
            message:
              Fix bug #137044: ftp apssword handling broken
            modified:
              NEWS                           NEWS-20050323055033-4e00b5db738777ff
              bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
              bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
            ------------------------------------------------------------
            revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.14.1.4
            revision-id: v.ladeuil+lp at free.fr-20070907133303-0c0ro056pn6owz10
            parent: v.ladeuil+lp at free.fr-20070905133820-s1jndkddykxebo4g
            parent: pqm at pqm.ubuntu.com-20070906063814-iiwx3hccoukt499k
            committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
            branch nick: 137044
            timestamp: Fri 2007-09-07 15:33:03 +0200
            message:
              Merge bzr.dev
            added:
              bzrlib/_patiencediff_c.c       _patiencediff_c.c-20070721205602-q3imkipwlgagp3cy-1
              bzrlib/benchmarks/bench_pack.py bench_pack.py-20070903042947-0wphp878xr6wkw7t-1
              bzrlib/patiencediff.py         patiencediff.py-20070721205536-jz8gaykeb7xtampk-1
            renamed:
              bzrlib/patiencediff.py => bzrlib/_patiencediff_py.py cdvdifflib.py-20051106064558-f8f8097fbf0db4e4
            modified:
              NEWS                           NEWS-20050323055033-4e00b5db738777ff
              bzr                            bzr.py-20050313053754-5485f144c7006fa6
              bzrlib/benchmarks/__init__.py  __init__.py-20060516064526-eb0d37c78e86065d
              bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
              bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
              bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
              bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
              bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
              bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
              bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
              bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
              bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
              bzrlib/pack.py                 container.py-20070607160755-tr8zc26q18rn0jnb-1
              bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
              bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
              bzrlib/store/revision/knit.py  knit.py-20060303020652-de5fa299e941a3c7
              bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
              bzrlib/tests/blackbox/test_cat.py test_cat.py-20051201162916-f0937e4e19ea24b3
              bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
              bzrlib/tests/blackbox/test_conflicts.py test_conflicts.py-20060228151432-9723ebb925b999cf
              bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
              bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
              bzrlib/tests/blackbox/test_version.py test_version.py-20070312060045-ol7th9z035r3im3d-1
              bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
              bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
              bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
              bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
              bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
              bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
              bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
              bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
              bzrlib/tests/test_merge_core.py test_merge_core.py-20050824132511-eb99b23a0eec641b
              bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
              bzrlib/tests/test_revert.py    test_revert.py-20060828180832-fqb1v6ecpyvnlitj-1
              bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
              bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
              bzrlib/tests/test_weave.py     testknit.py-20050627023648-9833cc5562ffb785
              bzrlib/tests/tree_implementations/test_inv.py test_inv.py-20070312023226-0cdvk5uwhutis9vg-1
              bzrlib/tests/workingtree_implementations/test_executable.py test_executable.py-20060628162557-tr7h57kl80l3ma8i-1
              bzrlib/tests/workingtree_implementations/test_inv.py test_inv.py-20070311221604-ighlq8tbn5xq0kuo-1
              bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
              bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
              bzrlib/version.py              version.py-20060816024207-ves6ult9a11taj9t-1
              bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
              bzrlib/weave.py                knit.py-20050627021749-759c29984154256b
              bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
              bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
              doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
              setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
              bzrlib/_patiencediff_py.py     cdvdifflib.py-20051106064558-f8f8097fbf0db4e4
            ------------------------------------------------------------
            revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.14.1.3
            revision-id: v.ladeuil+lp at free.fr-20070905133820-s1jndkddykxebo4g
            parent: v.ladeuil+lp at free.fr-20070905133538-3hlcjti8pktcamp0
            committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
            branch nick: 137044
            timestamp: Wed 2007-09-05 15:38:20 +0200
            message:
              Cosmetic change.
            modified:
              bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
            ------------------------------------------------------------
            revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.14.1.2
            revision-id: v.ladeuil+lp at free.fr-20070905133538-3hlcjti8pktcamp0
            parent: v.ladeuil+lp at free.fr-20070905072749-qiud9xt21loarqyy
            committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
            branch nick: 137044
            timestamp: Wed 2007-09-05 15:35:38 +0200
            message:
              Review feedback.
            modified:
              bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
              bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
            ------------------------------------------------------------
            revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.14.1.1
            revision-id: v.ladeuil+lp at free.fr-20070905072749-qiud9xt21loarqyy
            parent: pqm at pqm.ubuntu.com-20070903130729-qdcrag0a7vcpzfgm
            committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
            branch nick: 137044
            timestamp: Wed 2007-09-05 09:27:49 +0200
            message:
              Fix #137044 by prompting for a password if *none* is provided for ftp.
              
              * bzrlib/transport/ftp.py:
              (FtpTransport._create_connection): The fix: the test was inverted.
              (_setup_medusa.test_authorizer.__init__): One user can be secured
              by verifying his password.
              (_setup_medusa.test_authorizer.authorize): Check the password if a
              secured user have been declared. Let the doors wide open
              otherwise (as before :-/).
              
              * bzrlib/tests/test_ftp_transport.py:
              (TestFTPServer.test_basic_exists): New class for UI related tests.
            modified:
              NEWS                           NEWS-20050323055033-4e00b5db738777ff
              bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
              bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
        ------------------------------------------------------------
        revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.18.1.9.1.1
        revision-id: pqm at pqm.ubuntu.com-20070906063814-iiwx3hccoukt499k
        parent: pqm at pqm.ubuntu.com-20070906050530-q58gvki4dedc4i6e
        parent: robertc at robertcollins.net-20070906055813-7gb0w5zi4u7xctt6
        committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
        branch nick: +trunk
        timestamp: Thu 2007-09-06 07:38:14 +0100
        message:
          Fix typo in ghosts version of test_add_lines_nostoresha.
        modified:
          bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
        ------------------------------------------------------------
        revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.18.1.9.2.1
        revision-id: robertc at robertcollins.net-20070906055813-7gb0w5zi4u7xctt6
        parent: pqm at pqm.ubuntu.com-20070906050530-q58gvki4dedc4i6e
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: integration
        timestamp: Thu 2007-09-06 15:58:13 +1000
        message:
          Fix typo in ghosts version of test_add_lines_nostoresha.
        modified:
          bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
    ------------------------------------------------------------
    revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.42
    revision-id: robertc at robertcollins.net-20070906010906-2so4bg4lr3y8wlqd
    parent: robertc at robertcollins.net-20070905230807-xxl20o4evg2wrswh
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: commit
    timestamp: Thu 2007-09-06 11:09:06 +1000
    message:
      Move content summary generation outside of record_entry_contents.
    modified:
      bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/tests/repository_implementations/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
    ------------------------------------------------------------
    revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.41
    revision-id: robertc at robertcollins.net-20070905230807-xxl20o4evg2wrswh
    parent: robertc at robertcollins.net-20070905055134-pwbueao0qq6krf9u
    parent: pqm at pqm.ubuntu.com-20070905084824-xdwd8f4fioovdi9v
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: commit
    timestamp: Thu 2007-09-06 09:08:07 +1000
    message:
      Merge bzr.dev.
    added:
      bzrlib/_patiencediff_c.c       _patiencediff_c.c-20070721205602-q3imkipwlgagp3cy-1
      bzrlib/patiencediff.py         patiencediff.py-20070721205536-jz8gaykeb7xtampk-1
    renamed:
      bzrlib/patiencediff.py => bzrlib/_patiencediff_py.py cdvdifflib.py-20051106064558-f8f8097fbf0db4e4
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzr                            bzr.py-20050313053754-5485f144c7006fa6
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
      bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
      bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
      bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
      bzrlib/tests/blackbox/test_version.py test_version.py-20070312060045-ol7th9z035r3im3d-1
      bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
      bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
      bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
      bzrlib/tests/test_merge_core.py test_merge_core.py-20050824132511-eb99b23a0eec641b
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
      bzrlib/tests/test_revert.py    test_revert.py-20060828180832-fqb1v6ecpyvnlitj-1
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/workingtree_implementations/test_executable.py test_executable.py-20060628162557-tr7h57kl80l3ma8i-1
      bzrlib/tests/workingtree_implementations/test_inv.py test_inv.py-20070311221604-ighlq8tbn5xq0kuo-1
      bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
      bzrlib/version.py              version.py-20060816024207-ves6ult9a11taj9t-1
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
      setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
      bzrlib/_patiencediff_py.py     cdvdifflib.py-20051106064558-f8f8097fbf0db4e4
=== modified file 'NEWS'
--- a/NEWS	2007-09-09 22:28:46 +0000
+++ b/NEWS	2007-09-09 23:01:47 +0000
@@ -123,6 +123,9 @@
    * ``bzr --version`` takes care about encoding of stdout, especially
      when output is redirected. (Alexander Belchenko, #131100)
 
+   * Prompt for an ftp password if none is provided.
+     (Vincent Ladeuil, #137044)
+
   IMPROVEMENTS:
 
    * Add the option "--show-diff" to the commit command in order to display
@@ -255,6 +258,10 @@
      incremental addition of data to a file without requiring that all the
      data be buffered in memory. (Robert Collins)
 
+   * New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a
+     tuple containing the key information about a path for commit processing
+     to complete. (Robert Collins)
+
    * New methods on ``bzrlib.knit.KnitVersionedFile``:
      ``get_data_stream(versions)``, ``insert_data_stream(stream)`` and
      ``get_format_signature()``.  These provide some infrastructure for

=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2007-09-09 22:28:46 +0000
+++ b/bzrlib/commit.py	2007-09-09 23:01:47 +0000
@@ -713,13 +713,17 @@
                     continue
             # TODO: have the builder do the nested commit just-in-time IF and
             # only if needed.
-            try:
-                kind = self.work_tree.kind(file_id)
-                # TODO: specific_files filtering before nested tree processing
-                if kind == 'tree-reference' and self.builder.recursive == 'down':
-                    self._commit_nested_tree(file_id, path)
-            except errors.NoSuchFile:
-                pass
+            content_summary = self.work_tree.path_content_summary(path)
+            if content_summary[0] == 'tree-reference':
+                # enforce repository nested tree policy.
+                if (not self.work_tree.supports_tree_reference() or
+                    # repository does not support it either.
+                    not self.branch.repository._format.supports_tree_reference()):
+                    content_summary = ('directory',) + content_summary[1:]
+            kind = content_summary[0]
+            # TODO: specific_files filtering before nested tree processing
+            if kind == 'tree-reference' and self.builder.recursive == 'down':
+                self._commit_nested_tree(file_id, path)
 
             # Record an entry for this item
             # Note: I don't particularly want to have the existing_ie
@@ -727,7 +731,7 @@
             # without it thanks to a unicode normalisation issue. :-(
             definitely_changed = kind != existing_ie.kind
             self._record_entry(path, file_id, specific_files, kind, name,
-                parent_id, definitely_changed, existing_ie)
+                parent_id, definitely_changed, existing_ie, content_summary)
 
         # Unversion IDs that were found to be deleted
         self.work_tree.unversion(deleted_ids)
@@ -758,7 +762,7 @@
             pass
 
     def _record_entry(self, path, file_id, specific_files, kind, name,
-                      parent_id, definitely_changed, existing_ie=None):
+        parent_id, definitely_changed, existing_ie, content_summary):
         "Record the new inventory entry for a path if any."
         # mutter('check %s {%s}', path, file_id)
         if (not specific_files or 
@@ -777,8 +781,8 @@
                 # this entry is new and not being committed
                 ie = None
         if ie is not None:
-            self.builder.record_entry_contents(ie, self.parent_invs, 
-                path, self.work_tree)
+            self.builder.record_entry_contents(ie, self.parent_invs,
+                path, self.work_tree, content_summary)
             self._report_change(ie, path)
         return ie
 

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-09-09 22:28:46 +0000
+++ b/bzrlib/repository.py	2007-09-09 23:01:47 +0000
@@ -2395,7 +2395,8 @@
             # _new_revision_id
             ie.revision = self._new_revision_id
 
-    def record_entry_contents(self, ie, parent_invs, path, tree):
+    def record_entry_contents(self, ie, parent_invs, path, tree,
+        content_summary):
         """Record the content of ie from tree into the commit if needed.
 
         Side effect: sets ie.revision when unchanged
@@ -2405,11 +2406,12 @@
             commit.
         :param path: The path the entry is at in the tree.
         :param tree: The tree which contains this entry and should be used to 
-        obtain content.
+            obtain content.
+        :param content_summary: Summary data from the tree about the paths
+            content - stat, length, exec, sha/link target.
         """
         if self.new_inventory.root is None:
             self._check_root(ie, parent_invs, tree)
-        content_summary = tree.path_content_summary(path)
         kind = content_summary[0]
         # XXX: repository specific check for nested tree support goes here - if
         # the repo doesn't want nested trees we skip it ?
@@ -2497,7 +2499,6 @@
                 lines = tree.get_file(ie.file_id, path).readlines()
                 ie.text_sha1, ie.text_size = self._add_text_to_weave(
                     ie.file_id, lines, heads, nostore_sha)
-                ie.revision = self._new_revision_id
             except errors.ExistingContent:
                 # we are not going to store a new file graph node as it turns
                 # out to be unchanged.

=== modified file 'bzrlib/tests/repository_implementations/test_commit_builder.py'
--- a/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-09-05 05:51:34 +0000
+++ b/bzrlib/tests/repository_implementations/test_commit_builder.py	2007-09-06 01:09:06 +0000
@@ -46,7 +46,8 @@
                 tree.unlock()
             parent_tree = tree.branch.repository.revision_tree(None)
             parent_invs = []
-            builder.record_entry_contents(ie, parent_invs, '', tree)
+            builder.record_entry_contents(ie, parent_invs, '', tree,
+                tree.path_content_summary(''))
 
     def test_finish_inventory(self):
         tree = self.make_branch_and_tree(".")
@@ -127,7 +128,8 @@
             builder = tree.branch.get_commit_builder([])
             self.callDeprecated(['Root entry should be supplied to'
                 ' record_entry_contents, as of bzr 0.10.'],
-                builder.record_entry_contents, entry, [], 'foo', tree)
+                builder.record_entry_contents, entry, [], 'foo', tree,
+                    tree.path_content_summary('foo'))
             builder.finish_inventory()
             rev_id = builder.commit('foo bar')
         finally:

=== modified file 'bzrlib/tests/test_ftp_transport.py'
--- a/bzrlib/tests/test_ftp_transport.py	2007-04-12 21:18:29 +0000
+++ b/bzrlib/tests/test_ftp_transport.py	2007-09-05 13:35:38 +0000
@@ -14,8 +14,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-from bzrlib import tests
-import bzrlib.transport
+import sys
+
+from bzrlib import (
+    tests,
+    transport,
+    ui,
+    )
 
 
 class _MedusaFeature(tests.Feature):
@@ -54,7 +59,7 @@
     """Test aftp transport."""
 
     def test_aftp_degrade(self):
-        t = bzrlib.transport.get_transport('aftp://host/path')
+        t = transport.get_transport('aftp://host/path')
         self.failUnless(t.is_active)
         parent = t.clone('..')
         self.failUnless(parent.is_active)
@@ -71,3 +76,42 @@
         t = self.get_transport()
         t.put_bytes('foo', 'test bytes\n')
         self.assertEqual('test bytes\n', t.get_bytes('foo'))
+
+
+class TestFTPServerUI(TestCaseWithFTPServer):
+
+    def setUp(self):
+        super(TestFTPServerUI, self).setUp()
+        self.old_factory = ui.ui_factory
+        # The following has the unfortunate side-effect of hiding any ouput
+        # during the tests (including pdb prompts). Feel free to comment them
+        # for debugging purposes but leave them in place, there are needed to
+        # run the tests without any console
+        self.old_stdout = sys.stdout
+        sys.stdout = tests.StringIOWrapper()
+        self.addCleanup(self.restoreUIFactory)
+
+    def restoreUIFactory(self):
+        ui.ui_factory = self.old_factory
+        sys.stdout = self.old_stdout
+
+    def test_prompt_for_password(self):
+        t = self.get_transport()
+        # Ensure that the test framework set the password
+        self.assertIsNot(t._password, None)
+        # Reset the password (get_url set the password to 'bar' so we
+        # reset it to None in the transport before the connection).
+        password = t._password
+        t._password = None
+        ui.ui_factory = tests.TestUIFactory(stdin=password+'\n')
+        # Ask the server to check the password
+        server = self.get_server()
+        # FIXME: There should be a better way to declare authorized users and
+        # passwords to the server
+        authorizer = server._ftp_server.authorizer
+        authorizer.secured_user = t._user
+        authorizer.secured_password = password
+        # Issue a request to the server to connect
+        t.has('whatever/not/existing')
+        # stdin should be empty (the provided password have been consumed)
+        self.assertEqual('', ui.ui_factory.stdin.readline())

=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py	2007-09-09 22:28:46 +0000
+++ b/bzrlib/tests/test_versionedfile.py	2007-09-09 23:01:47 +0000
@@ -182,52 +182,7 @@
             self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
                 version + "2")
 
-    def test_add_lines_nostoresha(self):
-        """When nostore_sha is supplied using old content raises."""
-        vf = self.get_file()
-        empty_text = ('a', [])
-        sample_text_nl = ('b', ["foo\n", "bar\n"])
-        sample_text_no_nl = ('c', ["foo\n", "bar"])
-        shas = []
-        for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
-            sha, _, _ = vf.add_lines(version, [], lines)
-            shas.append(sha)
-        # we now have a copy of all the lines in the vf.
-        # is the test applicable to this vf implementation?
-        try:
-            vf.add_lines_with_ghosts('d', [], [])
-        except NotImplementedError:
-            raise TestSkipped("add_lines_with_ghosts is optional")
-        for sha, (version, lines) in zip(
-            shas, (empty_text, sample_text_nl, sample_text_no_nl)):
-            self.assertRaises(errors.ExistingContent,
-                vf.add_lines_with_ghosts, version + "2", [], lines,
-                nostore_sha=sha)
-            # and no new version should have been added.
-            self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
-                version + "2")
-
-    def test_add_lines_nostoresha(self):
-        """When nostore_sha is supplied using old content raises."""
-        vf = self.get_file()
-        empty_text = ('a', [])
-        sample_text_nl = ('b', ["foo\n", "bar\n"])
-        sample_text_no_nl = ('c', ["foo\n", "bar"])
-        shas = []
-        for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
-            sha, _, _ = vf.add_lines(version, [], lines)
-            shas.append(sha)
-        # we now have a copy of all the lines in the vf.
-        for sha, (version, lines) in zip(
-            shas, (empty_text, sample_text_nl, sample_text_no_nl)):
-            self.assertRaises(errors.ExistingContent,
-                vf.add_lines, version + "2", [], lines,
-                nostore_sha=sha)
-            # and no new version should have been added.
-            self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
-                version + "2")
-
-    def test_add_lines_nostoresha(self):
+    def test_add_lines_with_ghosts_nostoresha(self):
         """When nostore_sha is supplied using old content raises."""
         vf = self.get_file()
         empty_text = ('a', [])

=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py	2007-08-27 04:25:39 +0000
+++ b/bzrlib/transport/ftp.py	2007-09-09 23:01:47 +0000
@@ -130,7 +130,7 @@
             connection = ftplib.FTP()
             connection.connect(host=self._host, port=self._port)
             if self._user and self._user != 'anonymous' and \
-                    password is not None: # '' is a valid password
+                    password is None: # '' is a valid password
                 get_password = bzrlib.ui.ui_factory.get_password
                 password = get_password(prompt='FTP %(user)s@%(host)s password',
                                         user=self._user, host=self._host)
@@ -654,6 +654,9 @@
 
         def __init__(self, root):
             self.root = root
+            # If secured_user is set secured_password will be checked
+            self.secured_user = None
+            self.secured_password = None
 
         def authorize(self, channel, username, password):
             """Return (success, reply_string, filesystem)"""
@@ -666,7 +669,13 @@
             else:
                 channel.read_only = 0
 
-            return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
+            # Check secured_user if set
+            if (self.secured_user is not None
+                and username == self.secured_user
+                and password != self.secured_password):
+                return 0, 'Password invalid.', None
+            else:
+                return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
 
 
     class ftp_channel(medusa.ftp_server.ftp_channel):



More information about the bazaar-commits mailing list