public RepositoryTagMap( AbstractRepository repository, RepositoryTagMap parent, Map<String, RepositoryTagEntry> tagMap) throws IOException { _tagMap = Collections.unmodifiableMap(tagMap); long now = Alarm.getCurrentTime(); if (parent.getSequence() < now) _sequence = now; else _sequence = parent.getSequence() + 1; TempStream os = new TempStream(); WriteStream out = new WriteStream(os); writeTagMap(out); out.close(); String tagHash; InputStream is = os.getInputStream(); try { tagHash = repository.addBlob(is); } finally { is.close(); } _tree = new GitTree(); _tree.addBlob("tags", 0775, tagHash); for (String key : tagMap.keySet()) { RepositoryTagEntry entry = tagMap.get(key); String sha1 = entry.getTagEntryHash(); String root = entry.getRoot(); _tree.addBlob(sha1, 0644, sha1); GitType type = repository.getType(root); if (type == GitType.BLOB) _tree.addBlob(root, 0644, root); else if (type == GitType.TREE) _tree.addDir(root, root); else throw new IllegalStateException(L.l("'{0}' has an unknown type {1}", root, type)); } String treeHash = repository.addTree(_tree); _commit = new GitCommit(); _commit.setTree(treeHash); _commit.put("sequence", String.valueOf(_sequence)); _commitHash = repository.addCommit(_commit); }
/** * This function obtains from a predicate that is a conjunction of assignments the assignment * related to an identifier * * @param specID The identifier of a variable in the specification * @param pred A predicate * @return the equality */ public static MemPred getRelatedEquality(Pred pred, String specID) { AbstractRepository<Pred> predRep = pred.accept(new AndPredClausesExtractor()); AbstractIterator<Pred> predIt = predRep.createIterator(); while (predIt.hasNext()) { Pred auxPred = predIt.next(); if (auxPred instanceof MemPred) { MemPred memPred = ((MemPred) auxPred); if (memPred.getMixfix()) { String id = ((RefExpr) memPred.getLeftExpr()).getName().toString(); if (id.equals(specID)) { return memPred; } } else return null; } else return null; } return null; }
protected void getResources(List<Resource> list, boolean recursive) throws IOException { Set paths = context.getResourcePaths(path); if (paths != null) { for (Object obj : paths) { String path = (String) obj; if (!path.endsWith("/")) { int n = path.lastIndexOf('/', path.length() - 1); String name = path.substring(n + 1); list.add(lookupResource(name)); } else if (recursive) { int n = path.lastIndexOf('/', path.length() - 2); String name = path.substring(n + 1, path.length() - 1); AbstractRepository repo = lookupRepository(name); repo.getResources(list, true); } } } }
public RepositoryTagMap(AbstractRepository repository, String commitHash, boolean isValidate) throws IOException { _commitHash = commitHash; if (commitHash == null) throw new NullPointerException(); // force loading and validation from backend if (isValidate) repository.validateHash(commitHash); _commit = repository.readCommit(commitHash); String sequence = _commit.get("sequence"); if (sequence != null) _sequence = Long.parseLong(sequence); else _sequence = 1; _tree = repository.readTree(_commit.getTree()); _tagMap = readTagMap(repository, _tree.getHash("tags")); }
private Map<String, RepositoryTagEntry> readTagMap(AbstractRepository repository, String sha1) throws IOException { TreeMap<String, RepositoryTagEntry> map = new TreeMap<String, RepositoryTagEntry>(); InputStream is = repository.openBlob(sha1); try { ReadStream in = Vfs.openRead(is); String tag; while ((tag = in.readLine()) != null) { String entrySha1 = in.readLine(); RepositoryTagEntry entry = new RepositoryTagEntry(repository, entrySha1); map.put(tag, entry); } } finally { is.close(); } return Collections.unmodifiableMap(map); }