Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 628:6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 22 May 2013 15:52:31 +0200 |
parents | e4a71afd3c71 |
children | a937e63b6e02 |
comparison
equal
deleted
inserted
replaced
627:5153eb73b18d | 628:6526d8adbc0f |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011-2012 TMate Software Ltd | 2 * Copyright (c) 2011-2013 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
55 import org.tmatesoft.hg.repo.HgDirstate; | 55 import org.tmatesoft.hg.repo.HgDirstate; |
56 import org.tmatesoft.hg.repo.HgDirstate.EntryKind; | 56 import org.tmatesoft.hg.repo.HgDirstate.EntryKind; |
57 import org.tmatesoft.hg.repo.HgDirstate.Record; | 57 import org.tmatesoft.hg.repo.HgDirstate.Record; |
58 import org.tmatesoft.hg.repo.HgIgnore; | 58 import org.tmatesoft.hg.repo.HgIgnore; |
59 import org.tmatesoft.hg.repo.HgInternals; | 59 import org.tmatesoft.hg.repo.HgInternals; |
60 import org.tmatesoft.hg.repo.HgInvalidControlFileException; | |
60 import org.tmatesoft.hg.repo.HgManifest; | 61 import org.tmatesoft.hg.repo.HgManifest; |
61 import org.tmatesoft.hg.repo.HgManifest.Flags; | 62 import org.tmatesoft.hg.repo.HgManifest.Flags; |
62 import org.tmatesoft.hg.repo.HgMergeState; | 63 import org.tmatesoft.hg.repo.HgMergeState; |
63 import org.tmatesoft.hg.repo.HgRepository; | 64 import org.tmatesoft.hg.repo.HgRepository; |
64 import org.tmatesoft.hg.repo.HgRevisionMap; | 65 import org.tmatesoft.hg.repo.HgRevisionMap; |
217 final long start = System.nanoTime(); | 218 final long start = System.nanoTime(); |
218 HgLogCommand cmd = new HgLogCommand(hgRepo); | 219 HgLogCommand cmd = new HgLogCommand(hgRepo); |
219 cmd.file("a2.txt", true, false); | 220 cmd.file("a2.txt", true, false); |
220 final int[] count = new int[] { 0 }; | 221 final int[] count = new int[] { 0 }; |
221 class MyHandler implements HgChangesetTreeHandler, Adaptable { | 222 class MyHandler implements HgChangesetTreeHandler, Adaptable { |
222 public void treeElement(HgChangesetTreeHandler.TreeElement entry) { | 223 public void treeElement(HgChangesetTreeHandler.TreeElement entry) throws HgRuntimeException { |
223 StringBuilder sb = new StringBuilder(); | 224 StringBuilder sb = new StringBuilder(); |
224 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions()); | 225 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions()); |
225 for (HgChangeset cc : entry.children()) { | 226 for (HgChangeset cc : entry.children()) { |
226 sb.append(cc.getRevisionIndex()); | 227 sb.append(cc.getRevisionIndex()); |
227 sb.append(':'); | 228 sb.append(':'); |
517 System.out.println(bac.toArray().length); | 518 System.out.println(bac.toArray().length); |
518 f2.content(0, bac = new ByteArrayChannel()); // 0: 14269 | 519 f2.content(0, bac = new ByteArrayChannel()); // 0: 14269 |
519 System.out.println(bac.toArray().length); | 520 System.out.println(bac.toArray().length); |
520 } | 521 } |
521 | 522 |
522 private void dumpIgnored() { | 523 private void dumpIgnored() throws HgInvalidControlFileException { |
523 String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"}; | 524 String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"}; |
524 HgIgnore ignore = hgRepo.getIgnore(); | 525 HgIgnore ignore = hgRepo.getIgnore(); |
525 for (int i = 0; i < toCheck.length; i++) { | 526 for (int i = 0; i < toCheck.length; i++) { |
526 System.out.println("Ignored " + toCheck[i] + ": " + ignore.isIgnored(Path.create(toCheck[i]))); | 527 System.out.println("Ignored " + toCheck[i] + ": " + ignore.isIgnored(Path.create(toCheck[i]))); |
527 } | 528 } |
607 System.out.println(">> " + manifestRevision); | 608 System.out.println(">> " + manifestRevision); |
608 } | 609 } |
609 public void dir(Path p) { | 610 public void dir(Path p) { |
610 System.out.println(p); | 611 System.out.println(p); |
611 } | 612 } |
612 public void file(HgFileRevision fileRevision) { | 613 public void file(HgFileRevision fileRevision) throws HgRuntimeException { |
613 System.out.print(fileRevision.getRevision());; | 614 System.out.print(fileRevision.getRevision());; |
614 System.out.print(" "); | 615 System.out.print(" "); |
615 System.out.printf("%s %s", fileRevision.getParents().first().shortNotation(), fileRevision.getParents().second().shortNotation()); | 616 System.out.printf("%s %s", fileRevision.getParents().first().shortNotation(), fileRevision.getParents().second().shortNotation()); |
616 System.out.print(" "); | 617 System.out.print(" "); |
617 System.out.println(fileRevision.getPath()); | 618 System.out.println(fileRevision.getPath()); |
670 } | 671 } |
671 } | 672 } |
672 } | 673 } |
673 | 674 |
674 | 675 |
675 private void testStatusInternals() throws HgException { | 676 private void testStatusInternals() throws HgException, HgRuntimeException { |
676 HgDataFile n = hgRepo.getFileNode(Path.create("design.txt")); | 677 HgDataFile n = hgRepo.getFileNode(Path.create("design.txt")); |
677 for (String s : new String[] {"011dfd44417c72bd9e54cf89b82828f661b700ed", "e5529faa06d53e06a816e56d218115b42782f1ba", "c18e7111f1fc89a80a00f6a39d51288289a382fc"}) { | 678 for (String s : new String[] {"011dfd44417c72bd9e54cf89b82828f661b700ed", "e5529faa06d53e06a816e56d218115b42782f1ba", "c18e7111f1fc89a80a00f6a39d51288289a382fc"}) { |
678 // expected: 359, 2123, 3079 | 679 // expected: 359, 2123, 3079 |
679 byte[] b = s.getBytes(); | 680 byte[] b = s.getBytes(); |
680 final Nodeid nid = Nodeid.fromAscii(b, 0, b.length); | 681 final Nodeid nid = Nodeid.fromAscii(b, 0, b.length); |