Package org.tmatesoft.hg.repo

Examples of org.tmatesoft.hg.repo.HgRepository


*/
public class Cat {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepository hgRepo = cmdLineOpts.findRepository();
    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev");
    OutputStreamChannel out = new OutputStreamChannel(System.out);
    for (String fname : cmdLineOpts.getList("")) {
      System.out.println(fname);
      HgDataFile fn = hgRepo.getFileNode(fname);
      if (fn.exists()) {
        fn.contentWithFilters(rev, out);
        System.out.println();
      } else {
        System.out.printf("%s not found!\n", fname);
View Full Code Here


* @author TMate Software Ltd.
*/
public class Bundle {
  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    final HgRepository hgRepo = cmdLineOpts.findRepository();
    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    File bundleFile = new File("/temp/hg/hg-bundle-cpython.tmp");
    HgBundle hgBundle = new HgLookup().loadBundle(bundleFile);
    hgBundle.inspectFiles(new Dump());
    if (Boolean.parseBoolean("true")) {
      return;
    }
    /* pass -R <path-to-repo-with-less-revisions-than-bundle>, e.g. for bundle with tip=168 and -R \temp\hg4j-50 with tip:159
    +Changeset {User: ..., Comment: Integer ....}
    +Changeset {User: ..., Comment: Approach with ...}
    -Changeset {User: ..., Comment: Correct project name...}
    -Changeset {User: ..., Comment: Record possible...}
    */
    hgBundle.changes(hgRepo, new HgChangelog.Inspector() {
      private final HgChangelog changelog = hgRepo.getChangelog();
     
      public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) throws HgRuntimeException {
        if (changelog.isKnown(nodeid)) {
          System.out.print("+");
        } else {
View Full Code Here

*/
public class Tags {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet());
    HgRepository hgRepo = cmdLineOpts.findRepository();
    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    HgTags tags = hgRepo.getTags();
    final HgChangelog clog = hgRepo.getChangelog();
    final Map<TagInfo, Integer> ti2index = new HashMap<TagInfo, Integer>();
    final TreeSet<TagInfo> sorted = new TreeSet<HgTags.TagInfo>(new Comparator<TagInfo>() {

      public int compare(TagInfo o1, TagInfo o2) {
        // reverse, from newer to older (bigger indexes first);
View Full Code Here

  // -agentlib:hprof=heap=sites,depth=10,etc might be handy to debug speed/memory issues
 
  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, asSet("--debug", "-v", "--verbose", "--hg4j-order-direct"));
    HgRepository hgRepo = cmdLineOpts.findRepository();
    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    //
    // in fact, neither cancel nor progress of any use, need them just to check comamnd API
    final CancelSupport noCancel = CancelSupport.Factory.get(null);
    final ProgressSupport noProgress = ProgressSupport.Factory.get(null);
    //
    final Dump dump = new Dump(hgRepo);
    dump.complete(cmdLineOpts.getBoolean("--debug"));
    dump.verbose(cmdLineOpts.getBoolean("-v", "--verbose"));
    final boolean reverseOrder = !cmdLineOpts.getBoolean("--hg4j-order-direct");
    dump.reversed(reverseOrder);
    HgLogCommand cmd = new HgLogCommand(hgRepo);
    for (String u : cmdLineOpts.getList("-u", "--user")) {
      cmd.user(u);
    }
    for (String b : cmdLineOpts.getList("-b", "--branches")) {
      cmd.branch(b);
    }
    int limit = cmdLineOpts.getSingleInt(-1, "-l", "--limit");
    if (limit != -1) {
      cmd.limit(limit);
    }
    cmd.set(noCancel).set(noProgress);
    List<String> files = cmdLineOpts.getList("");
    final long start = System.currentTimeMillis();
    if (files.isEmpty()) {
      if (limit == -1) {
        // no revisions and no limit
        cmd.execute(dump);
      } else {
        // in fact, external (to dump inspector) --limit processing yelds incorrect results when other args
        // e.g. -u or -b are used (i.e. with -u shall give <limit> csets with user, not check last <limit> csets for user
        int[] r = new int[] { 0, hgRepo.getChangelog().getRevisionCount() };
        if (fixRange(r, reverseOrder, limit) == 0) {
          System.out.println("No changes");
          return;
        }
        cmd.range(r[0], r[1]).execute(dump);
      }
      dump.done();
    } else {
      for (String fname : files) {
        HgDataFile f1 = hgRepo.getFileNode(fname);
        System.out.println("History of the file: " + f1.getPath());
        if (limit == -1) {
          cmd.file(f1.getPath(), true).execute(dump);
        } else {
          int[] r = new int[] { 0, f1.getRevisionCount() };
View Full Code Here

      System.out.println(l.getLocation());
      System.out.println(l.getSource());
      System.out.println(l.getType());
      System.out.println(l.isCommitted() ? l.getRevision() : "not yet committed");
      if (l.getType() == Kind.Hg) {
        HgRepository r = l.getRepo();
        System.out.printf("%s (%s) has %d revisions\n", l.getLocation(), r.getLocation(), r.getChangelog().getLastRevision() + 1);
        if (r.getChangelog().getLastRevision() >= 0) {
          final RawChangeset c = r.getChangelog().range(TIP, TIP).get(0);
          System.out.printf("TIP: %s %s '%s'\n", c.user(), c.dateString(), c.comment());
        }
      }
    }
  }
View Full Code Here

*/
public class Manifest {

  public static void main(String[] args) throws Exception {
    Options cmdLineOpts = Options.parse(args, asSet("--debug", "-v", "--verbose"));
    HgRepository hgRepo = cmdLineOpts.findRepository();
    if (hgRepo.isInvalid()) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
      return;
    }
    final boolean debug = cmdLineOpts.getBoolean("--debug");
    final boolean verbose = cmdLineOpts.getBoolean("-v", "--verbose");
    HgManifestHandler h = new HgManifestHandler() {
View Full Code Here

    patch1.read(new ByteArrayDataAccess(patchData.array(), patchData.arrayOffset(), patchData.remaining()));
    return patch1;
  }
 
  private byte[] getRevisionTrueContent(File repoLoc, final int manifestRev, int clogRev) throws HgRepositoryNotFoundException, IllegalArgumentException, HgRuntimeException {
    HgRepository hgRepo = new HgLookup().detect(repoLoc);
    final ByteArrayOutputStream out = new ByteArrayOutputStream(1024 * 1000);
    hgRepo.getManifest().walk(clogRev, clogRev, new HgManifest.Inspector() {
     
      public boolean next(Nodeid nid, Path fname, Flags flags) {
        try {
          out.write(fname.toString().getBytes());
          out.write(0);
View Full Code Here

  @Rule
  public ErrorCollectorExt errorCollector = new ErrorCollectorExt();

  @Test
  public void testHelperNoParentChildMap() throws Exception {
    HgRepository repo = Configuration.get().find("test-phases");
    HgPhase[] expected = readPhases(repo);
    final long start = System.nanoTime();
    PhasesHelper ph = new PhasesHelper(HgInternals.getImplementationRepo(repo), null);
    initAndCheck(ph, expected);
    final long end = System.nanoTime();
View Full Code Here

    System.out.printf("Without ParentWalker (simulates log command for single file): %,d μs\n", (end - start)/1000);
  }
 
  @Test
  public void testHelperWithParentChildMap() throws Exception {
    HgRepository repo = Configuration.get().find("test-phases");
    HgPhase[] expected = readPhases(repo);
    final long start1 = System.nanoTime();
    HgParentChildMap<HgChangelog> pw = new HgParentChildMap<HgChangelog>(repo.getChangelog());
    pw.init();
    final long start2 = System.nanoTime();
    PhasesHelper ph = new PhasesHelper(HgInternals.getImplementationRepo(repo), pw);
    initAndCheck(ph, expected);
    final long end = System.nanoTime();
View Full Code Here

    System.out.printf("With ParentWalker(simulates log command for whole repo): %,d μs (pw init: %,d ns)\n", (end - start1)/1000, start2 - start1);
  }
 
  @Test
  public void testAllSecretAndDraft() throws Exception {
    HgRepository repo = Configuration.get().find("test-phases");
    Internals implRepo = HgInternals.getImplementationRepo(repo);
    HgPhase[] expected = readPhases(repo);
    ArrayList<Nodeid> secret = new ArrayList<Nodeid>();
    ArrayList<Nodeid> draft = new ArrayList<Nodeid>();
    ArrayList<Nodeid> pub = new ArrayList<Nodeid>();
    for (int i = 0; i < expected.length; i++) {
      Nodeid n = repo.getChangelog().getRevision(i);
      switch (expected[i]) {
      case Secret : secret.add(n); break;
      case Draft : draft.add(n); break;
      case Public : pub.add(n); break;
      default : throw new IllegalStateException();
      }
    }
    final RevisionSet rsSecret = new RevisionSet(secret);
    final RevisionSet rsDraft = new RevisionSet(draft);
    assertFalse("[sanity]", rsSecret.isEmpty());
    assertFalse("[sanity]", rsDraft.isEmpty());
    HgParentChildMap<HgChangelog> pw = new HgParentChildMap<HgChangelog>(repo.getChangelog());
    pw.init();
    PhasesHelper ph1 = new PhasesHelper(implRepo, null);
    PhasesHelper ph2 = new PhasesHelper(implRepo, pw);
    RevisionSet s1 = ph1.allSecret().symmetricDifference(rsSecret);
    RevisionSet s2 = ph2.allSecret().symmetricDifference(rsSecret);
View Full Code Here

TOP

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

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.