Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.LineReader$LineConsumer


    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)));
            return true;
          }
        }, applied = new LinkedList<PatchRecord>());
      }
      if (fileSeries.isFile()) {
        final Map<String,PatchRecord> name2patch = new HashMap<String, PatchRecord>();
        for (PatchRecord pr : applied) {
          name2patch.put(pr.getName(), pr);
        }
        LinkedList<String> knownPatchNames = new LinkedList<String>();
        new LineReader(fileSeries, log).read(new LineReader.SimpleLineCollector(), knownPatchNames);
        // XXX read other queues?
        allKnown = new ArrayList<PatchRecord>(knownPatchNames.size());
        for (String name : knownPatchNames) {
          PatchRecord pr = name2patch.get(name);
          if (pr == null) {
View Full Code Here


    if (!f.exists()) {
      return this;
    }
    state = new HashMap<Nodeid, Nodeid>();
    try {
      LineReader lr = new LineReader(f, repo.getSessionContext().getLog());
      ArrayList<String> contents = new ArrayList<String>();
      lr.read(new LineReader.SimpleLineCollector(), contents);
      Iterator<String> it = contents.iterator();
      workingDirParent = Nodeid.fromAscii(it.next());
      destRevision = Nodeid.fromAscii(it.next());
      externalParent = Nodeid.fromAscii(it.next());
      collapse = "1".equals(it.next());
View Full Code Here

      final ManifestRevision m2 = new ManifestRevision(nodeidPool, fnamePool);
      if (!wcp2.isNull()) {
        final int rp2 = hgRepo.getChangelog().getRevisionIndex(wcp2);
        hgRepo.getManifest().walk(rp2, rp2, m2);
      }
      LineReader lr = new LineReader(f, repo.getLog());
      Iterator<String> lines = lr.read(new LineReader.SimpleLineCollector(), new ArrayList<String>()).iterator();
      String s = lines.next();
      stateParent = nodeidPool.unify(Nodeid.fromAscii(s));
      final int rp1 = hgRepo.getChangelog().getRevisionIndex(stateParent);
      hgRepo.getManifest().walk(rp1, rp1, m1);
      while (lines.hasNext()) {
View Full Code Here

    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));
View Full Code Here

  private void readActiveBookmark() throws HgInvalidControlFileException {
    activeBookmark = null;
    File active = repo.getRepositoryFile(HgRepositoryFiles.BookmarksCurrent);
    try {
      if (active.canRead() && active.isFile()) {
        LineReader lr2 = new LineReader(active, repo.getLog());
        ArrayList<String> c = new ArrayList<String>(2);
        lr2.read(new LineReader.SimpleLineCollector(), c);
        if (c.size() > 0) {
          activeBookmark = c.get(0);
        }
      }
      if (activeTracker == null) {
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.LineReader$LineConsumer

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.