~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testconfig.py

  • Committer: Robert Collins
  • Date: 2005-10-29 23:48:45 UTC
  • Revision ID: robertc@robertcollins.net-20051029234845-7ae4e7d118bdd3ed
Implement a 'bzr push' command, with saved locations; update diff to return 1.

    * 'bzr diff' now returns 1 when there are changes in the working 
      tree.

    * 'bzr push' now exists and can push changes to a remote location. 
      This uses the transport infrastructure, and can store the remote
      location in the ~/.bazaar/branches.conf configuration file.

    * WorkingTree.pull has been split across Branch and WorkingTree,
      to allow Branch only pulls.

    * commands.display_command now returns the result of the decorated 
      function.

    * LocationConfig now has a set_user_option(key, value) call to save
      a setting in its matching location section (a new one is created
      if needed).

    * Branch has two new methods, get_push_location and set_push_location
      to respectively, get and set the push location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
class InstrumentedConfigObj(object):
74
74
    """A config obj look-enough-alike to record calls made to it."""
75
75
 
 
76
    def __contains__(self, thing):
 
77
        self._calls.append(('__contains__', thing))
 
78
        return False
 
79
 
 
80
    def __getitem__(self, key):
 
81
        self._calls.append(('__getitem__', key))
 
82
        return self
 
83
 
76
84
    def __init__(self, input):
77
85
        self._calls = [('__init__', input)]
78
86
 
 
87
    def __setitem__(self, key, value):
 
88
        self._calls.append(('__setitem__', key, value))
 
89
 
 
90
    def write(self):
 
91
        self._calls.append(('write',))
 
92
 
79
93
 
80
94
class FakeBranch(object):
81
95
 
458
472
        self.assertEqual('bzrlib.selftest.testconfig.post_commit',
459
473
                         self.my_config.post_commit())
460
474
 
 
475
    def test_set_user_setting_sets_and_saves(self):
 
476
        # TODO RBC 20051029 test hat mkdir ~/.bazaar is called ..
 
477
        self.get_location_config('/a/c')
 
478
        record = InstrumentedConfigObj("foo")
 
479
        self.my_config._parser = record
 
480
        self.my_config.set_user_option('foo', 'bar')
 
481
        self.assertEqual([('__contains__', '/a/c'),
 
482
                          ('__contains__', '/a/c/'),
 
483
                          ('__setitem__', '/a/c', {}),
 
484
                          ('__getitem__', '/a/c'),
 
485
                          ('__setitem__', 'foo', 'bar'),
 
486
                          ('write',)],
 
487
                         record._calls[1:])
 
488
 
461
489
 
462
490
class TestBranchConfigItems(TestCase):
463
491