Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.HgRepoFacade


*/
public class Push {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepoFacade hgRepo = new HgRepoFacade();
    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    // XXX perhaps, HgRepoFacade shall get detectRemote() analog (to get remote server with respect of facade's repo)
    HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository());
    if (hgRemote.isInvalid()) {
      System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
      return;
    }
    HgPushCommand cmd = hgRepo.createPushCommand();
    cmd.destination(hgRemote);
    cmd.execute();
    System.out.printf("Added %d changesets\n", cmd.getPushedRevisions().size());
  }
View Full Code Here


  public static void main(String[] args) throws Exception {
    final Set<String> flagOpts = asSet("-A", "--all", "-m", "--modified", "-a", "--added", "-r", "--removed",
        "--d", "--deleted", "-u", "--unknown", "-c", "--clean", "-i", "--ignored",
        "-n", "--no-status", "-C", "--copies");
    Options cmdLineOpts = Options.parse(args, flagOpts);
    HgRepoFacade hgRepo = new HgRepoFacade();
    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    //
    HgStatusCommand cmd = hgRepo.createStatusCommand();
    if (cmdLineOpts.getBoolean("-A", "--all")) {
      cmd.all();
    } else {
      // default: mardu
      cmd.modified(cmdLineOpts.getBoolean(true, "-m", "--modified"));
View Full Code Here

*/
public class Merge {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, new HashSet<String>(Arrays.asList("--dry-run")));
    HgRepoFacade hgRepo = new HgRepoFacade();
    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    HgMergeCommand.Mediator m = null;
    if (cmdLineOpts.getBoolean("--dry-run") || Boolean.TRUE.booleanValue()) {
      m = new Dump();
    }
    final String revParam = cmdLineOpts.getSingle("-r", "--rev");
    final HgMergeCommand cmd = hgRepo.createMergeCommand();
    if (revParam.trim().length() == Nodeid.SIZE_ASCII) {
      cmd.changeset(Nodeid.fromAscii(revParam.trim()));
    } else {
      cmd.changeset(Integer.parseInt(revParam));
    }
View Full Code Here

    if (Boolean.FALSE.booleanValue()) {
      new SequenceConstructor().test();
      return;
    }
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepoFacade hgRepo = new HgRepoFacade();
    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository());
    if (hgRemote.isInvalid()) {
      System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
      return;
    }
    HgIncomingCommand cmd = hgRepo.createIncomingCommand();
    cmd.against(hgRemote);
    //
    List<Nodeid> missing = cmd.executeLite();
    Collections.reverse(missing); // useful to test output, from newer to older
    Outgoing.dump("Nodes to fetch:", missing);
    System.out.printf("Total: %d\n\n", missing.size());
    //
    // Complete
    final ChangesetDumpHandler h = new ChangesetDumpHandler(hgRepo.getRepository());
    h.complete(false); // this option looks up index of parent revision, done via repo.changelog (which doesn't have any of these new revisions)
    // this can be fixed by tracking all nodeid->revision idx inside ChangesetDumpHandler, and refer to repo.changelog only when that mapping didn't work
    h.verbose(cmdLineOpts.getBoolean("-v", "--verbose"));
    cmd.executeFull(h);
  }
View Full Code Here

*/
public class Pull {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepoFacade hgRepo = new HgRepoFacade();
    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository());
    if (hgRemote.isInvalid()) {
      System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
      return;
    }
    HgPullCommand cmd = hgRepo.createPullCommand();
    cmd.source(hgRemote);
    cmd.execute();
    System.out.printf("Sent %d changesets\n", cmd.getPulledRevisions().size());
  }
View Full Code Here

public class Annotate {

  public static void main(String[] args) throws Exception {
    String[] boolOpts = new String[] {"-l", "--line-number" };
    Options cmdLineOpts = Options.parse(args, new TreeSet<String>(asList(boolOpts)));
    HgRepoFacade repo = new HgRepoFacade();
    if (!repo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", repo.getRepository().getLocation());
      return;
    }
    int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev");
    HgAnnotateCommand cmd = repo.createAnnotateCommand();
    AnnotateDumpInspector insp = new AnnotateDumpInspector(cmdLineOpts.getBoolean(false, "-l", "--line-number"));
    cmd.changeset(rev);
    for (String fname : cmdLineOpts.getList("")) {
      cmd.file(Path.create(fname));
      cmd.execute(insp);
View Full Code Here

*/
public class Commit {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepoFacade repo = new HgRepoFacade();
    if (!repo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", repo.getRepository().getLocation());
      return;
    }
    String message = cmdLineOpts.getSingle("-m", "--message");
    if (message == null) {
      System.err.println("Need a commit message");
      return;
    }
    HgCommitCommand cmd = repo.createCommitCommand();
    cmd.message(message);
    Outcome o = cmd.execute();
    if (!o.isOk()) {
      System.err.println(o.getMessage());
      return;
View Full Code Here

*/
public class Outgoing {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepoFacade hgRepo = new HgRepoFacade();
    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    // XXX perhaps, HgRepoFacade shall get detectRemote() analog (to get remote server with respect of facade's repo)
    HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository());
    if (hgRemote.isInvalid()) {
      System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
      return;
    }
    //
    HgOutgoingCommand cmd = hgRepo.createOutgoingCommand();
    cmd.against(hgRemote);
   
    // find all local children of commonKnown
    List<Nodeid> result = cmd.executeLite();
    dump("Lite", result);
    //
    //
    System.out.println("Full");
    // show all, starting from next to common
    final ChangesetDumpHandler h = new ChangesetDumpHandler(hgRepo.getRepository());
    h.complete(cmdLineOpts.getBoolean("--debug")).verbose(cmdLineOpts.getBoolean("-v", "--verbose"));
    cmd.executeFull(h);
    h.done();
  }
View Full Code Here

    Assert.assertArrayEquals(change_3_9_old2new, insp.getReportedRevisionPairs());
  }

  @Test
  public void testAnnotateCmdFollowNoFollow() throws Exception {
    HgRepoFacade hgRepoFacade = new HgRepoFacade();
    HgRepository repo = Configuration.get().find("test-annotate2");
    hgRepoFacade.init(repo);
    HgAnnotateCommand cmd = hgRepoFacade.createAnnotateCommand();
    final Path fname = Path.create("file1b.txt");
    final int changeset = TIP;
    AnnotateInspector ai = new AnnotateInspector();

    cmd.changeset(changeset);
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.core.HgRepoFacade

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.