示例#1
0
    def test_checkout_specific_version_and_update(self):
        from vcstools.hg import HgClient
        directory = tempfile.mkdtemp()
        subdir = "checkout_specific_version_test"
        self.directories[subdir] = directory
        local_path = os.path.join(directory, "anyvc")
        url = self.readonly_url
        version = self.readonly_version
        client = HgClient(local_path)
        self.assertFalse(client.path_exists())
        self.assertFalse(client.detect_presence())
        self.assertFalse(client.detect_presence())
        self.assertTrue(client.checkout(url, version))
        self.assertTrue(client.path_exists())
        self.assertTrue(client.detect_presence())
        self.assertEqual(client.get_path(), local_path)
        self.assertEqual(client.get_url(), url)
        self.assertEqual(client.get_version(), version)

        new_version = self.readonly_version_second
        self.assertTrue(client.update(new_version))
        self.assertEqual(client.get_version(), new_version)

        shutil.rmtree(directory)
        self.directories.pop(subdir)
示例#2
0
    def test_checkout_specific_version_and_update(self):
        url = self.local_url
        version = self.local_version
        client = HgClient(self.local_path)
        self.assertFalse(client.path_exists())
        self.assertFalse(client.detect_presence())
        self.assertFalse(client.detect_presence())
        self.assertTrue(client.checkout(url, version))
        self.assertTrue(client.path_exists())
        self.assertTrue(client.detect_presence())
        self.assertEqual(client.get_path(), self.local_path)
        self.assertEqual(client.get_url(), url)
        self.assertEqual(client.get_version(), version)

        new_version = self.local_version_second
        self.assertTrue(client.update(new_version))
        self.assertEqual(client.get_version(), new_version)

        self.assertTrue(client.update())
        self.assertEqual(client.get_version(), self.local_version)

        self.assertTrue(client.update(new_version))
        self.assertEqual(client.get_version(), new_version)

        self.assertTrue(client.update(''))
        self.assertEqual(client.get_version(), self.local_version)
示例#3
0
    def test_checkout_specific_version_and_update(self):
        url = self.local_url
        version = self.local_version
        client = HgClient(self.local_path)
        self.assertFalse(client.path_exists())
        self.assertFalse(client.detect_presence())
        self.assertFalse(client.detect_presence())
        self.assertTrue(client.checkout(url, version))
        self.assertTrue(client.path_exists())
        self.assertTrue(client.detect_presence())
        self.assertEqual(client.get_path(), self.local_path)
        self.assertEqual(client.get_url(), url)
        self.assertEqual(client.get_version(), version)

        new_version = self.local_version_second
        self.assertTrue(client.update(new_version))
        self.assertEqual(client.get_version(), new_version)

        self.assertTrue(client.update())
        self.assertEqual(client.get_version(), self.local_version)

        self.assertTrue(client.update(new_version))
        self.assertEqual(client.get_version(), new_version)

        self.assertTrue(client.update(''))
        self.assertEqual(client.get_version(), self.local_version)
 def test_checkout_specific_version_and_update(self):
     from vcstools.hg import HgClient
     directory = tempfile.mkdtemp()
     subdir = "checkout_specific_version_test"
     self.directories[subdir] = directory
     local_path = os.path.join(directory, "anyvc")
     url = self.readonly_url
     version = self.readonly_version
     client = HgClient(local_path)
     self.assertFalse(client.path_exists())
     self.assertFalse(client.detect_presence())
     self.assertFalse(client.detect_presence())
     self.assertTrue(client.checkout(url, version))
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_path(), local_path)
     self.assertEqual(client.get_url(), url)
     self.assertEqual(client.get_version(), version)
     
     new_version = self.readonly_version_second
     self.assertTrue(client.update(new_version))
     self.assertEqual(client.get_version(), new_version)
     
     shutil.rmtree(directory)
     self.directories.pop(subdir)
示例#5
0
    def test_get_remote_version(self):
        url = self.local_url
        version = self.local_version
        client = HgClient(self.local_path)
        client.checkout(url, version='default')
        self.assertEqual(client.get_remote_version(fetch=True),
                         self.local_version)
        self.assertEqual(client.get_version(), self.local_version)

        for cmd in [
                "hg checkout default", "touch remote_new.txt",
                "hg add remote_new.txt", "hg commit -m remote_new"
        ]:
            subprocess.check_call(cmd, shell=True, cwd=self.remote_path)
        po = subprocess.Popen("hg log --template '{node|short}' -l1",
                              shell=True,
                              cwd=self.remote_path,
                              stdout=subprocess.PIPE)
        remote_new_version = po.stdout.read().decode('UTF-8').rstrip(
            "'").lstrip("'")
        self.assertNotEqual(self.local_version, remote_new_version)

        self.assertEqual(client.get_remote_version(fetch=False),
                         self.local_version)
        self.assertEqual(client.get_remote_version(fetch=True),
                         remote_new_version)
        self.assertEqual(client.get_remote_version(fetch=False),
                         remote_new_version)
        self.assertEqual(client.get_version(), self.local_version)
 def test_get_url_by_reading(self):
     from vcstools.hg import HgClient
     client = HgClient(self.readonly_path)
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_url(), self.readonly_url)
     self.assertEqual(client.get_version(), self.readonly_version)
     self.assertEqual(client.get_version(self.readonly_version_init[0:6]), self.readonly_version_init+'+')
     self.assertEqual(client.get_version("test_tag"), self.readonly_version_init+'+')
