Example #1
0
 def test_eq(self):
     format1 = HgControlDirFormat()
     format2 = HgControlDirFormat()
     self.assertEquals(format1, format2)
     self.assertEquals(format1, format1)
     bzr_format = format_registry.make_controldir("default")
     self.assertNotEquals(bzr_format, format1)
Example #2
0
    def probe_transport(self, transport):
        try:
            external_url = transport.external_url()
        except errors.InProcessTransport:
            raise errors.NotBranchError(path=transport.base)
        scheme = external_url.split(":")[0]
        if scheme not in self._supported_schemes:
            raise errors.NotBranchError(path=transport.base)
        from breezy import urlutils
        external_url = urlutils.split_segment_parameters(external_url)[0]
        # Explicitly check for .hg directories here, so we avoid
        # loading foreign branches through Mercurial.
        if (external_url.startswith("http:")
                or external_url.startswith("https:")):
            if not has_hg_http_smart_server(transport, external_url):
                raise errors.NotBranchError(path=transport.base)
        else:
            if not has_hg_dumb_repository(transport):
                raise errors.NotBranchError(path=transport.base)

        lazy_load_mercurial()
        from mercurial import error as hg_errors

        import urllib2
        from breezy.plugins.hg.dir import HgControlDirFormat
        format = HgControlDirFormat()
        try:
            format.open(transport)
        except hg_errors.RepoError, e:
            raise errors.NotBranchError(path=transport.base)
Example #3
0
    def test_recursive_removing_of_empty_directories(self):
        # Create files in directory of Mercurial repository.
        self.build_tree([
            "hg/",
            "hg/f1",
            "hg/d1/",
            "hg/d1/d2/",
            "hg/d1/d2/f2",
        ])

        # Create Mercurial repository itself and fill it's history.
        hgrepo = mercurial.localrepo.localrepository(hgui(), "hg", create=True)
        hgrepo[None].add(["f1", "d1/d2/f2"])
        hgrepo.commit("Initial commit")
        hgrepo[None].forget(["d1/d2/f2"])
        os.unlink("hg/d1/d2/f2")
        hgrepo.commit("Remove file f2, so parent directories d2, d1 are empty")

        # Import history from Mercurial repository into Bazaar repository.
        bzrtree = self.make_branch_and_tree("bzr")
        hgdir = HgControlDirFormat().open(self.get_transport("hg"))
        bzrtree.pull(hgdir.open_branch())

        # As file f2 was deleted, directories d1 and d2 should not exists.
        self.assertPathDoesNotExist("bzr/d1")

        # Self-assurance check that history was really imported.
        self.assertPathExists("bzr/f1")
Example #4
0
 def test_tags(self):
     tree = self.make_branch_and_tree(".", format=HgControlDirFormat())
     self.build_tree_contents([
         (".hgtags", "4ad63131870d4fbf2a88d7403705310b2d0b9b76 v0.1\n")
     ])
     tree.add([".hgtags"])
     tree.commit("add tags")
     tags = FileHgTags(tree.branch, tree.branch.last_revision(),
                       tree.branch)
     self.assertEquals(
         {u"v0.1": "hg-v1:4ad63131870d4fbf2a88d7403705310b2d0b9b76"},
         tags.get_tag_dict())
Example #5
0
 def _matchingcontroldir(self):
     from breezy.plugins.hg.dir import HgControlDirFormat
     return HgControlDirFormat()
Example #6
0
 def test_no_tags_file(self):
     branch = self.make_branch(".", format=HgControlDirFormat())
     tags = FileHgTags(branch, branch.last_revision(), branch)
     self.assertEquals({}, tags.get_tag_dict())
Example #7
0
 def make_empty_branch(self, transport):
     return HgControlDirFormat().initialize_on_transport(
         transport).open_branch()
Example #8
0
 def test_network_name(self):
     format = HgControlDirFormat()
     self.assertEquals("hg", format.network_name())
