void Client::merge(const Path & path1, const Revision & revision1, const Path & path2, const Revision & revision2, const Path & localPath, bool force, bool recurse, bool notice_ancestry, bool dry_run) throw(ClientException) { Pool pool; svn_error_t * error = svn_client_merge(path1.c_str(), revision1.revision(), path2.c_str(), revision2.revision(), localPath.c_str(), recurse, !notice_ancestry, force, dry_run, *m_context, pool); if (error != NULL) throw ClientException(error); }
svn_revnum_t Client::checkout(const char * url, const Path & destPath, const Revision & revision, bool recurse, bool ignore_externals, const Revision & peg_revision) throw(ClientException) { Pool subPool; apr_pool_t * apr_pool = subPool.pool(); svn_revnum_t revnum = 0; svn_error_t * error = svn_client_checkout2(&revnum, url, destPath.c_str(), peg_revision.revision(), // peg_revision revision.revision(), // revision recurse, ignore_externals, *m_context, apr_pool); if (error != NULL) throw ClientException(error); return revnum; }
Score::FileError MasterScore::read300(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "programVersion") { setMscoreVersion(e.readElementText()); parseVersion(mscoreVersion()); } else if (tag == "programRevision") setMscoreRevision(e.readInt()); else if (tag == "Score") { if (!read(e)) return FileError::FILE_BAD_FORMAT; } else if (tag == "Revision") { Revision* revision = new Revision; revision->read(e); revisions()->add(revision); } } int id = 1; for (LinkedElements* le : e.linkIds()) le->setLid(this, id++); for (Staff* s : staves()) s->updateOttava(); setCreated(false); return FileError::FILE_NO_ERROR; }
void BondAngleDistribution::writeBondAngleDistribution() { RealType norm = (RealType)nTotBonds_*((RealType)nTotBonds_-1.0)/2.0; std::ofstream ofs(getOutputFileName().c_str()); if (ofs.is_open()) { Revision r; ofs << "# " << getAnalysisType() << "\n"; ofs << "# OpenMD " << r.getFullRevision() << "\n"; ofs << "# " << r.getBuildDate() << "\n"; ofs << "# selection script: \"" << selectionScript_ << "\"\n"; if (!paramString_.empty()) ofs << "# parameters: " << paramString_ << "\n"; // Normalize by number of frames and write it out: for (int i = 0; i < nBins_; ++i) { RealType Thetaval = i * deltaTheta_; ofs << Thetaval; ofs << "\t" << (RealType)histogram_[i]/norm/frameCounter_; ofs << "\n"; } ofs.close(); } else { sprintf(painCave.errMsg, "BondAngleDistribution: unable to open %s\n", (getOutputFileName() + "q").c_str()); painCave.isFatal = 1; simError(); } }
void GCN::writeData() { std::ofstream ofs(outputFilename_.c_str(), std::ios::binary); if (ofs.is_open()) { Revision r; RealType binValue(0.0); ofs << "# " << getAnalysisType() << "\n"; ofs << "# OpenMD " << r.getFullRevision() << "\n"; ofs << "# " << r.getBuildDate() << "\n"; ofs << "# selection script1: \"" << sele1_ ; ofs << "\"\tselection script2: \"" << sele2_ << "\"\n"; if (!paramString_.empty()) ofs << "# parameters: " << paramString_ << "\n"; for(unsigned int n = 0; n < histogram_.size(); n++){ binValue = n * delta_; ofs << binValue << "\t" << histogram_[n] << "\n"; } } ofs.close(); }
// Loads a revision from the cache Revision *Cache::get(const std::string &id) { if (!m_loaded) { load(); } std::string dir = cacheDir(); std::pair<uint32_t, uint32_t> offset = m_index[id]; std::string path = str::printf("%s/cache.%u", dir.c_str(), offset.first); if (m_cin == NULL || offset.first != m_ciindex) { delete m_cin; m_cin = new BIStream(path); m_ciindex = offset.first; if (!m_cin->ok()) { throw PEX(str::printf("Unable to read from cache file: %s", path.c_str())); } } if (!m_cin->seek(offset.second)) { throw PEX(str::printf("Unable to read from cache file: %s", path.c_str())); } Revision *rev = new Revision(id); std::vector<char> data; *m_cin >> data; data = utils::uncompress(data); if (data.empty()) { throw PEX(str::printf("Unable to read from cache file: %s", path.c_str())); } MIStream rin(data); if (!rev->load03(rin)) { throw PEX(str::printf("Unable to read from cache file: %s", path.c_str())); } return rev; }
Score::FileError MasterScore::read301(XmlReader& e) { bool top = true; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "programVersion") { setMscoreVersion(e.readElementText()); parseVersion(mscoreVersion()); } else if (tag == "programRevision") setMscoreRevision(e.readIntHex()); else if (tag == "Score") { MasterScore* score; if (top) { score = this; top = false; } else { score = new MasterScore(); score->setMscVersion(mscVersion()); addMovement(score); } if (!score->read(e)) return FileError::FILE_BAD_FORMAT; } else if (tag == "Revision") { Revision* revision = new Revision; revision->read(e); revisions()->add(revision); } } return FileError::FILE_NO_ERROR; }
void Client::doExport(const Path & from_path, const Path & to_path, const Revision & revision, bool overwrite, const Revision & peg_revision, bool ignore_externals, bool recurse, const char * native_eol) throw(ClientException) { Pool pool; svn_revnum_t revnum = 0; svn_error_t * error = svn_client_export3(&revnum, from_path.c_str(), to_path.c_str(), peg_revision.revision(), revision.revision(), overwrite, ignore_externals, recurse, native_eol, *m_context, pool); if (error != NULL) throw ClientException(error); }
void Client::get(Path & dstPath, const Path & path, const Revision & revision, const Revision & peg_revision) throw(ClientException) { Pool pool; // create a new file and suppose we only want // this users to be able to read and write the file apr_file_t * file = openTempFile(dstPath, path, revision, pool); // now create a stream and let svn_client_cat write to the // stream svn_stream_t * stream = svn_stream_from_aprfile(file, pool); if (stream != 0) { svn_error_t * error = svn_client_cat2( stream, path.c_str(), peg_revision.revision() , revision.revision(), *m_context, pool); if (error != 0) throw ClientException(error); svn_stream_close(stream); } // finalize stuff apr_file_close(file); }
bool Revision::operator==(const Revision &r)const { if (r.kind() != kind()) { return false; } if (m_revision.kind == svn_opt_revision_number) { return revnum() == r.revnum(); } else if (m_revision.kind == svn_opt_revision_date) { return date() == r.date(); } return true; }
std::vector<svn_revnum_t> Client::update(const Targets & targets, const Revision & revision, bool recurse, bool ignore_externals) throw(ClientException) { Pool pool; apr_array_header_t * result_revs; svn_error_t * error = svn_client_update2(&result_revs, const_cast<apr_array_header_t*>(targets.array(pool)), revision.revision(), recurse, ignore_externals, *m_context, pool); if (error != NULL) throw ClientException(error); std::vector<svn_revnum_t> revnums; int i; for (i = 0; i < result_revs->nelts; i++) { svn_revnum_t revnum= APR_ARRAY_IDX(result_revs, i, svn_revnum_t); revnums.push_back(revnum); } return revnums; }
std::pair<svn_revnum_t,std::string> Client::revpropget(const char *propName, const Path &path, const Revision &revision) { Pool pool; svn_string_t *propval; svn_revnum_t revnum; svn_error_t * error = svn_client_revprop_get(propName, &propval, path.c_str(), revision.revision(), &revnum, *m_context, pool); if (error != nullptr) { throw ClientException(error); } // if the property does not exist NULL is returned if (propval == nullptr) return std::pair<svn_revnum_t,std::string> (0, std::string()); return std::pair<svn_revnum_t,std::string> (revnum, std::string(propval->data)); }
/** * set property in @a path no matter whether local or * repository * * @param path * @param revision * @param propName * @param propValue * @param recurse * @param revprop * @return PropertiesList */ svn_revnum_t Client::revpropset(const char *propName, const char *propValue, const Path &path, const Revision &revision, bool force) { Pool pool; const svn_string_t * propval = svn_string_create((const char *) propValue, pool); svn_revnum_t revnum; svn_error_t * error = svn_client_revprop_set(propName, propval, path.c_str(), revision.revision(), &revnum, force, *m_context, pool); if (error != nullptr) throw ClientException(error); return revnum; }
Revision *LdbCache::get(const std::string &id) { if (!m_db) opendb(); std::string value; leveldb::Status s = m_db->Get(leveldb::ReadOptions(), id, &value); if (!s.ok()) { throw PEX(str::printf("Error reading from cache: %s", s.ToString().c_str())); } Revision *rev = new Revision(id); MIStream rin(value.c_str(), value.length()); if (!rev->load(rin)) { throw PEX(str::printf("Unable to read from cache: Data corrupted")); } return rev; }
void fromJsonSub(const json11::Json& json) { //cout << "[[Page::fromJson]]..." << endl; long n_pageid = json["pageid"].int_value(); //cout << "[[Page::fromJson]] n_pageid: " << n_pageid << endl; if(pageid == -1) pageid = n_pageid; else if(pageid!=n_pageid) return; // serious error in logic int n_ns = json["ns"].int_value(); //cout << "[[Page::fromJson]] n_ns: " << n_ns << endl; if(ns==-1) ns = n_ns; else if(ns!=n_ns) return; // serious error in logic string n_title = json["title"].string_value(); //cout << "[[Page::fromJson]] n_title: " << n_title << endl; if(title.length() == 0) title = n_title; else if(title.compare(n_title) != 0) return; // serious error in logic auto revisionsJson = json["revisions"].array_items(); for(auto itr : revisionsJson) { //Revision revision(itr); Revision revision; revision.fromJson(itr); //cout << "[[Page::fromJson]] revision.revid: " << revision.revid << endl; if(revisionsMap.find(revision.revid) != revisionsMap.end()) continue; //cout << "[[Page::fromJson]] new revision" << endl; revision.ns = ns; revision.pageid = pageid; revision.title = title; //cout << "[[Page::fromJson]] (revisionsMap.find(revision.revid) == revisionsMap.end()): " << (revisionsMap.find(revision.revid) == revisionsMap.end()) << endl; revisions.push_back(revision); //revisionsMap[revision.revid] = &revisions[revisions.size()-1]; revisionsMap[revision.revid] = revisions.size()-1; } auto categoriesJson = json["categories"].array_items(); for(auto ipr : categoriesJson) { //Category category(ipr); Category category; category.fromJson(ipr); if(categoriesMap.find(category.title) != categoriesMap.end()) continue; categories.push_back(category); //categoriesMap[category.title] = &categories[categories.size()-1]; categoriesMap[category.title] = categories.size()-1; } }
void ProjectModel::rollback(QModelIndex &index, int n) { ProjectTreeItem *item = static_cast<ProjectTreeItem*>(index.internalPointer()); QVariant var = item->data(0, Qt::UserRole); CompleteAnnotationItem *currentAnnotation = var.value<CompleteAnnotationItem*>(); Revision<AnnotationItem*> revision = currentAnnotation->getRevision(n); RevisionAnnotationList revisions; for(int i = 0; i < n; i++){ revisions << currentAnnotation->getRevision(i); } CompleteAnnotationItem *newAnnotation = new CompleteAnnotationItem(revision.getValue()->getId(), revision.getValue(), revisions); var.setValue<CompleteAnnotationItem*>(newAnnotation); item->setData(var); }
// Adds the revision to the cache void LdbCache::put(const std::string &id, const Revision &rev) { if (!m_db) opendb(); MOStream rout; rev.write(rout); std::vector<char> data(rout.data()); leveldb::Status s = m_db->Put(leveldb::WriteOptions(), id, std::string(data.begin(), data.end())); if (!s.ok()) { throw PEX(str::printf("Error writing to cache: %s", s.ToString().c_str())); } }
// Adds the revision to the cache void Cache::put(const std::string &id, const Revision &rev) { if (!m_loaded) { load(); } // Defer any signals while writing to the cache SIGBLOCK_DEFER(); // Add revision to cache std::string dir = m_opts.cacheDir() + "/" + uuid(), path; if (m_cout == NULL) { m_coindex = 0; do { path = str::printf("%s/cache.%u", dir.c_str(), m_coindex); if (!sys::fs::fileExists(path) || sys::fs::filesize(path) < MAX_CACHEFILE_SIZE) { break; } ++m_coindex; } while (true); delete m_cout; m_cout = new BOStream(path, true); } else if (m_cout->tell() >= MAX_CACHEFILE_SIZE) { delete m_cout; path = str::printf("%s/cache.%u", dir.c_str(), ++m_coindex); m_cout = new BOStream(path, true); } uint32_t offset = m_cout->tell(); MOStream rout; rev.write03(rout); std::vector<char> compressed = utils::compress(rout.data()); *m_cout << compressed; // Add revision to index if (m_iout == NULL) { if (sys::fs::exists(dir + "/index")) { m_iout = new GZOStream(dir + "/index", true); } else { m_iout = new GZOStream(dir + "/index", false); // Version number *m_iout << CACHE_VERSION; } } *m_iout << id; *m_iout << m_coindex << offset << utils::crc32(compressed); // Update cached index m_index[id] = std::pair<uint32_t, uint32_t>(m_coindex, offset); }
void GofRAngle::writeRdf() { std::ofstream ofs(outputFilename_.c_str()); if (ofs.is_open()) { Revision r; ofs << "# " << getAnalysisType() << "\n"; ofs << "# OpenMD " << r.getFullRevision() << "\n"; ofs << "# " << r.getBuildDate() << "\n"; ofs << "# selection script1: \"" << selectionScript1_ ; ofs << "\"\tselection script2: \"" << selectionScript2_ << "\""; if (doSele3_) { ofs << "\tselection script3: \"" << selectionScript3_ << "\"\n"; } else { ofs << "\n"; } if (!paramString_.empty()) ofs << "# parameters: " << paramString_ << "\n"; for (unsigned int i = 0; i < avgGofr_.size(); ++i) { // RealType r = deltaR_ * (i + 0.5); for(unsigned int j = 0; j < avgGofr_[i].size(); ++j) { // RealType cosAngle = -1.0 + (j + 0.5)*deltaCosAngle_; ofs << avgGofr_[i][j]/nProcessed_ << "\t"; } ofs << "\n"; } } else { sprintf(painCave.errMsg, "GofRAngle: unable to open %s\n", outputFilename_.c_str()); painCave.isFatal = 1; simError(); } ofs.close(); }
std::string Client::cat(const Path & path, const Revision & revision, const Revision & peg_revision) throw(ClientException) { Pool pool; svn_stringbuf_t * stringbuf = svn_stringbuf_create("", pool); svn_stream_t * stream = svn_stream_from_stringbuf(stringbuf, pool); svn_error_t * error; error = svn_client_cat2(stream, path.c_str(), peg_revision.revision(), revision.revision(), *m_context, pool); if (error != 0) throw ClientException(error); return std::string(stringbuf->data, stringbuf->len); }
InfoVector Client::info(const Path & pathOrUrl, bool recurse, const Revision & revision, const Revision & pegRevision) throw(ClientException) { Pool pool; InfoVector infoVector; svn_error_t * error = svn_client_info(pathOrUrl.c_str(), pegRevision.revision(), revision.revision(), infoReceiverFunc, &infoVector, recurse, *m_context, pool); if (error != 0) throw ClientException(error); return infoVector; }
/** * lists properties in @a path no matter whether local or * repository * * @param path * @param revision * @param recurse * @return PropertiesList */ PathPropertiesMapList Client::proplist(const Path & path, const Revision & revision, bool recurse) { Pool pool; apr_array_header_t * props; svn_error_t * error = svn_client_proplist(&props, path.c_str(), revision.revision(), recurse, *m_context, pool); if (error != nullptr) { throw ClientException(error); } PathPropertiesMapList path_prop_map_list; for (int j = 0; j < props->nelts; ++j) { svn_client_proplist_item_t *item = ((svn_client_proplist_item_t **)props->elts)[j]; PropertiesMap prop_map; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, item->prop_hash); hi; hi = apr_hash_next(hi)) { const void *key; void *val; apr_hash_this(hi, &key, nullptr, &val); prop_map [std::string((const char *)key)] = std::string(((const svn_string_t *)val)->data); } path_prop_map_list.push_back(PathPropertiesMapEntry(item->node_name->data, prop_map)); } return path_prop_map_list; }
void Wc::ensureAdm(const char * dir, const char *uuid, const char * url, const Revision & revision) { Pool pool; Path dirPath(dir); Path urlPath(url); svn_error_t * error = svn_wc_ensure_adm(dirPath.c_str(), // path uuid, // UUID urlPath.c_str(), // url revision.revnum(), // revision pool); if (error != NULL) throw ClientException(error); }
void Client::copy(const Path & srcPath, const Revision & srcRevision, const Path & destPath) throw(ClientException) { Pool pool; svn_client_commit_info_t *commit_info = NULL; svn_error_t * error = svn_client_copy(&commit_info, srcPath.c_str(), srcRevision.revision(), destPath.c_str(), *m_context, pool); if (error != NULL) throw ClientException(error); }
PathPropertiesMapList Client::propget(const char *propName, const Path &path, const Revision &revision, bool recurse) { Pool pool; apr_hash_t *props; svn_error_t * error = svn_client_propget(&props, propName, path.c_str(), revision.revision(), recurse, *m_context, pool); if (error != nullptr) { throw ClientException(error); } PathPropertiesMapList path_prop_map_list; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) { PropertiesMap prop_map; const void *key; void *val; apr_hash_this(hi, &key, nullptr, &val); prop_map [std::string(propName)] = std::string(((const svn_string_t *)val)->data); path_prop_map_list.push_back(PathPropertiesMapEntry((const char *)key, prop_map)); } return path_prop_map_list; }
void SVNRepos::deltify(File &path, Revision &revStart, Revision &revEnd) { SVN::Pool requestPool; svn_repos_t *repos; svn_fs_t *fs; svn_revnum_t start = SVN_INVALID_REVNUM, end = SVN_INVALID_REVNUM; svn_revnum_t youngest, revision; SVN::Pool revisionPool; if (path.isNull()) { JNIUtil::throwNullPointerException("path"); return; } SVN_JNI_ERR(svn_repos_open3(&repos, path.getInternalStyle(requestPool), NULL, requestPool.getPool(), requestPool.getPool()), ); fs = svn_repos_fs(repos); SVN_JNI_ERR(svn_fs_youngest_rev(&youngest, fs, requestPool.getPool()), ); if (revStart.revision()->kind == svn_opt_revision_number) /* ### We only handle revision numbers right now, not dates. */ start = revStart.revision()->value.number; else if (revStart.revision()->kind == svn_opt_revision_head) start = youngest; else start = SVN_INVALID_REVNUM; if (revEnd.revision()->kind == svn_opt_revision_number) end = revEnd.revision()->value.number; else if (revEnd.revision()->kind == svn_opt_revision_head) end = youngest; else end = SVN_INVALID_REVNUM; /* Fill in implied revisions if necessary. */ if (start == SVN_INVALID_REVNUM) start = youngest; if (end == SVN_INVALID_REVNUM) end = start; if (start > end) { SVN_JNI_ERR(svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("First revision cannot be higher than second")), ); }
svn_revnum_t Client::doSwitch(const Path & path, const char * url, const Revision & revision, bool recurse) throw(ClientException) { Pool pool; svn_revnum_t revnum = 0; svn_error_t * error = svn_client_switch(&revnum, path.c_str(), url, revision.revision(), recurse, *m_context, pool); if (error != NULL) throw ClientException(error); return revnum; }
/** * delete property in @a path no matter whether local or * repository * * @param path * @param revision * @param propName * @param propValue * @param recurse * @param revprop * @return PropertiesList */ svn_revnum_t Client::revpropdel(const char *propName, const Path &path, const Revision &revision, bool force) { Pool pool; svn_revnum_t revnum; svn_error_t * error = svn_client_revprop_set(propName, nullptr, // value = NULL path.c_str(), revision.revision(), &revnum, force, *m_context, pool); if (error != nullptr) throw ClientException(error); return revnum; }
/** * lists revision properties in @a path no matter whether local or * repository * * @param path * @param revision * @param recurse * @return PropertiesList */ std::pair<svn_revnum_t,PropertiesMap> Client::revproplist(const Path &path, const Revision &revision) { Pool pool; apr_hash_t * props; svn_revnum_t revnum; svn_error_t * error = svn_client_revprop_list(&props, path.c_str(), revision.revision(), &revnum, *m_context, pool); if (error != nullptr) { throw ClientException(error); } PropertiesMap prop_map; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) { const void *key; void *val; apr_hash_this(hi, &key, nullptr, &val); prop_map [std::string((const char *)key)] = std::string(((const svn_string_t *)val)->data); } return std::pair<svn_revnum_t,PropertiesMap> (revnum, prop_map); }
void SVNAdmin::deltify(const char *path, Revision &revStart, Revision &revEnd) { Pool requestPool; SVN_JNI_NULL_PTR_EX(path, "path", ); path = svn_path_internal_style(path, requestPool.pool()); svn_repos_t *repos; svn_fs_t *fs; svn_revnum_t start = SVN_INVALID_REVNUM, end = SVN_INVALID_REVNUM; svn_revnum_t youngest, revision; Pool revisionPool; SVN_JNI_ERR(svn_repos_open(&repos, path, requestPool.pool()), ); fs = svn_repos_fs (repos); SVN_JNI_ERR(svn_fs_youngest_rev(&youngest, fs, requestPool.pool()), ); if (revStart.revision()->kind == svn_opt_revision_number) /* ### We only handle revision numbers right now, not dates. */ start = revStart.revision()->value.number; else if (revStart.revision()->kind == svn_opt_revision_head) start = youngest; else start = SVN_INVALID_REVNUM; if (revEnd.revision()->kind == svn_opt_revision_number) end = revEnd.revision()->value.number; else if (revEnd.revision()->kind == svn_opt_revision_head) end = youngest; else end = SVN_INVALID_REVNUM; /* Fill in implied revisions if necessary. */ if (start == SVN_INVALID_REVNUM) start = youngest; if (end == SVN_INVALID_REVNUM) end = start; if (start > end) { SVN_JNI_ERR(svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("First revision cannot be higher than second")), ); }