示例#7
0
 def test_get_url_by_reading(self):
     url = self.local_url
     client = HgClient(self.local_path)
     client.checkout(url, self.local_version)
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_url(), self.local_url)
     self.assertEqual(client.get_version(), self.local_version)
     self.assertEqual(client.get_version(self.local_version_init[0:6]), self.local_version_init)
     self.assertEqual(client.get_version("test_tag"), self.local_version_init)
 def test_get_url_by_reading(self):
     url = self.local_url
     client = HgClient(self.local_path)
     client.checkout(url, self.local_version)
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_url(), self.local_url)
     self.assertEqual(client.get_version(), self.local_version)
     self.assertEqual(client.get_version(self.local_version_init[0:6]), self.local_version_init)
     self.assertEqual(client.get_version("test_tag"), self.local_version_init)
示例#9
0
 def test_get_url_by_reading(self):
     from vcstools.hg import HgClient
     client = HgClient(self.readonly_path)
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_url(), self.readonly_url)
     self.assertEqual(client.get_version(), self.readonly_version)
     self.assertEqual(client.get_version(self.readonly_version_init[0:6]),
                      self.readonly_version_init + '+')
     self.assertEqual(client.get_version("test_tag"),
                      self.readonly_version_init + '+')
示例#10
0
 def test_checkout(self):
     url = self.local_url
     client = HgClient(self.local_path)
     self.assertFalse(client.path_exists())
     self.assertFalse(client.detect_presence())
     self.assertTrue(client.checkout(url))
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_path(), self.local_path)
     self.assertEqual(client.get_url(), url)
     self.assertEqual(client.get_version(), self.local_version)
示例#11
0
 def test_checkout(self):
     url = self.local_url
     client = HgClient(self.local_path)
     self.assertFalse(client.path_exists())
     self.assertFalse(client.detect_presence())
     self.assertTrue(client.checkout(url))
     self.assertTrue(client.path_exists())
     self.assertTrue(client.detect_presence())
     self.assertEqual(client.get_path(), self.local_path)
     self.assertEqual(client.get_url(), url)
     self.assertEqual(client.get_version(), self.local_version)
示例#12
0
    def test_get_remote_version(self):
        url = self.local_url
        version = self.local_version
        client = HgClient(self.local_path)
        client.checkout(url, version='default')
        self.assertEqual(client.get_remote_version(fetch=True), self.local_version)
        self.assertEqual(client.get_version(), self.local_version)

        for cmd in [
                "hg checkout default",
                "touch remote_new.txt",
                "hg add remote_new.txt",
                "hg commit -m remote_new"]:
            subprocess.check_call(cmd, shell=True, cwd=self.remote_path)
        po = subprocess.Popen("hg log --template '{node|short}' -l1", shell=True, cwd=self.remote_path, stdout=subprocess.PIPE)
        remote_new_version = po.stdout.read().decode('UTF-8').rstrip("'").lstrip("'")
        self.assertNotEqual(self.local_version, remote_new_version)

        self.assertEqual(client.get_remote_version(fetch=False), self.local_version)
        self.assertEqual(client.get_remote_version(fetch=True), remote_new_version)
        self.assertEqual(client.get_remote_version(fetch=False), remote_new_version)
        self.assertEqual(client.get_version(), self.local_version)
示例#13
0
 def test_get_version_modified(self):
     client = HgClient(self.local_path)
     self.assertFalse(client.get_version().endswith('+'))
示例#14
0
 def test_checkout_emptystringversion(self):
     # special test to check that version '' means the same as None
     url = self.local_url
     client = HgClient(self.local_path)
     self.assertTrue(client.checkout(url, ''))
     self.assertEqual(client.get_version(), self.local_version)
示例#15
0
 def test_get_version_modified(self):
     client = HgClient(self.local_path)
     self.assertFalse(client.get_version().endswith('+'))
示例#16
0
 def test_checkout_emptystringversion(self):
     # special test to check that version '' means the same as None
     url = self.local_url
     client = HgClient(self.local_path)
     self.assertTrue(client.checkout(url, ''))
     self.assertEqual(client.get_version(), self.local_version)