comparison cmdline/org/tmatesoft/hg/console/Bundle.java @ 182:f26ffe04ced0

Refactor HgBundle to dispatch changes found through callback
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 12 Apr 2011 19:36:18 +0200
parents 8c8e3f372fa1
children 9b99d27aeddc
comparison
equal deleted inserted replaced
181:cd3371670f0b 182:f26ffe04ced0
16 */ 16 */
17 package org.tmatesoft.hg.console; 17 package org.tmatesoft.hg.console;
18 18
19 import java.io.File; 19 import java.io.File;
20 20
21 import org.tmatesoft.hg.core.Nodeid;
21 import org.tmatesoft.hg.repo.HgBundle; 22 import org.tmatesoft.hg.repo.HgBundle;
23 import org.tmatesoft.hg.repo.HgChangelog;
22 import org.tmatesoft.hg.repo.HgLookup; 24 import org.tmatesoft.hg.repo.HgLookup;
23 import org.tmatesoft.hg.repo.HgRepository; 25 import org.tmatesoft.hg.repo.HgRepository;
26 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
24 27
25 28
26 /** 29 /**
27 * WORK IN PROGRESS, DO NOT USE 30 * WORK IN PROGRESS, DO NOT USE
28 * 31 *
30 * @author TMate Software Ltd. 33 * @author TMate Software Ltd.
31 */ 34 */
32 public class Bundle { 35 public class Bundle {
33 public static void main(String[] args) throws Exception { 36 public static void main(String[] args) throws Exception {
34 Options cmdLineOpts = Options.parse(args); 37 Options cmdLineOpts = Options.parse(args);
35 HgRepository hgRepo = cmdLineOpts.findRepository(); 38 final HgRepository hgRepo = cmdLineOpts.findRepository();
36 if (hgRepo.isInvalid()) { 39 if (hgRepo.isInvalid()) {
37 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); 40 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
38 return; 41 return;
39 } 42 }
40 File bundleFile = new File("/temp/hg/hg-bundle-000000000000-gz.tmp"); 43 File bundleFile = new File("/temp/hg/hg-bundle-a78c980749e3.tmp");
41 HgBundle hgBundle = new HgLookup().loadBundle(bundleFile); 44 HgBundle hgBundle = new HgLookup().loadBundle(bundleFile);
42 // hgBundle.dump(); 45 // hgBundle.dump();
43 /* 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 46 /* 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
44 +Changeset {User: ..., Comment: Integer ....} 47 +Changeset {User: ..., Comment: Integer ....}
45 +Changeset {User: ..., Comment: Approach with ...} 48 +Changeset {User: ..., Comment: Approach with ...}
46 -Changeset {User: ..., Comment: Correct project name...} 49 -Changeset {User: ..., Comment: Correct project name...}
47 -Changeset {User: ..., Comment: Record possible...} 50 -Changeset {User: ..., Comment: Record possible...}
48 */ 51 */
49 hgBundle.changes(hgRepo); 52 hgBundle.changes(hgRepo, new HgChangelog.Inspector() {
53 private final HgChangelog changelog = hgRepo.getChangelog();
54
55 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
56 if (changelog.isKnown(nodeid)) {
57 System.out.print("+");
58 } else {
59 System.out.print("-");
60 }
61 System.out.printf("%d:%s\n%s\n", revisionNumber, nodeid.shortNotation(), cset.toString());
62 }
63 });
50 } 64 }
51 65
52 /* 66 /*
53 * TODO EXPLAIN why DataAccess.java on merge from branch has P2 set, and P1 is NULL 67 * TODO EXPLAIN why DataAccess.java on merge from branch has P2 set, and P1 is NULL
54 * 68 *