Rev 4316: (abentley) Implement references command. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Apr 30 16:00:27 BST 2009


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

------------------------------------------------------------
revno: 4316
revision-id: pqm at pqm.ubuntu.com-20090430150023-1cw4lwqf312vpuu8
parent: pqm at pqm.ubuntu.com-20090430065847-r404sy6qj7eoeaud
parent: aaron at aaronbentley.com-20090430140438-hpw2h918x4mpnpaw
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-04-30 16:00:23 +0100
message:
  (abentley) Implement references command.
added:
  bzrlib/tests/blackbox/test_reference.py test_reference.py-20090428205614-7lo1hc2etrwd73x3-1
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/reconfigure.py          reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
  bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
  bzrlib/tests/test_reconfigure.py test_reconfigure.py-20070908040425-6ykgo7escxhyrg9p-2
    ------------------------------------------------------------
    revno: 4273.1.21
    revision-id: aaron at aaronbentley.com-20090430140438-hpw2h918x4mpnpaw
    parent: aaron at aaronbentley.com-20090430140241-as7cb8cu3uldhv33
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: branch-subtree-locations
    timestamp: Thu 2009-04-30 10:04:38 -0400
    message:
      Update from review
    modified:
      bzrlib/tests/blackbox/test_reference.py test_reference.py-20090428205614-7lo1hc2etrwd73x3-1
    ------------------------------------------------------------
    revno: 4273.1.20
    revision-id: aaron at aaronbentley.com-20090430140241-as7cb8cu3uldhv33
    parent: aaron at aaronbentley.com-20090429203134-nwd8x2hpwan1xux3
    parent: pqm at pqm.ubuntu.com-20090430065847-r404sy6qj7eoeaud
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: branch-subtree-locations
    timestamp: Thu 2009-04-30 10:02:41 -0400
    message:
      Merge bzr.dev
    removed:
      bzrlib/util/configobj/docs/    docs-20051018184548-5eb1575f28e645ab
      bzrlib/util/configobj/docs/BSD-LICENSE.txt BSDLICENSE.txt-20051018184548-29b89ff3102657f5
      bzrlib/util/configobj/docs/configobj.txt configobj.txt-20051018184548-4949b5f17e6a19c7
      bzrlib/util/configobj/docs/validate.txt validate.txt-20051018184548-9e0e5ad913e258f5
    modified:
      Makefile                       Makefile-20050805140406-d96e3498bb61c5bb
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
      bzrlib/_groupcompress_py.py    _groupcompress_py.py-20090324110021-j63s399f4icrgw4p-1
      bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
      bzrlib/plugins/launchpad/account.py account.py-20071011033320-50y6vfftywf4yllw-1
      bzrlib/smtp_connection.py      smtp_connection.py-20070618204456-nu6wag1ste4biuk2-1
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
      bzrlib/transport/ftp/__init__.py ftp.py-20051116161804-58dc9506548c2a53
      bzrlib/transport/ftp/_gssapi.py _gssapi.py-20080611190840-7ejrtp884bk5eu72-2
      bzrlib/transport/ssh.py        ssh.py-20060824042150-0s9787kng6zv1nwq-1
      bzrlib/util/configobj/configobj.py configobj.py-20051018184548-06992a2246425e3e
    ------------------------------------------------------------
    revno: 4273.1.19
    revision-id: aaron at aaronbentley.com-20090429203134-nwd8x2hpwan1xux3
    parent: aaron at aaronbentley.com-20090428201244-jm84ghz5hdxt6hww
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: branch-subtree-locations
    timestamp: Wed 2009-04-29 16:31:34 -0400
    message:
      Implement reference command
    added:
      bzrlib/tests/blackbox/test_reference.py test_reference.py-20090428205614-7lo1hc2etrwd73x3-1
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
    ------------------------------------------------------------
    revno: 4273.1.18
    revision-id: aaron at aaronbentley.com-20090428201244-jm84ghz5hdxt6hww
    parent: aaron at aaronbentley.com-20090428194604-zvqoyqzlffdzhrff
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: branch-subtree-locations
    timestamp: Tue 2009-04-28 16:12:44 -0400
    message:
      Reconfigure preserves reference locations.
    modified:
      bzrlib/reconfigure.py          reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
      bzrlib/tests/test_reconfigure.py test_reconfigure.py-20070908040425-6ykgo7escxhyrg9p-2
    ------------------------------------------------------------
    revno: 4273.1.17
    revision-id: aaron at aaronbentley.com-20090428194604-zvqoyqzlffdzhrff
    parent: aaron at aaronbentley.com-20090424143544-h48v6fgl1k6bmxhj
    parent: pqm at pqm.ubuntu.com-20090428170537-tbjh8ng5lrws1er9
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: branch-subtree-locations
    timestamp: Tue 2009-04-28 15:46:04 -0400
    message:
      Merge bzr.dev into branch-subtree-locations.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
      bzrlib/help_topics/en/rules.txt rules.txt-20080516063844-ghr5l6pvvrhiycun-1
      bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
      bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
      bzrlib/plugins/netrc_credential_store/__init__.py __init__.py-20081006090402-hd75m8kcrrm0vlz1-1
      bzrlib/push.py                 push.py-20080606021927-5fe39050e8xne9un-1
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/smart/bzrdir.py         bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
      bzrlib/smart/message.py        message.py-20080222013625-ncqmh3nrxjkxab87-1
      bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
      bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
      bzrlib/tests/branch_implementations/test_create_clone.py test_create_clone.py-20090225031440-8ybpkzojo7cvourv-1
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
      bzrlib/tests/per_repository/test_write_group.py test_write_group.py-20070716105516-89n34xtogq5frn0m-1
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
      bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tests/test_smart_request.py test_smart_request.p-20090211070731-o38wayv3asm25d6a-1
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_source.py    test_source.py-20051207061333-a58dea6abecc030d
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
      bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
      bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
      bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
      bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
      doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
    ------------------------------------------------------------
    revno: 4273.1.16
    revision-id: aaron at aaronbentley.com-20090424143544-h48v6fgl1k6bmxhj
    parent: aaron at aaronbentley.com-20090423160228-gxb9fjel30ihjqm2
    parent: pqm at pqm.ubuntu.com-20090423204730-kcbq9na0n3zs2y3l
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: branch-subtree-locations
    timestamp: Fri 2009-04-24 10:35:44 -0400
    message:
      Merge bzr.dev into branch-subtree-locations.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/_groupcompress_py.py    _groupcompress_py.py-20090324110021-j63s399f4icrgw4p-1
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
      bzrlib/foreign.py              foreign.py-20081112170002-olsxmandkk8qyfuq-1
      bzrlib/groupcompress.py        groupcompress.py-20080705181503-ccbxd6xuy1bdnrpu-8
      bzrlib/hashcache.py            hashcache.py-20050706091756-fe3a8cc1143ff24f
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/lru_cache.py            lru_cache.py-20070119165515-tlw203kuwh0id5gv-1
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
      bzrlib/merge_directive.py      merge_directive.py-20070228184838-ja62280spt1g7f4x-1
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/smart/branch.py         branch.py-20061124031907-mzh3pla28r83r97f-1
      bzrlib/smart/bzrdir.py         bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
      bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
      bzrlib/tests/branch_implementations/test_locking.py test_locking.py-20060707151933-tav3o2hpibwi53u4-4
      bzrlib/tests/branch_implementations/test_parent.py test_parent.py-20050830052751-5e62766623c32222
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
      bzrlib/tests/lock_helpers.py   LockHelpers.py-20060707151933-tav3o2hpibwi53u4-1
      bzrlib/tests/test__groupcompress.py test__groupcompress_-20080724145854-koifwb7749cfzrvj-1
      bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
      bzrlib/tests/test_dirstate.py  test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
      bzrlib/tests/test_foreign.py   test_foreign.py-20081125004048-ywb901edgp9lluxo-1
      bzrlib/tests/test_groupcompress.py test_groupcompress.p-20080705181503-ccbxd6xuy1bdnrpu-13
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
      bzrlib/tests/test_lru_cache.py test_lru_cache.py-20070119165535-hph6rk4h9rzy4180-1
      bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_shelf.py     test_prepare_shelf.p-20081005181341-n74qe6gu1e65ad4v-2
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
      bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
      bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-04-27 22:07:03 +0000
