def update_from_cli(**kwargs): tests_root = kwargs["tests_root"] path = kwargs["path"] assert tests_root is not None m = None logger = get_logger() if not kwargs.get("rebuild", False): try: m = manifest.load(tests_root, path) except manifest.ManifestVersionMismatch: logger.info("Manifest version changed, rebuilding") m = None else: logger.info("Updating manifest") if m is None: m = manifest.Manifest(None) update(tests_root, kwargs["url_base"], m, ignore_local=kwargs.get("ignore_local", False)) manifest.write(m, path)
def main(request, response): path = os.path.join(root, "MANIFEST.json") manifest_file = manifest.load(path) manifest.update(root, "/", manifest_file) manifest.write(manifest_file, path) return [("Content-Type", "application/json")], json.dumps({"url": "/MANIFEST.json"})
def update_from_cli(**kwargs): tests_root = kwargs["tests_root"] path = kwargs["path"] assert tests_root is not None m = None logger = get_logger() if not kwargs.get("rebuild", False): try: m = manifest.load(tests_root, path) except manifest.ManifestVersionMismatch: logger.info("Manifest version changed, rebuilding") m = None else: logger.info("Updating manifest") if m is None: m = manifest.Manifest(kwargs["url_base"]) changed = update(tests_root, m, working_copy=kwargs["work"]) if changed: manifest.write(m, path)
def default_add(self, field, value): (remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False) default[field] = value manifest.write(self.manifest_filename, remotes, repos, default) self.read_manifest() self.output.append('default added: %s=%s' % (field, value))
def create(self, state): import manifest test_manifest = state.test_manifest state.initial_rev = test_manifest.rev manifest.update(state.sync["path"], "/", test_manifest) manifest.write(test_manifest, os.path.join(state.metadata_path, "MANIFEST.json"))
def init(cls, project_dir, bare=False, output_buffer=None): 'Project.init -- initialize a new rug repository' if output_buffer is None: output_buffer = output.NullOutputBuffer() if project_dir == None: project_dir = '.' if cls.valid_project(project_dir): raise RugError('%s is an existing rug project' % project_dir) if bare: rug_dir = project_dir else: rug_dir = os.path.join(project_dir, RUG_DIR) os.makedirs(rug_dir) config_file = os.path.join(rug_dir, RUG_CONFIG) open(config_file, 'w').close() manifest_dir = os.path.join(rug_dir, 'manifest') manifest_filename = os.path.join(manifest_dir, 'manifest.xml') mr = git.Repo.init(manifest_dir, output_buffer=output_buffer.spawn('manifest: ')) manifest.write(manifest_filename, {}, {}, {}) mr.add(os.path.basename(manifest_filename)) mr.commit('Initial commit') return cls(project_dir, output_buffer=output_buffer)
def sync_tests(paths, local_tree, wpt, bug): wpt.update() do_delayed_imports(paths["sync"]) try: # bug.comment("Updating to %s" % wpt.rev) sync_paths = {"/": {"tests_path": paths["sync"], "metadata_path": paths["sync_dest"]["metadata_path"]}} manifest_loader = testloader.ManifestLoader(sync_paths) test_manifest = manifest_loader.load_manifest(**sync_paths["/"]) initial_rev = test_manifest.rev manifest.update(sync_paths["/"]["tests_path"], "/", test_manifest) manifest.write(test_manifest, os.path.join(sync_paths["/"]["metadata_path"], "MANIFEST.json")) wpt.copy_work_tree(paths["sync_dest"]["tests_path"]) local_tree.create_patch( "web-platform-tests_update_%s" % wpt.rev, "Update web-platform-tests to revision %s" % wpt.rev ) local_tree.add_new(os.path.relpath(paths["sync_dest"]["tests_path"], local_tree.root)) local_tree.update_patch(include=[paths["sync_dest"]["tests_path"], paths["sync_dest"]["metadata_path"]]) except Exception as e: # bug.comment("Update failed with error:\n %s" % traceback.format_exc()) sys.stderr.write(traceback.format_exc()) raise finally: pass # wpt.clean() return initial_rev
def main(request, response): path = os.path.join(root, "MANIFEST.json") manifest_file = manifest.load(path) manifest.update(root, "/", manifest_file) manifest.write(manifest_file, path) return [("Content-Type", "application/json") ], json.dumps({"url": "/MANIFEST.json"})
def remote_add(self, remote, fetch): (remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False) if not remotes.has_key(remote): remotes[remote] = {'name':remote} remotes[remote]['fetch'] = fetch manifest.write(self.manifest_filename, remotes, repos, default) self.read_manifest() self.output.append('remote %s added' % remote)
def load_manifest(self, tests_path, metadata_path, url_base="/"): manifest_path = os.path.join(metadata_path, "MANIFEST.json") if (not os.path.exists(manifest_path) or self.force_manifest_update): self.update_manifest(manifest_path, tests_path, url_base) manifest_file = manifest.load(manifest_path) if manifest_file.url_base != url_base: self.logger.info("Updating url_base in manifest from %s to %s" % (manifest_file.url_base, url_base)) manifest_file.url_base = url_base manifest.write(manifest_file, manifest_path) return manifest_file
def remove(self, path): """ Remove a repo from the manifest """ (remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False) lookup_default = {} lookup_default.update(RUG_DEFAULT_DEFAULT) lookup_default.update(default) if path not in repos: raise RugError('unrecognized repo %s' % path) del(repos[path]) manifest.write(self.manifest_filename, remotes, repos, default) self.read_manifest() self.output.append("%s removed from manifest" % path)
def update_manifest(self, manifest_path, tests_path, url_base="/", recreate=False): self.logger.info("Updating test manifest %s" % manifest_path) json_data = None if not recreate: try: with open(manifest_path) as f: json_data = json.load(f) except IOError: #If the existing file doesn't exist just create one from scratch pass if not json_data: manifest_file = manifest.Manifest(None, url_base) else: manifest_file = manifest.Manifest.from_json(json_data) manifest.update(tests_path, url_base, manifest_file) manifest.write(manifest_file, manifest_path)
def update_from_cli(**kwargs): tests_root = kwargs["tests_root"] path = kwargs["path"] assert tests_root is not None m = None if kwargs["download"]: download_from_github(path, tests_root) if not kwargs.get("rebuild", False): try: m = manifest.load(tests_root, path) except manifest.ManifestVersionMismatch: logger.info("Manifest version changed, rebuilding") m = None if m is None: m = manifest.Manifest(kwargs["url_base"]) changed = update(tests_root, m, working_copy=kwargs["work"]) if changed: manifest.write(m, path)
def add(self, path, name=None, remote=None, rev=None, vcs=None, use_sha=None): #TODO:handle lists of dirs (remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False) lookup_default = {} lookup_default.update(RUG_DEFAULT_DEFAULT) lookup_default.update(default) update_rug_branch = False r = self.repos.get(path, None) if r is None: # Validate inputs if name is None: raise RugError('new repos must specify a name') if remote is None: raise RugError('new repos must specify a remote') if self.bare: if rev is None: raise RugError('new repos in bare projects must specify a rev') if vcs is None: raise RugError('new repos in bare projects must specify a vcs') if self.bare: #Can't really test/validate anything here since there's no repo #Hope the user knows what they're doing #Add the repo repos[path] = {'path': path} revision = rev else: if r is None: #New repository #Find vcs if not specified, and create repo object abs_path = os.path.join(self.dir, path) if vcs is None: repo = None #TODO: rug needs to take priority here, as rug repos with sub-repos at '.' #will look like the sub-repo vcs as well as a rug repo #(but not if the path of the sub-repo is '.') for (try_vcs, R) in self.vcs_class.items(): if R.valid_repo(abs_path): repo = R(abs_path, output_buffer=self.output.spawn(path + ': ')) vcs = try_vcs break if repo is None: raise RugError('unrecognized repo %s' % path) else: repo = self.vcs_class[vcs](abs_path, output_buffer=self.output.spawn(path + ': ')) #Add the repo repos[path] = {'path': path} #TODO: we don't know if the remote even exists yet, so can't set up all branches #logic elsewhere should be able to handle this possibility (remote & bookmark branches don't exist) update_rug_branch = True #TODO: should this be required? If not, what should the default be? if use_sha is None: use_sha = False else: #Modify existing repo repo = r['repo'] #TODO: rethink this condition if remote is not None: update_rug_branch = True #If use_sha is not specified, look at existing manifest revision if use_sha is None: use_sha = repo.valid_sha(r.get('revision', lookup_default['revision'])) #Get the rev if rev is None: rev = repo.head() else: rev = repo.rev_class.cast(repo, rev) if use_sha: rev = repo.rev_class(repo, rev.get_sha()) revision = rev.get_short_name() #Update repo properties for p in ['revision', 'name', 'remote', 'vcs']: pval = locals()[p] if (pval is not None) and (pval != lookup_default.get(p)): repos[path][p] = pval #Write the manifest and reload repos manifest.write(self.manifest_filename, remotes, repos, default) self.read_manifest() if not self.bare: r = self.repos[path] repo = r['repo'] branches = self.get_branch_names(r) #Update rug_index repo.update_ref(branches['rug_index'], rev) #If this is a new repo, set the rug branch if update_rug_branch: repo.update_ref(branches['rug'], rev) self.output.append("%s added to manifest" % path)
def create_manifest(self, manifest_path, tests_path, url_base="/"): self.logger.info("Creating test manifest %s" % manifest_path) manifest_file = manifest.Manifest(None, url_base) manifest.update(tests_path, url_base, manifest_file) manifest.write(manifest_file, manifest_path)
def create_manifest(self): logger.info("Creating test manifest") manifest.setup_git(self.tests_root) manifest_file = manifest.Manifest(None) manifest.update(manifest_file) manifest.write(manifest_file, self.manifest_path)