Esempio n. 1
0
  private void doExternalStatus(Map<File, File> externalsNew) throws SVNException {
    for (Iterator<File> paths = externalsNew.keySet().iterator(); paths.hasNext(); ) {
      File fullPath = paths.next();
      File wcRootAbsPath = externalsNew.get(fullPath);

      Structure<StructureFields.ExternalNodeInfo> externalInfo =
          SvnWcDbExternals.readExternal(
              getWcContext(), fullPath, wcRootAbsPath, StructureFields.ExternalNodeInfo.kind);
      ISVNWCDb.SVNWCDbKind externalKind = externalInfo.get(StructureFields.ExternalNodeInfo.kind);

      if (externalKind != ISVNWCDb.SVNWCDbKind.Dir) {
        continue;
      }

      if (SVNFileType.getType(fullPath) != SVNFileType.DIRECTORY) {
        continue;
      }
      handleEvent(
          SVNEventFactory.createSVNEvent(
              fullPath,
              SVNNodeKind.DIR,
              null,
              SVNRepository.INVALID_REVISION,
              SVNEventAction.STATUS_EXTERNAL,
              null,
              null,
              null),
          ISVNEventHandler.UNKNOWN);
      try {

        SvnGetStatus getStatus = getOperation().getOperationFactory().createGetStatus();
        getStatus.setSingleTarget(SvnTarget.fromFile(fullPath));
        getStatus.setRevision(SVNRevision.HEAD);
        getStatus.setDepth(getOperation().getDepth());
        getStatus.setRemote(getOperation().isRemote());
        getStatus.setReportAll(getOperation().isReportAll());
        getStatus.setReportIgnored(getOperation().isReportIgnored());
        getStatus.setReportExternals(getOperation().isReportExternals());
        getStatus.setReceiver(getOperation().getReceiver());
        getStatus.setFileListHook(getOperation().getFileListHook());

        getStatus.run();
      } catch (SVNException e) {
        if (e instanceof SVNCancelException) {
          throw e;
        }
      }
    }
  }
    public void bumpTo(SVNSqlJetDb sDb, File wcRootAbsPath) throws SVNException {
      /* Rename all pristine files, adding a ".svn-base" suffix. */
      File pristineDirAbsPath =
          SVNWCUtils.admChild(wcRootAbsPath, ISVNWCDb.PRISTINE_STORAGE_RELPATH);
      for (File dir : SVNFileListUtil.listFiles(pristineDirAbsPath)) {
        for (File file : SVNFileListUtil.listFiles(dir)) {
          /* If FINFO indicates that ABSPATH names a file, rename it to '<ABSPATH>.svn-base'.
           *
           * Ignore any file whose name is not the expected length, in order to make life easier for any developer
           * who runs this code twice or has some non-standard files in the pristine directory.
           */
          if (SVNFileType.getType(file) == SVNFileType.FILE
              && SVNFileUtil.getFileName(file).length() == PRISTINE_BASENAME_OLD_LEN) {
            File newAbsPath =
                SVNFileUtil.createFilePath(SVNFileUtil.getFilePath(file) + PRISTINE_STORAGE_EXT);
            SVNFileUtil.rename(file, newAbsPath);
          }
        }
      }

      /* Externals */
      try {
        sDb.getDb()
            .createTable(
                "CREATE TABLE EXTERNALS ( "
                    + "  wc_id  INTEGER NOT NULL REFERENCES WCROOT (id), "
                    + "  local_relpath  TEXT NOT NULL, "
                    + "  parent_relpath  TEXT NOT NULL, "
                    + "  repos_id  INTEGER NOT NULL REFERENCES REPOSITORY (id), "
                    + "  presence  TEXT NOT NULL, "
                    + "  kind  TEXT NOT NULL, "
                    + "  def_local_relpath         TEXT NOT NULL, "
                    + "  def_repos_relpath         TEXT NOT NULL, "
                    + "  def_operational_revision  TEXT, "
                    + "  def_revision              TEXT, "
                    + "  PRIMARY KEY (wc_id, local_relpath) "
                    + "); ");
        sDb.getDb()
            .createIndex("CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath);");
        sDb.getDb()
            .createIndex(
                "CREATE UNIQUE INDEX I_EXTERNALS_DEFINED ON EXTERNALS (wc_id, def_local_relpath, local_relpath);");
      } catch (SqlJetException e) {
        SVNSqlJetDb.createSqlJetError(e);
      }

      upgradeExternals(sDb, wcRootAbsPath);

      /* Format 29 introduces the EXTERNALS table (See STMT_CREATE_TRIGGERS) and optimizes a few trigger definitions. ... */
      // -- STMT_UPGRADE_TO_29
      try {
        if (sDb.getDb().getSchema().getTriggerNames().contains("nodes_update_checksum_trigger")) {
          sDb.getDb().dropTrigger("nodes_update_checksum_trigger");
        }
        if (sDb.getDb().getSchema().getTriggerNames().contains("nodes_insert_trigger")) {
          sDb.getDb().dropTrigger("nodes_insert_trigger");
        }
        if (sDb.getDb().getSchema().getTriggerNames().contains("nodes_delete_trigger")) {
          sDb.getDb().dropTrigger("nodes_delete_trigger");
        }
        sDb.getDb()
            .createTrigger(
                "CREATE TRIGGER nodes_update_checksum_trigger AFTER UPDATE OF checksum ON nodes WHEN NEW.checksum IS NOT OLD.checksum BEGIN UPDATE pristine SET refcount = refcount + 1 WHERE checksum = NEW.checksum; UPDATE pristine SET refcount = refcount - 1 WHERE checksum = OLD.checksum; END;");
        sDb.getDb()
            .createTrigger(
                "CREATE TRIGGER nodes_insert_trigger AFTER INSERT ON nodes WHEN NEW.checksum IS NOT NULL BEGIN UPDATE pristine SET refcount = refcount + 1 WHERE checksum = NEW.checksum; END;");
        sDb.getDb()
            .createTrigger(
                "CREATE TRIGGER nodes_delete_trigger AFTER DELETE ON nodes WHEN OLD.checksum IS NOT NULL BEGIN UPDATE pristine SET refcount = refcount - 1 WHERE checksum = OLD.checksum; END;");
      } catch (SqlJetException e) {
        SVNSqlJetDb.createSqlJetError(e);
      }

      setVersion(sDb, (int) 29);
    }