~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Robert Collins
  • Date: 2006-01-02 22:37:32 UTC
  • mfrom: (1185.50.33 bzr-jam-integration)
  • Revision ID: robertc@robertcollins.net-20060102223732-d5221b37ff0f7888
Merge in John Meinels integration branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
 
18
import sys
18
19
 
19
20
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
20
21
from bzrlib.clone import copy_branch
22
23
import bzrlib.errors as errors
23
24
from bzrlib.errors import NoSuchRevision, UnlistableBranch, NotBranchError
24
25
import bzrlib.gpg
 
26
from bzrlib.osutils import getcwd
25
27
from bzrlib.tests import TestCase, TestCaseInTempDir
26
28
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
27
29
from bzrlib.trace import mutter
49
51
        os.mkdir('b2')
50
52
        b1 = Branch.initialize('b1')
51
53
        b2 = Branch.initialize('b2')
52
 
        file(os.sep.join(['b1', 'foo']), 'w').write('hello')
 
54
        file('b1/foo', 'w').write('hello')
53
55
        b1.working_tree().add(['foo'], ['foo-id'])
54
56
        b1.working_tree().commit('lala!', rev_id='revision-1', allow_pointless=False)
55
57
 
374
376
        self.assertEqual(None, self.branch.get_push_location())
375
377
 
376
378
    def test_get_push_location_exact(self):
377
 
        self.build_tree(['.bazaar/'])
378
 
        print >> open('.bazaar/branches.conf', 'wt'), ("[%s]\n"
379
 
                                                       "push_location=foo" %
380
 
                                                       os.getcwdu())
 
379
        from bzrlib.config import (branches_config_filename,
 
380
                                   ensure_config_dir_exists)
 
381
        ensure_config_dir_exists()
 
382
        fn = branches_config_filename()
 
383
        print >> open(fn, 'wt'), ("[%s]\n"
 
384
                                  "push_location=foo" %
 
385
                                  getcwd())
381
386
        self.assertEqual("foo", self.branch.get_push_location())
382
387
 
383
388
    def test_set_push_location(self):
 
389
        from bzrlib.config import (branches_config_filename,
 
390
                                   ensure_config_dir_exists)
 
391
        ensure_config_dir_exists()
 
392
        fn = branches_config_filename()
384
393
        self.branch.set_push_location('foo')
385
394
        self.assertFileEqual("[%s]\n"
386
 
                             "push_location = foo" % os.getcwdu(),
387
 
                             '.bazaar/branches.conf')
 
395
                             "push_location = foo" % getcwd(),
 
396
                             fn)
388
397
 
389
398
    # TODO RBC 20051029 test getting a push location from a branch in a 
390
399
    # recursive section - that is, it appends the branch name.