51
61
self.assertTrue(self.tree.is_versioned('a'))
52
62
self.tree.revert(['a'])
53
63
self.assertFalse(self.tree.is_versioned('a'))
66
class ChangesBetweenGitTreeAndWorkingCopyTests(TestCaseWithTransport):
69
super(ChangesBetweenGitTreeAndWorkingCopyTests, self).setUp()
70
self.wt = self.make_branch_and_tree('.', format='git')
72
def expectDelta(self, expected_changes,
73
expected_extras=None, want_unversioned=False):
74
store = self.wt.branch.repository._git.object_store
76
tree_id = store[self.wt.branch.repository._git.head()].tree
79
changes, extras = changes_between_git_tree_and_working_copy(
80
store, tree_id, self.wt, want_unversioned=want_unversioned)
81
self.assertEqual(expected_changes, list(changes))
82
if expected_extras is None:
83
expected_extras = set()
84
self.assertEqual(set(expected_extras), set(extras))
88
[((None, ''), (None, stat.S_IFDIR), (None, Tree().id))])
90
def test_added_file(self):
91
self.build_tree(['a'])
93
a = Blob.from_string('contents of a\n')
95
t.add("a", stat.S_IFREG | 0o644, a.id)
97
[((None, ''), (None, stat.S_IFDIR), (None, t.id)),
98
((None, 'a'), (None, stat.S_IFREG | 0o644), (None, a.id))])
100
def test_added_unknown_file(self):
101
self.build_tree(['a'])
104
[((None, ''), (None, stat.S_IFDIR), (None, t.id))])
105
a = Blob.from_string('contents of a\n')
107
t.add("a", stat.S_IFREG | 0o644, a.id)
109
[((None, ''), (None, stat.S_IFDIR), (None, t.id)),
110
((None, 'a'), (None, stat.S_IFREG | 0o644), (None, a.id))],
112
want_unversioned=True)
114
def test_missing_added_file(self):
115
self.build_tree(['a'])
118
a = Blob.from_string('contents of a\n')
120
t.add("a", 0, ZERO_SHA)
122
[((None, ''), (None, stat.S_IFDIR), (None, t.id)),
123
((None, 'a'), (None, 0), (None, ZERO_SHA))],
126
def test_missing_versioned_file(self):
127
self.build_tree(['a'])
131
a = Blob.from_string('contents of a\n')
133
oldt.add("a", stat.S_IFREG | 0o644, a.id)
135
newt.add("a", 0, ZERO_SHA)
137
[(('', ''), (stat.S_IFDIR, stat.S_IFDIR), (oldt.id, newt.id)),
138
(('a', 'a'), (stat.S_IFREG|0o644, 0), (a.id, ZERO_SHA))])
140
def test_versioned_replace_by_dir(self):
141
self.build_tree(['a'])
146
olda = Blob.from_string('contents of a\n')
148
oldt.add("a", stat.S_IFREG | 0o644, olda.id)
151
newt.add("a", stat.S_IFDIR, newa.id)
154
(stat.S_IFDIR, stat.S_IFDIR),
156
(('a', 'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
157
], want_unversioned=False)
160
(stat.S_IFDIR, stat.S_IFDIR),
162
(('a', 'a'), (stat.S_IFREG | 0o644, stat.S_IFDIR), (olda.id, newa.id))
163
], want_unversioned=True)
165
def test_extra(self):
166
self.build_tree(['a'])
167
newa = Blob.from_string('contents of a\n')
169
newt.add("a", stat.S_IFREG | 0o644, newa.id)
172
(None, stat.S_IFDIR),
174
((None, 'a'), (None, stat.S_IFREG | 0o644), (None, newa.id))
175
], ['a'], want_unversioned=True)