Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.ByteArrayChannel.toArray()


  public void testContent() throws Exception {
    repo = Configuration.get().find("log-1");
    final byte[] expectedContent = new byte[] { 'a', ' ', 13, 10 };
    ByteArrayChannel ch = new ByteArrayChannel();
    repo.getFileNode("dir/b").content(0, ch);
    assertArrayEquals(expectedContent, ch.toArray());
    repo.getFileNode("d").content(HgRepository.TIP, ch = new ByteArrayChannel() );
    assertArrayEquals(expectedContent, ch.toArray());
  }

  @Test
View Full Code Here


    final byte[] expectedContent = new byte[] { 'a', ' ', 13, 10 };
    ByteArrayChannel ch = new ByteArrayChannel();
    repo.getFileNode("dir/b").content(0, ch);
    assertArrayEquals(expectedContent, ch.toArray());
    repo.getFileNode("d").content(HgRepository.TIP, ch = new ByteArrayChannel() );
    assertArrayEquals(expectedContent, ch.toArray());
  }

  @Test
  public void testStripMetadata() throws Exception {
    repo = Configuration.get().find("log-1");
View Full Code Here

    Assert.assertTrue(dir_b.isCopy());
    Assert.assertEquals("b", dir_b.getCopySourceName().toString());
    Assert.assertEquals("e44751cdc2d14f1eb0146aa64f0895608ad15917", dir_b.getCopySourceRevision().toString());
    dir_b.content(0, ch);
    // assert rawContent has 1 10 ... 1 10
    assertArrayEquals("a \r\n".getBytes(), ch.toArray());
    //
    // try once again to make sure metadata records/extracts correct offsets
    dir_b.content(0, ch = new ByteArrayChannel());
    assertArrayEquals("a \r\n".getBytes(), ch.toArray());
  }
View Full Code Here

    // assert rawContent has 1 10 ... 1 10
    assertArrayEquals("a \r\n".getBytes(), ch.toArray());
    //
    // try once again to make sure metadata records/extracts correct offsets
    dir_b.content(0, ch = new ByteArrayChannel());
    assertArrayEquals("a \r\n".getBytes(), ch.toArray());
  }

  @Test
  public void testWorkingCopyFileAccess() throws Exception {
    final File repoDir = RepoUtils.initEmptyTempRepo("testWorkingCopyFileAccess");
View Full Code Here

    write(f1, c3);
    //
    HgDataFile df = repo.getFileNode(f1.getName());
    // 1. Shall take content of the file from the dir
    df.workingCopy(ch = new ByteArrayChannel());
    assertArrayEquals(c3.getBytes(), ch.toArray());
    // 2. Shall supply working copy even if no local file is there
    f1.delete();
    assertFalse(f1.exists());
    df = repo.getFileNode(f1.getName());
    df.workingCopy(ch = new ByteArrayChannel());
View Full Code Here

    // 2. Shall supply working copy even if no local file is there
    f1.delete();
    assertFalse(f1.exists());
    df = repo.getFileNode(f1.getName());
    df.workingCopy(ch = new ByteArrayChannel());
    assertArrayEquals(c2.getBytes(), ch.toArray());
    //
    // 3. Shall extract revision of the file that corresponds actual parents (from dirstate) not the TIP as it was 
    exec.run("hg", "update", "-r", "0");
    assertEquals(0, exec.getExitValue());
    f1.delete();
View Full Code Here

    f1.delete();
    assertFalse(f1.exists());
    // there's no file and workingCopy shall do some extra work to find out actual revision to check out
    df = repo.getFileNode(f1.getName());
    df.workingCopy(ch = new ByteArrayChannel());
    assertArrayEquals(c1.getBytes(), ch.toArray());
  }

  private static void write(File f, String content) throws IOException {
    FileWriter fw = new FileWriter(f);
    fw.write(content);
View Full Code Here

      for (int i = 0; i <= hgTags.getLastRevision(); i++) { // TODO post-1.0 in fact, would be handy to have walk(start,end)
        // method for data files as well, though it looks odd.
        try {
          ByteArrayChannel sink = new ByteArrayChannel();
          hgTags.content(i, sink);
          final String content = new String(sink.toArray(), "UTF8");
          readGlobal(new StringReader(content));
        } catch (CancelledException ex) {
           // IGNORE, can't happen, we did not configure cancellation
          repo.getLog().dump(getClass(), Debug, ex, null);
        } catch (IOException ex) {
View Full Code Here

      }
      HgDataFile df = getFile(clogRevIndex);
      try {
        ByteArrayChannel c;
        df.content(fileRevIndex, c = new ByteArrayChannel());
        LineSequence rv = LineSequence.newlines(c.toArray());
        lruCache.addFirst(new Pair<Integer, LineSequence>(clogRevIndex, rv));
        if (lruCache.size() > limit) {
          lruCache.removeLast();
        }
        return rv;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.