Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ConfigFile$Parser


        super.setUp();
        WorkspaceImpl wsp = (WorkspaceImpl) superuser.getWorkspace();
        QueryManagerImpl qm = (QueryManagerImpl) wsp.getQueryManager();
        QueryObjectModelFactoryImpl factory = (QueryObjectModelFactoryImpl) qm
                .getQOMFactory();
        parser = new Parser(factory, superuser.getValueFactory());
    }
View Full Code Here


  private ManifestParseTree parse(InputStream inputStream) throws IOException, TokenizerException, ParserException {
    Preprocessor preprocessor = new ManifestPreprocessor();
    List<InputLine> contents = preprocessor.process(inputStream);
    Tokenizer tokenizer = new ManifestTokenizer(contents);

    Parser parser = new ManifestParser();
    return parser.parse(tokenizer);
  }
View Full Code Here

  private ManifestParseTree parse(InputStream inputStream) throws IOException, TokenizerException, ParserException {
    Preprocessor preprocessor = new ManifestPreprocessor();
    List<InputLine> contents = preprocessor.process(inputStream);
    Tokenizer tokenizer = new ManifestTokenizer(contents);

    Parser parser = new ManifestParser();
    return parser.parse(tokenizer);
  }
View Full Code Here

  Between two subsequent revisions (i.e. direct child in remote of a local root)
  cmd=between&pairs=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d-8c8e3f372fa1fbfcf92b004b6f2ada2dbaf60028
   empty result
   */
  public static void main(String[] args) throws Exception {
    ConfigFile cfg =  new ConfigFile(new BasicSessionContext(null));
    cfg.addLocation(new File(System.getProperty("user.home"), ".hgrc"));
    String svnkitServer = cfg.getSection("paths").get("svnkit");
//    URL url = new URL(svnkitServer + "?cmd=branches&nodes=30bd389788464287cee22ccff54c330a4b715de5");
//    URL url = new URL(svnkitServer + "?cmd=between");
    URL url = new URL(svnkitServer + "?cmd=changegroup&roots=71ddbf8603e8e09d54ac9c5fe4bb5ae824589f1d");
//    URL url = new URL("http://localhost:8000/" + "?cmd=between");
//    URL url = new URL(svnkitServer + "?cmd=stream_out");
View Full Code Here

    return new HgRemoteRepository(getSessionContext(), rd);
  }

  private ConfigFile getGlobalConfig() {
    if (globalCfg == null) {
      globalCfg = new ConfigFile(getSessionContext());
      try {
        globalCfg.addLocation(new File(System.getProperty("user.home"), ".hgrc"));
      } catch (HgIOException ex) {
        // XXX perhaps, makes sense to let caller/client know that we've failed to read global config?
        getSessionContext().getLog().dump(getClass(), Warn, ex, null);
View Full Code Here

   * @return access to configuration options, never <code>null</code>
   */
  public HgRepoConfig getConfiguration() /* XXX throws HgInvalidControlFileException? Description of the exception suggests it is only for files under ./hg/*/ {
    if (repoConfig == null) {
      try {
        ConfigFile configFile = impl.readConfiguration();
        repoConfig = new HgRepoConfig(configFile);
      } catch (HgIOException ex) {
        String m = "Errors while reading user configuration file";
        getSessionContext().getLog().dump(getClass(), Warn, ex, m);
        return new HgRepoConfig(new ConfigFile(getSessionContext())); // empty config, do not cache, allow to try once again
        //throw new HgInvalidControlFileException(m, ex, null);
      }
    }
    return repoConfig;
  }
View Full Code Here

  @Rule
  public ErrorCollectorExt errorCollector = new ErrorCollectorExt();

  @Test
  public void testConfigFile() throws Exception {
    ConfigFile configFile = new ConfigFile(new BasicSessionContext(null));
    configFile.addLocation(new File(Configuration.get().getTestDataDir(), "sample.rc"));
    // section1 has key1 unset, key2 overridden from included, key4 from second occurence
    HashMap<String, String> section1 = new HashMap<String, String>();
    section1.put("key2", "alternative value 2");
    section1.put("key3", "value 3");
    section1.put("key4", "value 4");
    // section2 comes from included config
    HashMap<String, String> section2 = new HashMap<String, String>();
    section2.put("key1", "value 1-2");
    HashMap<String, String> section3 = new HashMap<String, String>();
    section3.put("key1", "value 1-3");
    HashMap<String, HashMap<String,String>> sections = new HashMap<String, HashMap<String,String>>();
    sections.put("section1", section1);
    sections.put("section2", section2);
    sections.put("section3", section3);
    //
    for (String s : configFile.getSectionNames()) {
//      System.out.printf("[%s]\n", s);
      final HashMap<String, String> m = sections.remove(s);
      errorCollector.assertTrue(m != null);
      for (Map.Entry<String, String> e : configFile.getSection(s).entrySet()) {
//        System.out.printf("%s = %s\n", e.getKey(), e.getValue());
        if (m.containsKey(e.getKey())) {
          errorCollector.assertEquals(m.remove(e.getKey()), e.getValue());
        } else {
          errorCollector.fail("Unexpected key:" + e.getKey());
View Full Code Here

   * @throws HgIOException when configuration file read/write attemt has failed
   * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
   */
  public void execute() throws HgMissingConfigElementException, HgIOException, HgException {
    try {
      ConfigFile cfgRead = new ConfigFile(sessionCtx);
      cfgRead.addLocation(configFile);
      ConfigFileParser cfgWrite = new ConfigFileParser();
      FileInputStream fis = new FileInputStream(configFile);
      cfgWrite.parse(fis);
      fis.close();
      for (Operation op : changes) {
        if (!ignoreMissingKeys && !cfgRead.hasSection(op.section)) {
          throw new HgMissingConfigElementException("Bad section name", op.section, op.key);
        }
        Map<String, String> sect = cfgRead.getSection(op.section);
        if (!ignoreMissingKeys && !sect.containsKey(op.key)) {
          throw new HgMissingConfigElementException("Bad key name", op.section, op.key);
        }
        String oldValue = sect.get(op.key);
        if (oldValue == null) {
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.ConfigFile$Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.