Example #9
0
 def test_hash(self):
     format1 = HgControlDirFormat()
     format2 = HgControlDirFormat()
     self.assertEquals(hash(format1), hash(format2))
     bzr_format = format_registry.make_controldir("default")
     self.assertNotEquals(hash(bzr_format), hash(format1))
Example #10
0
 def make_repository(self, transport):
     controldir = HgControlDirFormat().initialize_on_transport(transport)
     return controldir.open_repository()
Example #11
0
 def known_formats(cls):
     from breezy.plugins.hg.dir import HgControlDirFormat
     return [HgControlDirFormat()]
Example #12
0
 def setUp(self):
     super(TestPulling, self).setUp()
     self.build_tree(['hg/', 'hg/a', 'hg/b', 'hg/dir/', 'hg/dir/c'])
     hgdir = HgControlDirFormat().initialize('hg')
     self.tree = hgdir.open_workingtree()
     mode = os.lstat('hg/b').st_mode
     os.chmod('hg/b', mode | stat.S_IEXEC)
     # do not add 'dir' to ensure that we pickup dir/c anyway : if hg
     # changes it behaviour, we want this test to start failing.
     self.tree.add(['a', 'b', 'dir/c'])
     self.tree.commit('foo')
     revone_inventory = Inventory()
     tip = self.tree.last_revision()
     revone_inventory.root.revision = tip
     entry = revone_inventory.add_path(u'a', kind='file', file_id='hg:a')
     entry.revision = tip
     entry.text_size = len('contents of hg/a\n')
     entry.text_sha1 = "72bcea9d6cba6ee7d3241bfa0c5e54506ad81a94"
     entry = revone_inventory.add_path(u'b', kind='file', file_id='hg:b')
     entry.executable = True
     entry.revision = tip
     entry.text_size = len('contents of hg/b\n')
     entry.text_sha1 = "b4d0c22d126cd0afeeeffa62961fb47c0932835a"
     entry = revone_inventory.add_path(u'dir',
                                       kind='directory',
                                       file_id='hg:dir')
     entry.revision = tip
     entry = revone_inventory.add_path(u'dir/c',
                                       kind='file',
                                       file_id='hg:dir_sc')
     entry.revision = tip
     entry.text_size = len('contents of hg/dir/c\n')
     entry.text_sha1 = "958be752affac0fee70471331b96fb3fc1809425"
     self.revone_inventory = revone_inventory
     self.revidone = tip
     #====== end revision one
     # in revisiontwo we add a new file to dir, which should not change
     # the revision_id on the inventory.
     self.build_tree(['hg/dir/d'])
     self.tree.add(['dir/d'])
     self.tree.commit('bar')
     self.revtwo_inventory = copy.deepcopy(revone_inventory)
     tip = self.tree.last_revision()
     entry = self.revtwo_inventory.add_path(u'dir/d',
                                            kind='file',
                                            file_id='hg:dir_sd')
     entry.revision = tip
     entry.text_size = len('contents of hg/dir/d\n')
     entry.text_sha1 = "f48fc342f707bfb4711790e1813c0df4d44e1a23"
     self.revidtwo = tip
     #====== end revision two
     # in revision three, we reset the exec flag on 'b'
     os.chmod('hg/b', mode)
     self.tree.commit('reset mode on b')
     self.revthree_inventory = copy.deepcopy(self.revtwo_inventory)
     tip = self.tree.last_revision()
     # should be a new file revision with exec reset
     entry = self.revthree_inventory.get_entry('hg:b')
     entry.revision = tip
     entry.executable = False
     self.revidthree = tip
     #====== end revision three
     # in revision four we change the file dir/c, which should not alter
     # the last-changed field for 'dir'.
     self.build_tree_contents([('hg/dir/c', 'new contents')])
     self.tree.commit('change dir/c')
     self.revfour_inventory = copy.deepcopy(self.revthree_inventory)
     tip = self.tree.last_revision()
     entry = self.revfour_inventory.get_entry('hg:dir_sc')
     entry.revision = tip
     entry.text_size = len('new contents')
     entry.text_sha1 = "7ffa72b76d5d66da37f4b614b7a822c01f23c183"
     self.revidfour = tip