+++ b/bzrlib/builtins.py	2009-04-29 20:31:34 +0000
@@ -5594,6 +5594,53 @@
                    dry_run=dry_run, no_prompt=force)
 
 
+class cmd_reference(Command):
+    """list, view and set branch locations for nested trees.
+
+    If no arguments are provided, lists the branch locations for nested trees.
+    If one argument is provided, display the branch location for that tree.
+    If two arguments are provided, set the branch location for that tree.
+    """
+
+    hidden = True
+
+    takes_args = ['path?', 'location?']
+
+    def run(self, path=None, location=None):
+        branchdir = '.'
+        if path is not None:
+            branchdir = path
+        tree, branch, relpath =(
+            bzrdir.BzrDir.open_containing_tree_or_branch(branchdir))
+        if path is not None:
+            path = relpath
+        if tree is None:
+            tree = branch.basis_tree()
+        if path is None:
+            info = branch._get_all_reference_info().iteritems()
+            self._display_reference_info(tree, branch, info)
+        else:
+            file_id = tree.path2id(path)
+            if file_id is None:
+                raise errors.NotVersionedError(path)
+            if location is None:
+                info = [(file_id, branch.get_reference_info(file_id))]
+                self._display_reference_info(tree, branch, info)
+            else:
+                branch.set_reference_info(file_id, path, location)
+
+    def _display_reference_info(self, tree, branch, info):
+        ref_list = []
+        for file_id, (path, location) in info:
+            try:
+                path = tree.id2path(file_id)
+            except errors.NoSuchId:
+                pass
+            ref_list.append((path, location))
+        for path, location in sorted(ref_list):
+            self.outf.write('%s %s\n' % (path, location))
+
+
 # these get imported and then picked up by the scan for cmd_*
 # TODO: Some more consistent way to split command definitions across files;
 # we do need to load at least some information about them to know of

