~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

  • Committer: Alexander Belchenko
  • Date: 2012-03-29 08:34:13 UTC
  • mto: (6015.44.14 2.4)
  • mto: This revision was merged to the branch mainline in revision 6513.
  • Revision ID: bialix@ukr.net-20120329083413-d4bqqdtfn2yrxp4f
change st_dev, st_ino, st_uid, st_gid from int members to properties.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    bzrdir,
19
19
    errors,
20
20
    osutils,
21
 
    revision as _mod_revision,
22
21
    versionedfile,
23
22
    )
24
23
from bzrlib.branch import Branch
36
35
def has_revision(branch, revision_id):
37
36
    return branch.repository.has_revision(revision_id)
38
37
 
39
 
 
40
 
def revision_history(branch):
41
 
    branch.lock_read()
42
 
    try:
43
 
        graph = branch.repository.get_graph()
44
 
        history = list(graph.iter_lefthand_ancestry(branch.last_revision(),
45
 
            [_mod_revision.NULL_REVISION]))
46
 
    finally:
47
 
        branch.unlock()
48
 
    history.reverse()
49
 
    return history
50
 
 
51
 
 
52
38
def fetch_steps(self, br_a, br_b, writable_a):
53
39
    """A foreign test method for testing fetch locally and remotely."""
54
40
 
55
41
    # TODO RBC 20060201 make this a repository test.
56
42
    repo_b = br_b.repository
57
 
    self.assertFalse(repo_b.has_revision(revision_history(br_a)[3]))
58
 
    self.assertTrue(repo_b.has_revision(revision_history(br_a)[2]))
59
 
    self.assertEquals(len(revision_history(br_b)), 7)
60
 
    br_b.fetch(br_a, revision_history(br_a)[2])
 
43
    self.assertFalse(repo_b.has_revision(br_a.revision_history()[3]))
 
44
    self.assertTrue(repo_b.has_revision(br_a.revision_history()[2]))
 
45
    self.assertEquals(len(br_b.revision_history()), 7)
 
46
    br_b.fetch(br_a, br_a.revision_history()[2])
61
47
    # branch.fetch is not supposed to alter the revision history
62
 
    self.assertEquals(len(revision_history(br_b)), 7)
63
 
    self.assertFalse(repo_b.has_revision(revision_history(br_a)[3]))
 
48
    self.assertEquals(len(br_b.revision_history()), 7)
 
49
    self.assertFalse(repo_b.has_revision(br_a.revision_history()[3]))
64
50
 
65
51
    # fetching the next revision up in sample data copies one revision
66
 
    br_b.fetch(br_a, revision_history(br_a)[3])
67
 
    self.assertTrue(repo_b.has_revision(revision_history(br_a)[3]))
68
 
    self.assertFalse(has_revision(br_a, revision_history(br_b)[6]))
69
 
    self.assertTrue(br_a.repository.has_revision(revision_history(br_b)[5]))
 
52
    br_b.fetch(br_a, br_a.revision_history()[3])
 
53
    self.assertTrue(repo_b.has_revision(br_a.revision_history()[3]))
 
54
    self.assertFalse(has_revision(br_a, br_b.revision_history()[6]))
 
55
    self.assertTrue(br_a.repository.has_revision(br_b.revision_history()[5]))
70
56
 
71
57
    # When a non-branch ancestor is missing, it should be unlisted...
72
58
    # as its not reference from the inventory weave.
74
60
    br_b4.fetch(br_b)
75
61
 
76
62
    writable_a.fetch(br_b)
77
 
    self.assertTrue(has_revision(br_a, revision_history(br_b)[3]))
78
 
    self.assertTrue(has_revision(br_a, revision_history(br_b)[4]))
 
63
    self.assertTrue(has_revision(br_a, br_b.revision_history()[3]))
 
64
    self.assertTrue(has_revision(br_a, br_b.revision_history()[4]))
79
65
 
80
66
    br_b2 = self.make_branch('br_b2')
81
67
    br_b2.fetch(br_b)
82
 
    self.assertTrue(has_revision(br_b2, revision_history(br_b)[4]))
83
 
    self.assertTrue(has_revision(br_b2, revision_history(br_a)[2]))
84
 
    self.assertFalse(has_revision(br_b2, revision_history(br_a)[3]))
 
68
    self.assertTrue(has_revision(br_b2, br_b.revision_history()[4]))
 
69
    self.assertTrue(has_revision(br_b2, br_a.revision_history()[2]))
 
70
    self.assertFalse(has_revision(br_b2, br_a.revision_history()[3]))
85
71
 
86
72
    br_a2 = self.make_branch('br_a2')
87
73
    br_a2.fetch(br_a)
88
 
    self.assertTrue(has_revision(br_a2, revision_history(br_b)[4]))
89
 
    self.assertTrue(has_revision(br_a2, revision_history(br_a)[3]))
90
 
    self.assertTrue(has_revision(br_a2, revision_history(br_a)[2]))
 
74
    self.assertTrue(has_revision(br_a2, br_b.revision_history()[4]))
 
75
    self.assertTrue(has_revision(br_a2, br_a.revision_history()[3]))
 
76
    self.assertTrue(has_revision(br_a2, br_a.revision_history()[2]))
91
77
 
92
78
    br_a3 = self.make_branch('br_a3')
93
79
    # pulling a branch with no revisions grabs nothing, regardless of
95
81
    br_a3.fetch(br_a2)
96
82
    for revno in range(4):
97
83
        self.assertFalse(
98
 
            br_a3.repository.has_revision(revision_history(br_a)[revno]))
99
 
    br_a3.fetch(br_a2, revision_history(br_a)[2])
 
84
            br_a3.repository.has_revision(br_a.revision_history()[revno]))
 
85
    br_a3.fetch(br_a2, br_a.revision_history()[2])
100
86
    # pull the 3 revisions introduced by a@u-0-3
101
 
    br_a3.fetch(br_a2, revision_history(br_a)[3])
 
87
    br_a3.fetch(br_a2, br_a.revision_history()[3])
102
88
    # NoSuchRevision should be raised if the branch is missing the revision
103
89
    # that was requested.
104
90
    self.assertRaises(errors.NoSuchRevision, br_a3.fetch, br_a2, 'pizza')