int LuaBridge::RemoveIndexEntry(lua_State* state) { Repository* repo = fetchRepository(state); CHECK_REPO(repo) LUA->CheckString(2); try { repo->RemoveIndexEntry(std::string(LUA->GetString(2))); } catch (GitError e) { return pushErrorString(state, e); } LUA->PushBool(true); return 1; }
void Mock1Test::testMock1() { debug(LOG_DEBUG, DEBUG_LOG, 0, "Mock1Test begin"); ModulePtr module = repository->getModule("mock1"); debug(LOG_DEBUG, DEBUG_LOG, 0, "got module"); module->open(); debug(LOG_DEBUG, DEBUG_LOG, 0, "module open"); DeviceLocatorPtr cl = module->getDeviceLocator(); debug(LOG_DEBUG, DEBUG_LOG, 0, "get DeviceLocator"); std::vector<std::string> cameras = cl->getDevicelist(); debug(LOG_DEBUG, DEBUG_LOG, 0, "get %d devices", cameras.size()); CPPUNIT_ASSERT(cameras.size() == 10); CameraPtr camera = cl->getCamera("camera:mock1/5"); // for every CCD, take an image for (unsigned int i = 0; i < camera->nCcds(); i++) { CcdPtr ccd = camera->getCcd(i); Exposure exposure; ImageRectangle frame(ImagePoint(1,1), ImageSize(ccd->getSize().width() - 2, ccd->getSize().height() - 2)); exposure.frame(frame); ccd->startExposure(exposure); while (ccd->exposureStatus() == Exposure::exposing) { sleep(1); } if (ccd->exposureStatus() == Exposure::exposed) { ImagePtr image = ccd->getImage(); debug(LOG_DEBUG, DEBUG_LOG, 0, "result image size: %d x %d", image->size().width(), image->size().height()); } } debug(LOG_DEBUG, DEBUG_LOG, 0, "Mock1Test end"); }
RepositoryItem::RepositoryItem(const Repository &repo) : QTreeWidgetItem(QTreeWidgetItem::UserType) , m_repo(repo) { if (!repo.isDefault()) setFlags(flags() | Qt::ItemIsEditable); }
Diff diff_to_index(Repository const & repo, Tree & t, git_diff_options const & opts) { git_diff * diff; auto op_res = git_diff_tree_to_index(&diff, repo.ptr(), t.ptr(), nullptr, &opts); assert(op_res == 0); return Diff(diff); }
MetaRuleVerdict HPProtectToolsRule::verdict(Repository evidence) const { ContributionSet pt_processes_running; for(ContributionSet::const_iterator i=m_ptkeys.begin(); i!=m_ptkeys.end(); i++) if(evidence.exists(L"process_info." + *i + L".running")) pt_processes_running.insert(*i); // if any are none, protecttools appears not to be present, and so this rule judges "not guilty" if(pt_processes_running.empty()) { return MetaRuleVerdict(false); } // if any are some, protecttools is present and so this rule judges "guilty" else { std::wstring guilties (L"["); guilties.append (join<std::wstring,ContributionSet>(pt_processes_running,L",")); guilties.append (L"]"); return MetaRuleVerdict(true, L"HP ProtectTools (a.k.a. \"ActivCard\" is Running", // verdict L"The following running processes:\n\n" + // details guilties + L"\n\n" L"Indicate the presence of the ProtectTools/ActivCard software, which is known to lock resources required by Belgian e-ID components.", L"Stop and Disable ProtectTools/ActivCard", // suggestion name()); } }
Settings::Update Settings::updateUserRepositories(const RepoHash &updates) { if (updates.isEmpty()) return Settings::NoUpdatesApplied; QHash <QUrl, Repository> reposToUpdate; foreach (const QVariant &variant, d->m_data.values(scUserRepositories)) { const Repository repository = variant.value<Repository>(); reposToUpdate.insert(repository.url(), repository); } const bool updated = apply(updates, &reposToUpdate); if (updated) setUserRepositories(reposToUpdate.values().toSet()); return updated ? Settings::UpdatesApplied : Settings::NoUpdatesApplied; }
Diff diff(Repository const & repo, Tree & a, Tree & b, git_diff_options const & opts) { git_diff * diff; auto op_res = git_diff_tree_to_tree(&diff, repo.ptr(), a.ptr(), b.ptr(), &opts); assert(op_res == 0); return Diff(diff); }
Diff diff_index_to_workdir(Repository const & repo, git_diff_options const & opts) { git_diff * diff; auto op_res = git_diff_index_to_workdir(&diff, repo.ptr(), nullptr, &opts); assert(op_res == 0); return Diff(diff); }
branch_iterator(Repository const & repo, branch_type type) : type_(convert(type)), m_DoneFlag(false) { git_branch_iterator_new(&base_, repo.ptr(), type_); ++(*this); }
Component& Component::provide(const std::string& version) { // Check this is a valid version number std::vector<std::string> vs = versions(); if(std::count(vs.begin(),vs.end(),version)==0){ STENCILA_THROW(Exception,"Component does not have version.\n address: "+address()+"\n version: "+version); } // Create directory std::string version_path = path()+"/.at/"+version; boost::filesystem::create_directories(version_path); // Archive into it Repository* repo = this->repo(); if(repo){ repo->archive(version,version_path); } return *this; }
void BupSlave::open(const KUrl &pUrl, QIODevice::OpenMode pMode) { if(pMode & QIODevice::WriteOnly) { emit error(KIO::ERR_CANNOT_OPEN_FOR_WRITING, pUrl.prettyUrl()); return; } QStringList lPathInRepo; if(!checkCorrectRepository(pUrl, lPathInRepo)) { emit error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl())); return; } Node *lNode = mRepository->resolve(lPathInRepo, true); if(lNode == NULL) { emit error(KIO::ERR_DOES_NOT_EXIST, lPathInRepo.join(QLatin1String("/"))); return; } File *lFile = qobject_cast<File *>(lNode); if(lFile == NULL) { emit error(KIO::ERR_IS_DIRECTORY, lPathInRepo.join(QLatin1String("/"))); return; } if(0 != lFile->seek(0)) { emit error(KIO::ERR_CANNOT_OPEN_FOR_READING, pUrl.prettyUrl()); return; } mOpenFile = lFile; emit mimeType(lFile->mMimeType); emit totalSize(lFile->size()); emit position(0); emit opened(); }
void BupSlave::listDir(const KUrl& pUrl) { QStringList lPathInRepo; if(!checkCorrectRepository(pUrl, lPathInRepo)) { emit error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl())); return; } Node *lNode = mRepository->resolve(lPathInRepo, true); if(lNode == NULL) { emit error(KIO::ERR_DOES_NOT_EXIST, lPathInRepo.join(QLatin1String("/"))); return; } Directory *lDir = qobject_cast<Directory *>(lNode); if(lDir == NULL) { emit error(KIO::ERR_IS_FILE, lPathInRepo.join(QLatin1String("/"))); return; } // give the directory a chance to reload if necessary. lDir->reload(); const QString sDetails = metaData(QLatin1String("details")); const int lDetails = sDetails.isEmpty() ? 2 : sDetails.toInt(); NodeMapIterator i(lDir->subNodes()); UDSEntry lEntry; while(i.hasNext()) { createUDSEntry(i.next().value(), lEntry, lDetails); emit listEntry(lEntry, false); } emit listEntry(lEntry, true); emit finished(); }
void Gitarre::onRepoViewItemChanged (QTreeWidgetItem * current, QTreeWidgetItem * previous) { PurgeRepoViewContextMenu (); int topLevelIndex = RepoView->indexOfTopLevelItem(current); if (topLevelIndex != -1) // item is a top level item { Repository *repo = Repos [topLevelIndex]; // create context menu for the specific item if (repo->GetGitRepo()) { RepoView->addAction(CommitRepoAction); RepoView->addAction(PushRepoAction); CommitAction->setEnabled(true); PushAction->setEnabled(true); } else { RepoView->addAction(FindRepoAction); CommitAction->setEnabled(false); PushAction->setEnabled(false); } RepoView->addAction(RemoveSeparator); RepoView->addAction(RemoveRepoAction); // refresh remotes menu if (current != previous) RefreshRemotesMenu (repo); } else // provide the corresponding top level index { QTreeWidgetItem *parent = current; // move all the way up the item hierarchy while (parent->parent()) // while item "parent" has a parent parent = parent->parent(); // set parent to its parent topLevelIndex = RepoView->indexOfTopLevelItem(parent); } Repository *repo = Repos [topLevelIndex]; QTextDocument *doc = repo->GetIgnoreDocument(); if (IgnoreEditor->document() != doc) { IgnoreEditor->setDocument(doc); UpdateIgnoreEditorTab (doc->isModified()); } }
/* Will Analyze a file with path "filename". Analyze -> Parse, Print AST, Print Scopes */ void AnalyzeSingleFile::analyze(std::string filename) { if (VERBOSE) { std::cout << "\n [VERBOSE] : Validating File : " << filename << "\n"; } std::string fileSpec = FileSystem::Path::getFullFileSpec(filename); if (!fileExists(fileSpec)) { std::cout << "\n Specified file Not found"; std::cout << "\n Are you sure file \"" << fileSpec << "\" exists ?"; std::cout << "\n "; system("pause"); return; } ConfigParseToConsole configure; configure.setVerbose(VERBOSE); Parser* pParser = configure.Build(); try { if (pParser) { if (!configure.Attach(fileSpec)) { std::cout << "\n could not open file" << fileSpec << "\n "; } } else { std::cout << "\n Parser not built \n "; } while (pParser->next()) pParser->parse(); if (_ShowResult) { StringHelper::Title("\n File : " + fileSpec, '='); } Repository* repo = Repository::getInsance(); element* rootElem = repo->getTree()->getRoot(); // Retriving Root Element to set its linecount and Complexity. rootElem->lineCountEnd = repo->lineCount(); // Set Line count(s) rootElem->lineCount = rootElem->lineCountEnd - rootElem->lineCountBegin + 1; rootElem->complexity = repo->getTree()->getComplexity(rootElem); // Set Complexity if (_ShowResult) { printTree(repo); } // Printing AST on the command prompt if (_ShowResult) { printFunctions(repo); } // Printing file scopes on the command prompt repo->getTable()->addEntry("EOS", "namespace EOS"); // Add Namespace EOS for Global Namespace setTypeTableFields(repo, fileSpec); // Set some values in TypeTable (Filename and Namespace) setTable(repo); // Set the typeTable in Metrics to the typetable obtained from Repository // Doing this will prevent keeping entire repo instance in the memory and just hold the partial typetable. if (_ShowResult) { printTable(repo); // Printing the TypeTable std::cout << "\n"; } } catch (std::exception& ex) { std::cout << "\n\n [EXCEPTION] : " << ex.what() << "\n\n"; } }
static int openAttributeEditor( lua_State* L ) { // Params: Object, [string] Repository* rep = LuaSpecFactory::getRepository( L ); assert( rep ); Root::Object* obj = PeerHelper<LuaObject>::checkSameOrSubClass( L, 1 )->obj(); ObjectDef* od = 0; if( lua_gettop(L) > 1 ) { const char* name = luaL_checkstring( L, 2 ); od = rep->findObjectDef( name ); if( od == 0 ) luaL_error( L, "Cannot find attribute definitions for class %s", name ); } DynValueEditor::edit( 0, od, obj ); return 0; }
void RepositoryTest::testOpen() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testOpen() begin"); ModulePtr module = repository->getModule("mock1"); module->open(); CPPUNIT_ASSERT(module->isloaded()); module->close(); CPPUNIT_ASSERT(!module->isloaded()); debug(LOG_DEBUG, DEBUG_LOG, 0, "testOpen() end"); }
inline void doAction(const ITokCollection*& pTc) { const static std::string keys[] = { "class", "struct" }; // pop anonymous scope p_Repos->scopeStack().pop(); // push type scope std::string name; for (int i=0,len;i<2;i++) if ((len = pTc->find(keys[i]))<pTc->call(new JustNewClass0)) name = (*pTc)[len +1]; element elem; elem.type = "type"; elem.name = name; elem.lineCount = p_Repos->lineCount(); std::cout<<"\n "<<elem.show(); p_Repos->scopeStack().push(elem); }
void BupSlave::get(const KUrl& pUrl) { QStringList lPathInRepo; if(!checkCorrectRepository(pUrl, lPathInRepo)) { emit error(KIO::ERR_SLAVE_DEFINED, i18n("No bup repository found.\n%1", pUrl.prettyUrl())); return; } // Assume that a symlink should be followed. // Kio will never call get() on a symlink if it actually wants to copy a // symlink, it would just create a symlink on the destination kioslave using the // target it already got from calling stat() on this one. Node *lNode = mRepository->resolve(lPathInRepo, true); if(lNode == NULL) { emit error(KIO::ERR_DOES_NOT_EXIST, lPathInRepo.join(QLatin1String("/"))); return; } File *lFile = qobject_cast<File *>(lNode); if(lFile == NULL) { emit error(KIO::ERR_IS_DIRECTORY, lPathInRepo.join(QLatin1String("/"))); return; } emit mimeType(lFile->mMimeType); // Emit total size AFTER mimetype emit totalSize(lFile->size()); //make sure file is at the beginning lFile->seek(0); KIO::filesize_t lProcessedSize = 0; const QString lResumeOffset = metaData(QLatin1String("resume")); if(!lResumeOffset.isEmpty()) { bool ok; KIO::fileoffset_t lOffset = lResumeOffset.toLongLong(&ok); if (ok && (lOffset > 0) && ((quint64)lOffset < lFile->size())) { if(0 == lFile->seek(lOffset)) { emit canResume(); lProcessedSize = lOffset; } } } QByteArray lResultArray; int lRetVal; while(0 == (lRetVal = lFile->read(lResultArray))) { emit data(lResultArray); lProcessedSize += lResultArray.length(); emit processedSize(lProcessedSize); } if(lRetVal == KIO::ERR_NO_CONTENT) { emit data(QByteArray()); emit processedSize(lProcessedSize); emit finished(); } else { emit error(lRetVal, lPathInRepo.join(QLatin1String("/"))); } }
int main(int argc, char **argv) { Fl::background(0xEE,0xEE,0xEE); Fl::background2(0xFF,0xFF,0xFF); //Fl::get_system_colors(); Fl::scheme("gtk+"); #ifdef WIN32 WSADATA wsa; if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) { cout << "WSAStartup failed: " << WSAGetLastError() << endl; return 1; } #endif NeoStore dlg; Fl_Double_Window* window = dlg.create_window(); RepositoryManager* repoMgr = RepositoryManager::getInstance(); Repository mainRepo; mainRepo.setServer(DEFAULT_HOST); repoMgr->addRepository(mainRepo); repoMgr->updatePackageInformation(); vector<Repository::Package> packages; repoMgr->getPackageList(&packages); for(int i = 0; i < packages.size(); i++) { Repository::Package* p = (Repository::Package*) malloc(sizeof(Repository::Package)); new(p) Repository::Package(); *p = packages[i]; dlg.available_packages->add(packages[i].name.c_str(), (void*) p); cout << "Got package: " << packages[i].name << endl; } window->show(); return Fl::run(); }
SkillEdit::SkillEdit(QWidget *parent) : QWidget(parent), ui(new Ui::SkillEdit), d(*new SkillEditPrivate) { ui->setupUi(this); //Find repository Repository *repo = REPOSITORY("Skill"); Q_ASSERT(repo); //Set up the filter model d.model = new QSortFilterProxyModel(this); d.model->setSourceModel(repo); d.model->setFilterKeyColumn(repo->column("name")); d.model->setFilterCaseSensitivity(Qt::CaseInsensitive); //Create the dock widget d.dockWidget = new SkillsDockWidget(d.model); //Configure the button box ui->buttonBox->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Cancel); //Add skill bases to their combobox QMetaEnum skillBaseEnum = ORM()->metaEnum("SkillBase"); for (int i=0; i<skillBaseEnum.keyCount(); ++i) { ui->base->addItem(skillBaseEnum.key(i)); } //Add skill categories to their combobox QMetaEnum skillCategoryEnum = ORM()->metaEnum("SkillCategory"); for (int i=0; i<skillCategoryEnum.keyCount(); ++i) { ui->category->addItem(skillCategoryEnum.key(i)); } //Set up the data widget mapper d.mapper = new DataWidgetMapper(this); d.mapper->setSubmitPolicy(DataWidgetMapper::ManualSubmit); d.mapper->setModel(repo); d.mapper->addMapping(ui->name, repo->column("name")); d.mapper->addMapping(ui->base, repo->column("base"), "currentIndex"); d.mapper->addMapping(ui->category, repo->column("category"), "currentIndex"); d.mapper->addMapping(ui->rulesPage, repo->column("rulesPage")); d.mapper->addMapping(ui->description, repo->column("description")); d.mapper->addMapping(ui->dieResults, repo->column("dieResults")); d.mapper->toFirst(); setStateUnmodified(); //Connect signals for un/modified data connect(d.mapper, SIGNAL(dataChanged()), this, SLOT(setStateModified())); //Connect signals for the button box connect(ui->buttonBox, SIGNAL(accepted()), d.mapper, SLOT(submit())); connect(ui->buttonBox, SIGNAL(rejected()), d.mapper, SLOT(revert())); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(setStateUnmodified())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(setStateUnmodified())); }
StagingDirDiff::StagingDirDiff(Tree *headCommitTree) { // get the diff const git_diff_options options = GIT_DIFF_OPTIONS_INIT; Repository *repo = headCommitTree->getRepository(); try { gitTest(git_diff_tree_to_index(&differences, repo->getInternalRepo(), headCommitTree->internalTree() , nullptr, &options)); } catch(GitException e) { stagingTreeDiffException(e); } processDifferences(); }
int main(){ Repository repo; Painting a{"Andi", "Flori", 2010}; Painting b{"Van Gogh", "The weird", 1970}; repo.addPainting(a); repo.addPainting(b); Repository special; Controller contr(repo, special); UI ui(contr); ui.run(); return 0; }
void RepositoryTest::testDescriptor() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testDescriptor() begin"); ModulePtr module = repository->getModule("mock1"); Module::dlclose_on_close = false; module->open(); moduleTest(module); module->close(); debug(LOG_DEBUG, DEBUG_LOG, 0, "testDescriptor() end"); }
bool BupSlave::checkCorrectRepository(const KUrl &pUrl, QStringList &pPathInRepository) { // make this slave accept most URLs.. even incorrect ones. (no slash (wrong), // one slash (correct), two slashes (wrong), three slashes (correct)) QString lPath; if(pUrl.hasHost()) { lPath = QLatin1String("/") + pUrl.host() + pUrl.path(KUrl::AddTrailingSlash); } else { lPath = pUrl.path(KUrl::AddTrailingSlash); if(!lPath.startsWith(QLatin1Char('/'))) { lPath.prepend(QLatin1Char('/')); } } if(mRepository && mRepository->isValid()) { if(lPath.startsWith(mRepository->objectName())) { lPath.remove(0, mRepository->objectName().length()); pPathInRepository = lPath.split(QLatin1Char('/'), QString::SkipEmptyParts); return true; } else { delete mRepository; mRepository = NULL; } } pPathInRepository = lPath.split(QLatin1Char('/'), QString::SkipEmptyParts); QString lRepoPath = QString::fromLatin1("/"); while(!pPathInRepository.isEmpty()) { // make sure the repo path will end with a slash lRepoPath += pPathInRepository.takeFirst(); lRepoPath += QLatin1String("/"); if((QFile::exists(lRepoPath + QLatin1String("objects")) && QFile::exists(lRepoPath + QLatin1String("refs"))) || (QFile::exists(lRepoPath + QLatin1String(".git/objects")) && QFile::exists(lRepoPath + QLatin1String(".git/refs")))) { mRepository = new Repository(NULL, lRepoPath); return mRepository->isValid(); } } return false; }
int LuaBridge::Log(lua_State* state) { Repository* repo = fetchRepository(state); CHECK_REPO(repo) RepositoryLog* log; try { log = repo->GetLog(); } catch (GitError e) { return pushErrorString(state, e); } LUA->CreateTable(); int i = 1; for (auto entry = log->log_entries.begin(); entry != log->log_entries.end(); ++entry) { LUA->PushNumber(i); LUA->CreateTable(); LUA->PushString("Ref"); LUA->PushString((*entry)->ref.c_str()); LUA->SetTable(-3); LUA->PushString("Message"); LUA->PushString((*entry)->commitmsg.c_str()); LUA->SetTable(-3); LUA->PushString("Committer"); LUA->PushString((*entry)->committer.c_str()); LUA->SetTable(-3); LUA->PushString("Author"); LUA->PushString((*entry)->author.c_str()); LUA->SetTable(-3); LUA->SetTable(-3); i++; } return 1; }
void SettingsDialog::addRepository() { int index = 0; QTreeWidgetItem *parent = m_ui->m_repositoriesView->currentItem(); if (parent && !m_rootItems.contains(parent)) { parent = parent->parent(); index = parent->indexOfChild(m_ui->m_repositoriesView->currentItem()); } if (parent) { Repository repository; repository.setEnabled(true); RepositoryItem *item = new RepositoryItem(repository); parent->insertChild(index, item); m_ui->m_repositoriesView->editItem(item, 4); m_ui->m_repositoriesView->scrollToItem(item); m_ui->m_repositoriesView->setCurrentItem(item); if (parent == m_rootItems.value(1)) m_ui->m_useTmpRepositories->setEnabled(parent->childCount() > 0); } }
void Gitarre::DisplayRepo(int i) { Repository *repo = Repos[i]; QTreeWidgetItem *item = new QTreeWidgetItem (QStringList (repo->GetName())); RepoView->insertTopLevelItem(i, item); if (repo->GetGitRepo ()) { StatusCbData cbData = { this, i, Gitarre::Add }; git_strarray *pathspec = pathspecAll (); git_status_options cbOptns = { 1, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_INCLUDE_IGNORED | GIT_STATUS_OPT_INCLUDE_UNMODIFIED | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS | GIT_STATUS_OPT_RECURSE_IGNORED_DIRS, *pathspec }; git_status_foreach_ext (repo->GetGitRepo(), &cbOptns, Gitarre::sStatusCb, (void *)&cbData); git_strarray_free (pathspec); // AddSubfolders (i, item, repo->GetDir()); } else item->setForeground(0, QBrush (QColor(Qt::red))); update (); }
static int doscript(lua_State *L) { Repository* rep = LuaSpecFactory::getRepository( L ); assert( rep ); const char* name = luaL_checkstring( L, 1 ); Repository::ScriptMap::const_iterator p = rep->getScripts().find( name ); if( p == rep->getScripts().end() ) luaL_error( L, "Cannot find script %s", name ); Script* s = (*p).second; int status = luaL_loadbuffer( L, s->getCode(), strlen( s->getCode() ), name ); if( status == 0 ) { status = lua_pcall( L, 0, LUA_MULTRET, 0 ); } if( status != 0 ) { // Auf Stack befindet sich die Fehlermeldung luaL_error( L, lua_tostring( L, -1) ); } s->setCompiled(); return 0; }
void push_range(Repository const & repo, RevWalker const & walk, const char *range, int hide) { auto revspec = repo.revparse(range); if (revspec.flags() & GIT_REVPARSE_MERGE_BASE) { /* TODO: support "<commit>...<commit>" */ throw std::runtime_error("unsupported operation"); } auto const & r = *revspec.range(); push_commit(walk, r.to.id(), !hide); push_commit(walk, r.from.id(), hide); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); Tester t; t.test1(); Repository* repo = new Repository("/Users/AndiD/Documents/C++/exam/prog.txt"); Controller* ctr = new Controller(repo); vector<GUI*> widgets; for ( auto it : repo->getProgs()){ GUI* window = new GUI(ctr, it); window->show(); repo->attachObserver((Observer*) window); widgets.push_back(window); } int rez = a.exec(); for( auto it : widgets ){ delete it; } delete repo; delete ctr; return rez; }