Package org.tmatesoft.hg.util

Examples of org.tmatesoft.hg.util.LogFacility


    });
    System.out.println();
  }
 
  private void testConsoleLog() {
    LogFacility fc = new StreamLogFacility(Debug, true, System.out);
    System.out.printf("isDebug: %s, isInfo:%s\n", fc.isDebug(), fc.getLevel() == Info);
    fc.dump(getClass(), Debug, "%d", 1);
    fc.dump(getClass(), Info, "%d\n", 2);
    fc.dump(getClass(), Warn, "%d\n", 3);
    fc.dump(getClass(), Error, "%d", 4);
    Exception ex = new Exception();
    fc.dump(getClass(), Debug, ex, "message");
    fc.dump(getClass(), Info, ex, null);
    fc.dump(getClass(), Warn, ex, null);
    fc.dump(getClass(), Error, ex, "message");
  }
View Full Code Here


  public MqManager refresh() throws HgInvalidControlFileException {
    // MQ doesn't seem to use any custom lock mechanism.
    // MQ uses Mercurial's wc/store lock when updating repository (strip/new queue)
    applied = allKnown = Collections.emptyList();
    queueNames = Collections.emptyList();
    final LogFacility log = repo.getSessionContext().getLog();
    try {
      File queues = repo.getFileFromRepoDir("patches.queues");
      if (queues.isFile()) {
        LineReader lr = new LineReader(queues, log).trimLines(true).skipEmpty(true);
        lr.read(new LineReader.SimpleLineCollector(), queueNames = new LinkedList<String>());
      }
      final String queueLocation; // path under .hg to patch queue information (status, series and diff files)
      File activeQueueFile = repo.getFileFromRepoDir("patches.queue");
      // file is there only if it's not default queue ('patches') that is active
      if (activeQueueFile.isFile()) {
        ArrayList<String> contents = new ArrayList<String>();
        new LineReader(activeQueueFile, log).read(new LineReader.SimpleLineCollector(), contents);
        if (contents.isEmpty()) {
          log.dump(getClass(), Warn, "File %s with active queue name is empty", activeQueueFile.getName());
          activeQueue = PATCHES_DIR;
          queueLocation = PATCHES_DIR + '/';
        } else {
          activeQueue = contents.get(0);
          queueLocation = PATCHES_DIR + '-' + activeQueue +  '/';
        }
      } else {
        activeQueue = PATCHES_DIR;
        queueLocation = PATCHES_DIR + '/';
      }
      final Path.Source patchLocation = new Path.Source() {
       
        public Path path(CharSequence p) {
          StringBuilder sb = new StringBuilder(64);
          sb.append(".hg/");
          sb.append(queueLocation);
          sb.append(p);
          return Path.create(sb);
        }
      };
      final File fileStatus = repo.getFileFromRepoDir(queueLocation + "status");
      final File fileSeries = repo.getFileFromRepoDir(queueLocation + "series");
      if (fileStatus.isFile()) {
        new LineReader(fileStatus, log).read(new LineReader.LineConsumer<List<PatchRecord>>() {
 
          public boolean consume(String line, List<PatchRecord> result) throws IOException {
            int sep = line.indexOf(':');
            if (sep == -1) {
              log.dump(MqManager.class, Warn, "Bad line in %s:%s", fileStatus.getPath(), line);
              return true;
            }
            Nodeid nid = Nodeid.fromAscii(line.substring(0, sep));
            String name = new String(line.substring(sep+1));
            result.add(new PatchRecord(nid, name, patchLocation.path(name)));
View Full Code Here

      storeLock.acquire();
    } catch (HgRepositoryLockException ex) {
      try {
        wdLock.release();
      } catch (HgRepositoryLockException e2) {
        final LogFacility log = repo.getSessionContext().getLog();
        log.dump(getClass(), Error, e2, "Nested exception ignored once failed to acquire store lock");
      }
      throw ex;
    }

  }
View Full Code Here

      storeLock.release();
    } catch (HgRepositoryLockException ex) {
      try {
        wdLock.release();
      } catch (HgRepositoryLockException e2) {
        final LogFacility log = repo.getSessionContext().getLog();
        log.dump(getClass(), Error, e2, "Nested exception ignored when releasing working directory lock");
      }
      throw ex;
    }
    wdLock.release();
  }
View Full Code Here

      }
      try {
        if (f.canRead()) {
          new Parser().go(f, cfg);
        } else {
          LogFacility lf = cfg.sessionContext.getLog();
          lf.dump(ConfigFile.class, LogFacility.Severity.Debug, "Can't read file to  include: %s", f);
        }
      } catch (HgIOException ex) {
        LogFacility lf = cfg.sessionContext.getLog();
        lf.dump(ConfigFile.class, LogFacility.Severity.Warn, "Can't include %s (%s)", f, includeValue);
      }
    }
View Full Code Here

    readBookmarks();
    readActiveBookmark();
  }
 
  private void readBookmarks() throws HgRuntimeException {
    final LogFacility log = repo.getLog();
    File all = repo.getRepositoryFile(HgRepositoryFiles.Bookmarks);
    try {
      LinkedHashMap<String, Nodeid> bm = new LinkedHashMap<String, Nodeid>();
      if (all.canRead() && all.isFile()) {
        LineReader lr1 = new LineReader(all, log);
        ArrayList<String> c = new ArrayList<String>();
        lr1.read(new LineReader.SimpleLineCollector(), c);
        for (String s : c) {
          int x = s.indexOf(' ');
          try {
            if (x > 0) {
              Nodeid nid = Nodeid.fromAscii(s.substring(0, x));
              String name = new String(s.substring(x+1));
              if (repo.getRepo().getChangelog().isKnown(nid)) {
                // copy name part not to drag complete line
                bm.put(name, nid);
              } else {
                log.dump(getClass(), LogFacility.Severity.Info, "Bookmark %s points to non-existent revision %s, ignored.", name, nid);
              }
            } else {
              log.dump(getClass(), LogFacility.Severity.Warn, "Can't parse bookmark entry: %s", s);
            }
          } catch (IllegalArgumentException ex) {
            log.dump(getClass(), LogFacility.Severity.Warn, ex, String.format("Can't parse bookmark entry: %s", s));
          }
        }
        bookmarks = bm;
      } else {
        bookmarks = Collections.emptyMap();
View Full Code Here

    }
    if (metadata == null) {
      metadata = new Metadata(getRepo());
    }
    ErrorHandlingInspector insp;
    final LogFacility lf = getRepo().getSessionContext().getLog();
    if (metadata.none(fileRevisionIndex)) {
      insp = new ContentPipe(sink, 0, lf);
    } else if (metadata.known(fileRevisionIndex)) {
      insp = new ContentPipe(sink, metadata.dataOffset(fileRevisionIndex), lf);
    } else {
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.util.LogFacility

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.