Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Commit.java @ 592:b12cc3d64a35
Command-line sample for commit command
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 01 May 2013 14:03:10 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
591:e447384f3771 | 592:b12cc3d64a35 |
---|---|
1 /* | |
2 * Copyright (c) 2013 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.Collections; | |
20 | |
21 import org.tmatesoft.hg.core.HgCommitCommand; | |
22 import org.tmatesoft.hg.core.HgRepoFacade; | |
23 import org.tmatesoft.hg.util.Outcome; | |
24 | |
25 /** | |
26 * | |
27 * @author Artem Tikhomirov | |
28 * @author TMate Software Ltd. | |
29 */ | |
30 public class Commit { | |
31 | |
32 public static void main(String[] args) throws Exception { | |
33 Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet()); | |
34 HgRepoFacade repo = new HgRepoFacade(); | |
35 if (!repo.init(cmdLineOpts.findRepository())) { | |
36 System.err.printf("Can't find repository in: %s\n", repo.getRepository().getLocation()); | |
37 return; | |
38 } | |
39 String message = cmdLineOpts.getSingle("-m", "--message"); | |
40 if (message == null) { | |
41 System.err.println("Need a commit message"); | |
42 return; | |
43 } | |
44 HgCommitCommand cmd = repo.createCommitCommand(); | |
45 cmd.message(message); | |
46 Outcome o = cmd.execute(); | |
47 if (!o.isOk()) { | |
48 System.err.println(o.getMessage()); | |
49 return; | |
50 } | |
51 System.out.printf("New changeset: %s\n", cmd.getCommittedRevision().shortNotation()); | |
52 } | |
53 } |