Package org.tmatesoft.hg.repo

Examples of org.tmatesoft.hg.repo.HgLookup


  private HgRepository initRepo() throws Exception {
    final File repoLoc = RepoUtils.initEmptyTempRepo("test-kw-filter");
    final File hgrc = new File(repoLoc, HgRepositoryFiles.RepoConfig.getPath());
    RepoUtils.createFile(hgrc, "[extensions]\nkeyword=\n\n[keyword]\n**.*=\n");
    repo = new HgLookup().detect(repoLoc);
    return repo;
  }
View Full Code Here



  @Test
  public void testCleanCheckoutInEmptyDir() throws Exception {
    File testRepoLoc = cloneRepoToTempLocation("log-1", "test-checkout-clean", true);
    repo = new HgLookup().detect(testRepoLoc);
    // nothing but .hg dir
    assertEquals("[sanity]", 0, testRepoLoc.listFiles(new FilesOnlyFilter()).length);
   
    new HgCheckoutCommand(repo).clean(true).changeset(1).execute();
    errorCollector.assertEquals(2, testRepoLoc.listFiles(new FilesOnlyFilter()).length);
View Full Code Here

    assertTrue("[sanity]", modifiedFile.canRead());
    final long modifiedFileInitialLen = modifiedFile.length();
    RepoUtils.modifyFileAppend(modifiedFile, "the change shall not survive");
    assertTrue("[sanity]", modifiedFile.length() > modifiedFileInitialLen);
    //
    repo = new HgLookup().detect(repoLoc);
    new HgCheckoutCommand(repo).clean(true).changeset(TIP).execute();
    errorCollector.assertTrue(untrackedFile.canRead());
    errorCollector.assertEquals(modifiedFileInitialLen, modifiedFile.length());
  }
View Full Code Here

  }

  @Test
  public void testBranchCheckout() throws Exception {
    File testRepoLoc = cloneRepoToTempLocation("log-branches", "test-checkoutBranch", true);
    repo = new HgLookup().detect(testRepoLoc);
   
    new HgCheckoutCommand(repo).clean(true).changeset(3 /*branch test*/).execute();

    StatusOutputParser statusOutputParser = new StatusOutputParser();
    eh = new ExecHelper(statusOutputParser, testRepoLoc);
View Full Code Here

  }
 
  @Test
  public void testCheckoutLinkAndExec() throws Exception {
    File testRepoLoc = cloneRepoToTempLocation("test-flags", "test-checkout-flags", true);
    repo = new HgLookup().detect(testRepoLoc);
    new HgCheckoutCommand(repo).clean(true).changeset(0).execute();

    Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(testRepoLoc), repo.getToRepoPathHelper()));
    FileWalker fw = new FileWalker(repo, testRepoLoc, pathSrc, null);
    int execFound, linkFound, regularFound;
View Full Code Here

    String ext2_key = "ext.disabled"; // disabled
    String ext3_key = "hgext.two"; // check if found by "two" key
    String hgrcContent = String.format("#comment\n[ui]\nusername = %s\n\n[paths]\n%s = %s\ndefault=%3$s\n\n[extensions]\n%s = \n%s = !\n%s=\n", username, path1_key, path1_value, ext1_key, ext2_key, ext3_key);
    RepoUtils.createFile(hgrc, hgrcContent);
    //
    HgRepository repo = new HgLookup().detect(repoLoc);
    final HgRepoConfig cfg = repo.getConfiguration();
    assertNotNull(cfg.getPaths());
    assertNotNull(cfg.getExtensions());
    final Section dne = cfg.getSection("does-not-exist");
    assertNotNull(dne);
View Full Code Here

  public void testCommitToNonEmpty() throws Exception {
    File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2non-empty");
    RepoUtils.createFile(new File(repoLoc, "file1"), "hello\n");
    new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST");
    //
    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), 0);
    HgDataFile df = hgRepo.getFileNode("file1");
    cf.add(df, new ByteArrayDataSource("hello\nworld".getBytes()));
    Transaction tr = newTransaction(hgRepo);
    Nodeid secondRev = cf.commit("SECOND", tr);
View Full Code Here

    File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2empty");
    String fname = "file1";
    RepoUtils.createFile(new File(repoLoc, fname), null);
    new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "add", fname);
    //
    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    assertEquals("[sanity]", 0, new HgLogCommand(hgRepo).execute().size());
    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), NO_REVISION);
    HgDataFile df = hgRepo.getFileNode(fname);
    final byte[] initialContent = "hello\nworld".getBytes();
    cf.add(df, new ByteArrayDataSource(initialContent));
View Full Code Here

  }
 
  @Test
  public void testCommitIntoBranch() throws Exception {
    File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-commit2branch", false);
    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    HgDataFile dfD = hgRepo.getFileNode("d");
    assertTrue("[sanity]", dfD.exists());
    File fileD = new File(repoLoc, "d");
    assertTrue("[sanity]", fileD.canRead());
    final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision();
View Full Code Here

   * use own add and remove commands and then commit
   */
  @Test
  public void testCommitWithAddRemove() throws Exception {
    File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-add-remove-commit", false);
    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    assertTrue("[sanity]", hgRepo.getFileNode("d").exists());
    assertTrue("[sanity]", new File(repoLoc, "d").canRead());
    RepoUtils.createFile(new File(repoLoc, "xx"), "xyz");
    new HgAddRemoveCommand(hgRepo).add(Path.create("xx")).remove(Path.create("d")).execute();
    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), hgRepo.getChangelog().getLastRevision());
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.