Package org.tmatesoft.hg.repo

Examples of org.tmatesoft.hg.repo.HgLookup


  public void testPullFromNonPublishing() throws Exception {
    // copy, not clone as latter updates phase information
    File srcRepoLoc = RepoUtils.copyRepoToTempLocation("test-phases", "test-pull-nopub-src");
    File dstRepoLoc = RepoUtils.initEmptyTempRepo("test-pull-nopub-dst");
    Map<String,?> props = Collections.singletonMap(Internals.CFG_PROPERTY_CREATE_PHASEROOTS, true);
    final HgLookup hgLookup = new HgLookup(new BasicSessionContext(props, null));
    HgRepository srcRepo = hgLookup.detect(srcRepoLoc);   
    // revisions 6 and 9 are secret, so
    // index of revisions 4 and 5 won't change, but that of 7 and 8 would
    Nodeid r7 = srcRepo.getChangelog().getRevision(7);
    Nodeid r8 = srcRepo.getChangelog().getRevision(8);

    HgRepository dstRepo = hgLookup.detect(dstRepoLoc);
    HgServer server = new HgServer().publishing(false).start(srcRepoLoc);
    try {
      final HgRemoteRepository srcRemote = hgLookup.detect(server.getURL());
      new HgPullCommand(dstRepo).source(srcRemote).execute();
    } finally {
      server.stop();
    }
    PhasesHelper phaseHelper = new PhasesHelper(HgInternals.getImplementationRepo(dstRepo));
View Full Code Here


  }
 
  @Test
  public void testScheduleAddition() throws Exception {
    File testRepoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-addremove-1", false);
    repo = new HgLookup().detect(testRepoLoc);
   
    StatusOutputParser statusParser = new StatusOutputParser();
    eh = new ExecHelper(statusParser, testRepoLoc);
    eh.run("hg", "status", "-A");
    assertEquals("[sanity]", 0, statusParser.getUnknown().size());
View Full Code Here

  }
 
  @Test
  public void testScheduleRemoval() throws Exception {
    File testRepoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-addremove-2", false);
    repo = new HgLookup().detect(testRepoLoc);

    StatusOutputParser statusParser = new StatusOutputParser();
    eh = new ExecHelper(statusParser, testRepoLoc);
    eh.run("hg", "status", "-A");
    assertEquals("[sanity]", 0, statusParser.getUnknown().size());
View Full Code Here

  @Test
  public void testCommand() throws Exception {
    // get a copy of a repository
    File testRepoLoc = RepoUtils.cloneRepoToTempLocation(Configuration.get().find("log-1"), "test-revert", false);
   
    repo = new HgLookup().detect(testRepoLoc);
    Path targetFile = Path.create("b");
    RepoUtils.modifyFileAppend(new File(testRepoLoc, targetFile.toString()), "XXX");
   
    StatusOutputParser statusParser = new StatusOutputParser();
    eh = new ExecHelper(statusParser, testRepoLoc);
View Full Code Here

  public ErrorCollectorExt errorCollector = new ErrorCollectorExt();

 
  @Test
  public void testSingleParentBlame() throws Exception {
    HgRepository repo = new HgLookup().detectFromWorkingDir();
    final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
    final int checkChangeset = repo.getChangelog().getRevisionIndex(Nodeid.fromAscii("946b131962521f9199e1fedbdc2487d3aaef5e46")); // 539
    HgDataFile df = repo.getFileNode(fname);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    HgDiffCommand diffCmd = new HgDiffCommand(repo);
View Full Code Here

    Assert.assertArrayEquals(expected, apiResult);
  }
 
  @Test
  public void testFileLineAnnotate1() throws Exception {
    HgRepository repo = new HgLookup().detectFromWorkingDir();
    final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
    HgDataFile df = repo.getFileNode(fname);
    AnnotateRunner ar = new AnnotateRunner(df.getPath(), null);

    final HgDiffCommand diffCmd = new HgDiffCommand(repo);
View Full Code Here

    }
  }
 
  private void ddd() throws Throwable {
//    HgRepository repo = new HgLookup().detect("/home/artem/hg/blame-merge/");
    HgRepository repo = new HgLookup().detect("/home/artem/hg/junit-test-repos/test-annotate3/");
    final DiffOutInspector insp = new DiffOutInspector(System.out);
    insp.needRevisions(true);
    new HgDiffCommand(repo).file(Path.create("file1")).executeParentsAnnotate(insp);
  }
View Full Code Here

  @Test
  public void testWorkingCopyFileAccess() throws Exception {
    final File repoDir = RepoUtils.initEmptyTempRepo("testWorkingCopyFileAccess");
    final Map<String, ?> props = Collections.singletonMap(Internals.CFG_PROPERTY_REVLOG_STREAM_CACHE, false);
    repo = new HgLookup(new BasicSessionContext(props, null)).detect(repoDir);
    File f1 = new File(repoDir, "file1");
    final String c1 = "First", c2 = "Second", c3 = "Third";
    ByteArrayChannel ch;
    ExecHelper exec = new ExecHelper(new OutputParser.Stub(), repoDir);
    // commit cset 0
View Full Code Here

  }

  @Test
  public void testSimple() throws Exception {
    int x = 0;
    HgLookup lookup = new HgLookup();
    for (HgRemoteRepository hgRemote : Configuration.get().allRemote()) {
      File dest = RepoUtils.initEmptyTempRepo("test-incoming-" + x++);
      HgRepository localRepo = lookup.detect(dest);
      // Idea:
      // hg in, hg4j in, compare
      // hg pull total/2
      // hg in, hg4j in, compare
      List<Nodeid> incoming = runAndCompareIncoming(localRepo, hgRemote);
      Assert.assertTrue("Need remote repository of reasonable size to test incoming command for partially filled case", incoming.size() >= 5);
      //
      Nodeid median = incoming.get(incoming.size() / 2);
      System.out.println("About to pull up to revision " + median.shortNotation());
      new ExecHelper(new OutputParser.Stub(), dest).run("hg", "pull", "-r", median.toString(), hgRemote.getLocation());
      //
      // shall re-read repository to pull up new changes
      localRepo = lookup.detect(dest);
      runAndCompareIncoming(localRepo, hgRemote);
    }
  }
View Full Code Here

  private File tempDir;
  private List<String> remoteServers;
  private File testDataDir;
 
  private Configuration() {
    lookup = new HgLookup();
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.repo.HgLookup

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.