Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Annotate.java @ 569:c4fd1037bc6f
Support for copy/rename follow/no-follow for annotate
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 10 Apr 2013 20:04:54 +0200 |
| parents | 32453f30de07 |
| children | 1c49c0cee540 |
comparison
equal
deleted
inserted
replaced
| 568:8ed4f4f4f0a6 | 569:c4fd1037bc6f |
|---|---|
| 14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
| 15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
| 16 */ | 16 */ |
| 17 package org.tmatesoft.hg.console; | 17 package org.tmatesoft.hg.console; |
| 18 | 18 |
| 19 import static java.util.Arrays.asList; | |
| 19 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
| 20 | 21 |
| 21 import java.util.Collections; | 22 import java.util.TreeSet; |
| 22 | 23 |
| 23 import org.tmatesoft.hg.core.HgAnnotateCommand; | 24 import org.tmatesoft.hg.core.HgAnnotateCommand; |
| 24 import org.tmatesoft.hg.core.HgAnnotateCommand.LineInfo; | 25 import org.tmatesoft.hg.core.HgAnnotateCommand.LineInfo; |
| 25 import org.tmatesoft.hg.core.HgRepoFacade; | 26 import org.tmatesoft.hg.core.HgRepoFacade; |
| 26 import org.tmatesoft.hg.repo.HgDataFile; | 27 import org.tmatesoft.hg.util.Path; |
| 27 | 28 |
| 28 /** | 29 /** |
| 29 * | 30 * |
| 30 * @author Artem Tikhomirov | 31 * @author Artem Tikhomirov |
| 31 * @author TMate Software Ltd. | 32 * @author TMate Software Ltd. |
| 32 */ | 33 */ |
| 33 public class Annotate { | 34 public class Annotate { |
| 34 | 35 |
| 35 public static void main(String[] args) throws Exception { | 36 public static void main(String[] args) throws Exception { |
| 36 Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet()); | 37 String[] boolOpts = new String[] {"-l", "--line-number" }; |
| 38 Options cmdLineOpts = Options.parse(args, new TreeSet<String>(asList(boolOpts))); | |
| 37 HgRepoFacade repo = new HgRepoFacade(); | 39 HgRepoFacade repo = new HgRepoFacade(); |
| 38 if (!repo.init(cmdLineOpts.findRepository())) { | 40 if (!repo.init(cmdLineOpts.findRepository())) { |
| 39 System.err.printf("Can't find repository in: %s\n", repo.getRepository().getLocation()); | 41 System.err.printf("Can't find repository in: %s\n", repo.getRepository().getLocation()); |
| 40 return; | 42 return; |
| 41 } | 43 } |
| 42 int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev"); | 44 int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev"); |
| 43 HgAnnotateCommand cmd = repo.createAnnotateCommand(); | 45 HgAnnotateCommand cmd = repo.createAnnotateCommand(); |
| 44 AnnotateDumpInspector insp = new AnnotateDumpInspector(cmdLineOpts.getBoolean(false, "-l", "--line-number")); | 46 AnnotateDumpInspector insp = new AnnotateDumpInspector(cmdLineOpts.getBoolean(false, "-l", "--line-number")); |
| 45 cmd.changeset(rev); | 47 cmd.changeset(rev); |
| 46 for (String fname : cmdLineOpts.getList("")) { | 48 for (String fname : cmdLineOpts.getList("")) { |
| 47 HgDataFile fn = repo.getRepository().getFileNode(fname); | 49 cmd.file(Path.create(fname)); |
| 48 cmd.file(fn); | |
| 49 cmd.execute(insp); | 50 cmd.execute(insp); |
| 50 } | 51 } |
| 51 } | 52 } |
| 52 | 53 |
| 53 private static class AnnotateDumpInspector implements HgAnnotateCommand.Inspector { | 54 private static class AnnotateDumpInspector implements HgAnnotateCommand.Inspector { |
| 57 lineNumbers = printLineNumbers; | 58 lineNumbers = printLineNumbers; |
| 58 } | 59 } |
| 59 | 60 |
| 60 public void next(LineInfo lineInfo) { | 61 public void next(LineInfo lineInfo) { |
| 61 if (lineNumbers) { | 62 if (lineNumbers) { |
| 62 System.out.printf("%3d:%3d:%s", lineInfo.getChangesetIndex(), lineInfo.getLineNumber(), new String(lineInfo.getContent())); | 63 System.out.printf("%3d:%3d: %s", lineInfo.getChangesetIndex(), lineInfo.getLineNumber(), new String(lineInfo.getContent())); |
| 63 } else { | 64 } else { |
| 64 System.out.printf("%3d:%s", lineInfo.getChangesetIndex(), new String(lineInfo.getContent())); | 65 System.out.printf("%3d: %s", lineInfo.getChangesetIndex(), new String(lineInfo.getContent())); |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 } | 69 } |
