comparison hg4j-cli/src/main/java/org/tmatesoft/hg/console/Outgoing.java @ 213:6ec4af642ba8 gradle

Project uses Gradle for build - actual changes
author Alexander Kitaev <kitaev@gmail.com>
date Tue, 10 May 2011 10:52:53 +0200
parents
children
comparison
equal deleted inserted replaced
212:edb2e2829352 213:6ec4af642ba8
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
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
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.console;
18
19 import java.util.Collection;
20 import java.util.List;
21
22 import org.tmatesoft.hg.core.HgOutgoingCommand;
23 import org.tmatesoft.hg.core.HgRepoFacade;
24 import org.tmatesoft.hg.core.Nodeid;
25 import org.tmatesoft.hg.repo.HgLookup;
26 import org.tmatesoft.hg.repo.HgRemoteRepository;
27
28
29 /**
30 * <em>hg outgoing</em>
31 *
32 * @author Artem Tikhomirov
33 * @author TMate Software Ltd.
34 */
35 public class Outgoing {
36
37 public static void main(String[] args) throws Exception {
38 Options cmdLineOpts = Options.parse(args);
39 HgRepoFacade hgRepo = new HgRepoFacade();
40 if (!hgRepo.init(cmdLineOpts.findRepository())) {
41 System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
42 return;
43 }
44 // XXX perhaps, HgRepoFacade shall get detectRemote() analog (to get remote server with respect of facade's repo)
45 HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository());
46 if (hgRemote.isInvalid()) {
47 System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
48 return;
49 }
50 //
51 HgOutgoingCommand cmd = hgRepo.createOutgoingCommand();
52 cmd.against(hgRemote);
53
54 // find all local children of commonKnown
55 List<Nodeid> result = cmd.executeLite(null);
56 dump("Lite", result);
57 //
58 //
59 System.out.println("Full");
60 // show all, starting from next to common
61 final ChangesetDumpHandler h = new ChangesetDumpHandler(hgRepo.getRepository());
62 h.complete(cmdLineOpts.getBoolean("--debug")).verbose(cmdLineOpts.getBoolean("-v", "--verbose"));
63 cmd.executeFull(h);
64 h.done();
65 }
66
67 // public static class ChangesetFormatter {
68 // private final StringBuilder sb = new StringBuilder(1024);
69 //
70 // public CharSequence simple(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
71 // sb.setLength(0);
72 // sb.append(String.format("changeset: %d:%s\n", revisionNumber, nodeid.toString()));
73 // sb.append(String.format("user: %s\n", cset.user()));
74 // sb.append(String.format("date: %s\n", cset.dateString()));
75 // sb.append(String.format("comment: %s\n\n", cset.comment()));
76 // return sb;
77 // }
78 // }
79
80
81 static void dump(String s, Collection<Nodeid> c) {
82 System.out.println(s);
83 for (Nodeid n : c) {
84 System.out.println(n);
85 }
86 }
87 }