=== modified file 'bzrlib/reconfigure.py'
--- a/bzrlib/reconfigure.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/reconfigure.py	2009-04-28 20:12:44 +0000
@@ -302,6 +302,7 @@
                 local_branch.set_last_revision_info(*last_revision_info)
             if self._destroy_reference:
                 self.referenced_branch.tags.merge_to(local_branch.tags)
+                self.referenced_branch.update_references(local_branch)
         else:
             local_branch = self.local_branch
         if self._create_reference:

=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py	2009-04-03 16:38:28 +0000
+++ b/bzrlib/tests/blackbox/__init__.py	2009-04-29 20:31:34 +0000
@@ -86,6 +86,7 @@
                      'bzrlib.tests.blackbox.test_push',
                      'bzrlib.tests.blackbox.test_reconcile',
                      'bzrlib.tests.blackbox.test_reconfigure',
+                     'bzrlib.tests.blackbox.test_reference',
                      'bzrlib.tests.blackbox.test_remerge',
                      'bzrlib.tests.blackbox.test_remove',
                      'bzrlib.tests.blackbox.test_re_sign',

=== added file 'bzrlib/tests/blackbox/test_reference.py'
--- a/bzrlib/tests/blackbox/test_reference.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_reference.py	2009-04-30 14:04:38 +0000
@@ -0,0 +1,88 @@
+# Copyright (C) 2009 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+from bzrlib import (
+    branch as _mod_branch,
+    bzrdir,
+    )
+from bzrlib.tests import TestCaseWithTransport
+
+
+class TestReference(TestCaseWithTransport):
+
+    def make_branch(self, location, format=None):
+        if format is None:
+            format = bzrdir.format_registry.make_bzrdir('1.9')
+            format.set_branch_format(_mod_branch.BzrBranchFormat8())
+        return TestCaseWithTransport.make_branch(self, location, format=format)
+
+    def test_no_args_lists(self):
+        branch = self.make_branch('branch')
+        branch.set_reference_info('file-id', 'path', 'http://example.org')
+        branch.set_reference_info('file-id2', 'lath', 'http://example.org/2')
+        out, err = self.run_bzr('reference', working_dir='branch')
+        lines = out.splitlines()
+        self.assertEqual('lath http://example.org/2', lines[0])
+        self.assertEqual('path http://example.org', lines[1])
+
+    def make_tree_with_reference(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/newpath'])
+        tree.add('newpath', 'file-id')
+        tree.branch.set_reference_info('file-id', 'path', 'http://example.org')
+        tree.branch.set_reference_info('file-id2', 'lath',
+                                       'http://example.org/2')
+        return tree
+
+    def test_uses_working_tree_location(self):
+        tree = self.make_tree_with_reference()
+        out, err = self.run_bzr('reference', working_dir='tree')
+        self.assertContainsRe(out, 'newpath http://example.org\n')
+
+    def test_uses_basis_tree_location(self):
+        tree = self.make_tree_with_reference()
+        tree.commit('add newpath')
+        tree.bzrdir.destroy_workingtree()
+        out, err = self.run_bzr('reference', working_dir='tree')
+        self.assertContainsRe(out, 'newpath http://example.org\n')
+
+    def test_one_arg_displays(self):
+        tree = self.make_tree_with_reference()
+        out, err = self.run_bzr('reference newpath', working_dir='tree')
+        self.assertEqual('newpath http://example.org\n', out)
+
+    def test_one_arg_uses_containing_tree(self):
+        tree = self.make_tree_with_reference()
+        out, err = self.run_bzr('reference tree/newpath')
+        self.assertEqual('newpath http://example.org\n', out)
+
+    def test_two_args_sets(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree(['tree/file'])
+        tree.add('file', 'file-id')
+        out, err = self.run_bzr('reference tree/file http://example.org')
+        path, location = tree.branch.get_reference_info('file-id')
+        self.assertEqual('http://example.org', location)
+        self.assertEqual('file', path)
+        self.assertEqual('', out)
+        self.assertEqual('', err)
+
+    def test_missing_file(self):
+        tree = self.make_branch_and_tree('tree')
+        out, err = self.run_bzr('reference file http://example.org',
+                                working_dir='tree', retcode=3)
+        self.assertEqual('bzr: ERROR: file is not versioned.\n', err)

=== modified file 'bzrlib/tests/test_reconfigure.py'
--- a/bzrlib/tests/test_reconfigure.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_reconfigure.py	2009-04-28 20:12:44 +0000
@@ -16,6 +16,7 @@
 
 from bzrlib import (
     branch as _mod_branch,
+    bzrdir,
     errors,
     reconfigure,
     repository,
@@ -417,3 +418,15 @@
             reconfigure.Reconfigure.set_repository_trees, tree.bzrdir, None)
         self.assertContainsRe(str(e),
             r"Requested reconfiguration of '.*' is not supported.")
+
+    def test_lightweight_checkout_to_tree_preserves_reference_locations(self):
+        format = bzrdir.format_registry.make_bzrdir('1.9')
+        format.set_branch_format(_mod_branch.BzrBranchFormat8())
+        tree = self.make_branch_and_tree('tree', format=format)
+        tree.branch.set_reference_info('file_id', 'path', '../location')
+        checkout = tree.branch.create_checkout('checkout', lightweight=True)
+        reconfiguration = reconfigure.Reconfigure.to_tree(checkout.bzrdir)
+        reconfiguration.apply()
+        checkout_branch = checkout.bzrdir.open_branch()
+        self.assertEqual(('path', '../location'),
+                         checkout_branch.get_reference_info('file_id'))




More information about the bazaar-commits mailing list