Exemplo n.º 1
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + '00' * 20 + '\trefs/stash\n'
     refs = InfoRefsContainer(StringIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs['HEAD']
     expected_refs["refs/stash"] = "00" * 20
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 2
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + '00' * 20 + '\trefs/stash\n'
     refs = InfoRefsContainer(StringIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs['HEAD']
     expected_refs["refs/stash"] = "00" * 20
     self.assertEquals(expected_refs, refs.as_dict())
Exemplo n.º 3
0
    def test_keys(self):
        refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        # ignore the symref loop if it exists
        actual_keys.discard("refs/heads/loop")
        expected_refs = dict(_TEST_REFS)
        del expected_refs["HEAD"]
        self.assertEqual(set(expected_refs.iterkeys()), actual_keys)

        actual_keys = refs.keys("refs/heads")
        actual_keys.discard("loop")
        self.assertEqual(["40-char-ref-aaaaaaaaaaaaaaaaaa", "master", "packed"], sorted(actual_keys))
        self.assertEqual(["refs-0.1", "refs-0.2"], sorted(refs.keys("refs/tags")))
Exemplo n.º 4
0
    def test_keys(self):
        refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        # ignore the symref loop if it exists
        actual_keys.discard('refs/heads/loop')
        expected_refs = dict(_TEST_REFS)
        del expected_refs['HEAD']
        self.assertEqual(set(expected_refs.iterkeys()), actual_keys)

        actual_keys = refs.keys('refs/heads')
        actual_keys.discard('loop')
        self.assertEqual(['master', 'packed'], sorted(actual_keys))
        self.assertEqual(['refs-0.1', 'refs-0.2'],
                         sorted(refs.keys('refs/tags')))
Exemplo n.º 5
0
 def __init__(self, transport, bare, refs_text=None):
     self.transport = transport
     self.bare = bare
     try:
         with transport.get(CONTROLDIR) as f:
             path = read_gitfile(f)
     except (ReadError, NoSuchFile):
         if self.bare:
             self._controltransport = self.transport
         else:
             self._controltransport = self.transport.clone('.git')
     else:
         self._controltransport = self.transport.clone(
             urlutils.quote_from_bytes(path))
     commondir = self.get_named_file(COMMONDIR)
     if commondir is not None:
         with commondir:
             commondir = os.path.join(
                 self.controldir(),
                 commondir.read().rstrip(b"\r\n").decode(
                     sys.getfilesystemencoding()))
             self._commontransport = \
                 _mod_transport.get_transport_from_path(commondir)
     else:
         self._commontransport = self._controltransport
     config = self.get_config()
     object_store = TransportObjectStore.from_config(
         self._commontransport.clone(OBJECTDIR),
         config)
     if refs_text is not None:
         refs_container = InfoRefsContainer(BytesIO(refs_text))
         try:
             head = TransportRefsContainer(
                 self._commontransport).read_loose_ref(b"HEAD")
         except KeyError:
             pass
         else:
             refs_container._refs[b"HEAD"] = head
     else:
         refs_container = TransportRefsContainer(
             self._commontransport, self._controltransport)
     super(TransportRepo, self).__init__(object_store,
                                         refs_container)
Exemplo n.º 6
0
    def test_keys(self):
        refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        # ignore the symref loop if it exists
        actual_keys.discard('refs/heads/loop')
        expected_refs = dict(_TEST_REFS)
        del expected_refs['HEAD']
        self.assertEqual(set(expected_refs.iterkeys()), actual_keys)

        actual_keys = refs.keys('refs/heads')
        actual_keys.discard('loop')
        self.assertEqual(['master', 'packed'], sorted(actual_keys))
        self.assertEqual(['refs-0.1', 'refs-0.2'],
                         sorted(refs.keys('refs/tags')))
Exemplo n.º 7
0
 def test_get_peeled(self):
     refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     self.assertEqual(_TEST_REFS['refs/heads/master'],
                      refs.get_peeled('refs/heads/master'))
Exemplo n.º 8
0
 def test_contains(self):
     refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
     self.assertTrue('refs/heads/master' in refs)
     self.assertFalse('refs/heads/bar' in refs)
Exemplo n.º 9
0
 def test_as_dict(self):
     refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     expected_refs = dict(_TEST_REFS)
     del expected_refs['HEAD']
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 10
0
 def test_get_peeled(self):
     refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     self.assertEqual(
         _TEST_REFS['refs/heads/master'],
         refs.get_peeled('refs/heads/master'))
Exemplo n.º 11
0
 def test_as_dict(self):
     refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     expected_refs = dict(_TEST_REFS)
     del expected_refs['HEAD']
     self.assertEqual(expected_refs, refs.as_dict())