/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testmerge.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:
 
1
import os
 
2
 
 
3
from bzrlib.branch import Branch
 
4
from bzrlib.commit import commit
 
5
from bzrlib.selftest import TestCaseInTempDir
 
6
from bzrlib.merge import merge
 
7
from bzrlib.errors import UnrelatedBranches, NoCommits
 
8
from bzrlib.revision import common_ancestor
 
9
from bzrlib.fetch import fetch
 
10
 
 
11
 
 
12
class TestMerge(TestCaseInTempDir):
 
13
    """Test appending more than one revision"""
 
14
    def test_pending(self):
 
15
        br = Branch.initialize(".")
 
16
        commit(br, "lala!")
 
17
        self.assertEquals(len(br.pending_merges()), 0)
 
18
        merge(['.', -1], [None, None])
 
19
        self.assertEquals(len(br.pending_merges()), 0)
 
20
 
 
21
    def test_nocommits(self):
 
22
        self.test_pending()
 
23
        os.mkdir('branch2')
 
24
        br2 = Branch.initialize('branch2')
 
25
        self.assertRaises(NoCommits, merge, ['branch2', -1], 
 
26
                          [None, None])
 
27
        return br2
 
28
 
 
29
    def test_unrelated(self):
 
30
        br2 = self.test_nocommits()
 
31
        commit(br2, "blah")
 
32
        self.assertRaises(UnrelatedBranches, merge, ['branch2', -1], 
 
33
                          [None, None])
 
34
        return br2
 
35
 
 
36
    def test_pending_with_null(self):
 
37
        """When base is forced to revno 0, pending_merges is set"""
 
38
        br2 = self.test_unrelated()
 
39
        br1 = Branch.open('.')
 
40
        fetch(from_branch=br2, to_branch=br1)
 
41
        # merge all of branch 2 into branch 1 even though they 
 
42
        # are not related.
 
43
        merge(['branch2', -1], ['branch2', 0])
 
44
        self.assertEquals(len(br1.pending_merges()), 1)
 
45
        return (br1, br2)
 
46
 
 
47
    def test_two_roots(self):
 
48
        """Merge base is sane when two unrelated branches are merged"""
 
49
        br1, br2 = self.test_pending_with_null()
 
50
        commit(br1, "blah")
 
51
        last = br1.last_revision()
 
52
        self.assertEquals(common_ancestor(last, last, br1), last)