Exemple #1
0
 def test_unchanged(self):
     b = Blob.from_string(b'b')
     delta = self.transform([('unchanged', (b'a', stat.S_IFREG | 0o644, b),
                              (b'a', stat.S_IFREG | 0o644, b))])
     expected_delta = TreeDelta()
     expected_delta.unchanged.append(
         TreeChange(b'git:a', ('a', 'a'), False, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'),
                    ('file', 'file'), (False, False), False))
Exemple #2
0
 def test_add(self):
     b = Blob.from_string(b'b')
     self.assertEqual([
         TreeChange(b'git:a', (None, 'a'), True, (False, True),
                    (None, b'TREE_ROOT'), (None, 'a'), (None, 'file'),
                    (None, False), False)
     ],
                      self.transform([('add', (None, None, None),
                                       (b'a', stat.S_IFREG | 0o644, b))]))
Exemple #3
0
 def test_rename_no_changes(self):
     a = Blob.from_string(b'a')
     self.assertEqual([
         TreeChange(b'git:old', ('old', 'a'), False, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('old', 'a'),
                    ('file', 'file'), (False, False), False)
     ],
                      self.transform([('rename', (b'old',
                                                  stat.S_IFREG | 0o644, a),
                                       (b'a', stat.S_IFREG | 0o644, a))]))
Exemple #4
0
 def test_delete(self):
     b = Blob.from_string(b'b')
     delta = self.transform([('remove', (b'a', stat.S_IFREG | 0o644, b),
                              (None, None, None))])
     expected_delta = TreeDelta()
     expected_delta.removed.append(
         TreeChange(b'git:a', ('a', None), True, (True, False),
                    (b'TREE_ROOT', None), ('a', None), ('file', None),
                    (False, None), False))
     self.assertEqual(delta, expected_delta)
Exemple #5
0
 def test_copy_no_changes(self):
     a = Blob.from_string(b'a')
     delta = self.transform([('copy', (b'old', stat.S_IFREG | 0o644, a),
                              (b'a', stat.S_IFREG | 0o644, a))])
     expected_delta = TreeDelta()
     expected_delta.copied.append(
         TreeChange(b'git:a', ('old', 'a'), False, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('old', 'a'),
                    ('file', 'file'), (False, False), True))
     self.assertEqual(expected_delta, delta)
Exemple #6
0
 def test_delete(self):
     b = Blob.from_string(b'b')
     self.assertEqual([
         TreeChange(b'git:a', ('a', None), True, (True, False),
                    (b'TREE_ROOT', None), ('a', None), ('file', None),
                    (False, None), False)
     ],
                      self.transform([('remove', (b'a',
                                                  stat.S_IFREG | 0o644, b),
                                       (None, None, None))]))
Exemple #7
0
 def test_rename_and_modify(self):
     a = Blob.from_string(b'a')
     b = Blob.from_string(b'b')
     self.assertEqual([
         TreeChange(b'git:a', ('a', 'b'), True, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'b'),
                    ('file', 'file'), (False, False), False)
     ],
                      self.transform([('rename', (b'a',
                                                  stat.S_IFREG | 0o644, a),
                                       (b'b', stat.S_IFREG | 0o644, b))]))
Exemple #8
0
 def test_kind_changed(self):
     a = Blob.from_string(b'a')
     b = Blob.from_string(b'target')
     self.assertEqual([
         TreeChange(b'git:a', ('a', 'a'), True, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'),
                    ('file', 'symlink'), (False, False), False)
     ],
                      self.transform([('modify', (b'a',
                                                  stat.S_IFREG | 0o644, a),
                                       (b'a', stat.S_IFLNK, b))]))
Exemple #9
0
 def test_kind_change(self):
     a = Blob.from_string(b'a')
     b = Blob.from_string(b'target')
     delta = self.transform([('modify', (b'a', stat.S_IFREG | 0o644, a),
                              (b'a', stat.S_IFLNK, b))])
     expected_delta = TreeDelta()
     expected_delta.kind_changed.append(
         TreeChange(b'git:a', ('a', 'a'), True, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'),
                    ('file', 'symlink'), (False, False), False))
     self.assertEqual(expected_delta, delta)
Exemple #10
0
 def test_rename_and_modify(self):
     a = Blob.from_string(b'a')
     b = Blob.from_string(b'b')
     delta = self.transform([('rename', (b'a', stat.S_IFREG | 0o644, a),
                              (b'b', stat.S_IFREG | 0o644, b))])
     expected_delta = TreeDelta()
     expected_delta.renamed.append(
         TreeChange(b'git:a', ('a', 'b'), True, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'b'),
                    ('file', 'file'), (False, False), False))
     self.assertEqual(delta, expected_delta)
Exemple #11
0
 def test_unversioned(self):
     b = Blob.from_string(b'b')
     self.assertEqual([
         TreeChange(None, (None, 'a'), True, (False, False),
                    (None, b'TREE_ROOT'), (None, 'a'), (None, 'file'),
                    (None, False), False)
     ],
                      self.transform([('add', (None, None, None),
                                       (b'a', stat.S_IFREG | 0o644, b))],
                                     target_extras=set([b'a'])))
     self.assertEqual([
         TreeChange(None, ('a', 'a'), False, (False, False),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'),
                    ('file', 'file'), (False, False), False)
     ],
                      self.transform([('add',
                                       (b'a', stat.S_IFREG | 0o644, b),
                                       (b'a', stat.S_IFREG | 0o644, b))],
                                     source_extras=set([b'a']),
                                     target_extras=set([b'a'])))
Exemple #12
0
 def test_unversioned(self):
     b = Blob.from_string(b'b')
     delta = self.transform([('add', (None, None, None),
                              (b'a', stat.S_IFREG | 0o644, b))],
                            target_extras=set([b'a']))
     expected_delta = TreeDelta()
     expected_delta.unversioned.append(
         TreeChange(None, (None, 'a'), True, (False, False),
                    (None, b'TREE_ROOT'), (None, 'a'), (None, 'file'),
                    (None, False), False))
     self.assertEqual(delta, expected_delta)
     delta = self.transform([('add', (b'a', stat.S_IFREG | 0o644, b),
                              (b'a', stat.S_IFREG | 0o644, b))],
                            source_extras=set([b'a']),
                            target_extras=set([b'a']))
     expected_delta = TreeDelta()
     expected_delta.unversioned.append(
         TreeChange(None, ('a', 'a'), False, (False, False),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'),
                    ('file', 'file'), (False, False), False))
     self.assertEqual(delta, expected_delta)
Exemple #13
0
 def test_unchanged(self):
     b = Blob.from_string(b'b')
     self.assertEqual([
         TreeChange(b'git:a', ('a', 'a'), False, (True, True),
                    (b'TREE_ROOT', b'TREE_ROOT'), ('a', 'a'),
                    ('file', 'file'), (False, False), False)
     ],
                      self.transform([('unchanged',
                                       (b'a', stat.S_IFREG | 0o644, b),
                                       (b'a', stat.S_IFREG | 0o644, b))],
                                     include_unchanged=True))
     self.assertEqual([],
                      self.transform([('unchanged',
                                       (b'a', stat.S_IFREG | 0o644, b),
                                       (b'a', stat.S_IFREG | 0o644, b))],
                                     include_unchanged=False))