Package org.tmatesoft.hg.internal

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


    cmd.file(file);
    final Nodeid cset = Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554");
    cmd.changeset(cset);
    final ByteArrayChannel sink = new ByteArrayChannel();
    cmd.execute(sink);
    final int result1 = sink.toArray().length;
    HgChangesetFileSneaker i = new HgChangesetFileSneaker(repo);
    boolean result = i.changeset(cset).checkExists(file);
    assertFalse(result);
    assertFalse(i.exists());
    result = i.followRenames(true).checkExists(file);
View Full Code Here


    assertTrue(result);
    assertTrue(i.exists());
    HgCatCommand cmd2 = new HgCatCommand(repo).revision(i.getFileRevision());
    final ByteArrayChannel sink2 = new ByteArrayChannel();
    cmd2.execute(sink2);
    final int result2 = sink2.toArray().length;
    assertEquals(result1, result2);
  }

  // ensure code to follow rename history in the command is correct
  @Test
View Full Code Here

    cmd2.file(Path.create("c"));
    ByteArrayChannel sink1, sink2;
    // a from wc/tip was c in rev 4
    cmd1.changeset(4).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(4).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink2.toArray(), sink1.toArray());
    //
    // d from wc/tip was a in 0..2 and b in rev 3..4. Besides, there's another d in r4
    cmd2.file(Path.create("d"));
    cmd1.changeset(2).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(2).execute(sink2 = new ByteArrayChannel());
View Full Code Here

    //
    // d from wc/tip was a in 0..2 and b in rev 3..4. Besides, there's another d in r4
    cmd2.file(Path.create("d"));
    cmd1.changeset(2).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(2).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
    //
    cmd1.file(Path.create("b"));
    cmd1.changeset(3).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(3).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
View Full Code Here

    assertArrayEquals(sink1.toArray(), sink2.toArray());
    //
    cmd1.file(Path.create("b"));
    cmd1.changeset(3).execute(sink1 = new ByteArrayChannel());
    cmd2.changeset(3).execute(sink2 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
    //
    cmd2.changeset(4).execute(sink2 = new ByteArrayChannel()); // ensure d in r4 is not from a or b
    assertArrayEquals("d:4\n".getBytes(), sink2.toArray());
    cmd2.changeset(5).execute(sink2 = new ByteArrayChannel()); // d in r5 is copy of b in r4
    cmd1.changeset(4).execute(sink1 = new ByteArrayChannel());
View Full Code Here

    //
    cmd2.changeset(4).execute(sink2 = new ByteArrayChannel()); // ensure d in r4 is not from a or b
    assertArrayEquals("d:4\n".getBytes(), sink2.toArray());
    cmd2.changeset(5).execute(sink2 = new ByteArrayChannel()); // d in r5 is copy of b in r4
    cmd1.changeset(4).execute(sink1 = new ByteArrayChannel());
    assertArrayEquals(sink1.toArray(), sink2.toArray());
  }
}
View Full Code Here

    final byte[] in2 = " continues here$\n3\n".getBytes();
    ByteArrayChannel out = new ByteArrayChannel();
    final Filter kwFilter = createFilter(Filter.Direction.ToRepo);
    out.write(kwFilter.filter(ByteBuffer.wrap(in1)));
    out.write(kwFilter.filter(ByteBuffer.wrap(in2)));
    Assert.assertEquals("1\n$Id$\n3\n", new String(out.toArray()));
    // Same as above, to extreme - only $ in the first buffer
    final Filter kwFilter2 = createFilter(Filter.Direction.ToRepo);
    out = new ByteArrayChannel();
    out.write(kwFilter2.filter(ByteBuffer.wrap("1\n$".getBytes())));
    out.write(kwFilter2.filter(ByteBuffer.wrap("Id:whatever continues here$\n3\n".getBytes())));
View Full Code Here

    // Same as above, to extreme - only $ in the first buffer
    final Filter kwFilter2 = createFilter(Filter.Direction.ToRepo);
    out = new ByteArrayChannel();
    out.write(kwFilter2.filter(ByteBuffer.wrap("1\n$".getBytes())));
    out.write(kwFilter2.filter(ByteBuffer.wrap("Id:whatever continues here$\n3\n".getBytes())));
    Assert.assertEquals("1\n$Id$\n3\n", new String(out.toArray()));
  }
 
  /**
   * what if input contains smth similar to keyword but unless the second part of the buffer
   * comes in, it's impossible to tell
View Full Code Here

    out.write(kwFilter.filter(ByteBuffer.wrap(in1)));
    out.write(kwFilter.filter(ByteBuffer.wrap(in2)));
    byte[] expected = new byte[in1.length + in2.length];
    System.arraycopy(in1, 0, expected, 0, in1.length);
    System.arraycopy(in2, 0, expected, in1.length, in2.length);
    Assert.assertEquals(new String(expected), new String(out.toArray()));
  }
 
  @Test
  public void testIncompleteKeywordAtEOF() throws Exception {
    initRepo();
View Full Code Here

      // WC doesn't have it anyway
      dataFile.content(fileRevisionIndex, bac);
    } catch (CancelledException ex) {
      // silently ignore - can't happen, ByteArrayChannel is not cancellable
    }
    return areTheSame(f, bac.toArray(), dataFile.getPath());
  }
 
  private boolean areTheSame(FileInfo f, final byte[] data, Path p) throws HgInvalidFileException {
    ReadableByteChannel is = null;
    class Check implements ByteChannel {
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.