def __init__(self, configuration_file=None): """ Start a server, read the configuration file, make sure the repositories are available and start checking for changes in these repositories. :param configuration_file: the configuration file to be used. """ if configuration_file is None: configuration_file = Defaults.CONFIGURATION_FILE try: self.configuration = Configuration(configuration_file) except ConfigurationException: print("The configuration file is nonexistent or not valid.") exit(Defaults.EXIT_INVALID_CONFIGURATION_FILE) else: print("Read " + configuration_file + " successfully.") local_exists = repository_exists(self.configuration.local) remote_exists = repository_exists(self.configuration.remote) # make sure the local and remote repositories exist if not local_exists and remote_exists: self.no_local_but_remote_exists() elif not local_exists and not remote_exists: self.not_local_and_no_remote() elif local_exists and not remote_exists: self.local_but_no_remote() else: self.local_and_remote() local_properties = _get_local_properties(self.local_repo.path) structure = _get_local_structure(self.local_repo.path) handler = LocalHandler(local_properties, structure) self.monitor = LocalMonitor(self.local_repo, handler) self.status = READY
def test_repository_exists_file(self): self.assertFalse(repository_exists(LOCAL_ROOT_FILE)) repo = Repo(LOCAL_ROOT_FILE) repo.hg_init() self.assertTrue(repository_exists(LOCAL_ROOT_FILE))
def test_repository_exists_ssh(self): self.assertFalse(repository_exists(REMOTE_ROOT_SSH)) repo = Repo(REMOTE_ROOT_SSH) repo.hg_init() self.assertTrue(repository_exists(REMOTE_ROOT_SSH))
def test_repository_exists_path(self): self.assertFalse(repository_exists(LOCAL_ROOT_PATH)) repo = Repo(LOCAL_ROOT_PATH) repo.hg_init() self.assertTrue(repository_exists(LOCAL_ROOT_PATH))