Mercurial > hg4j
annotate cmdline/org/tmatesoft/hg/console/Log.java @ 578:f97e81d13190
Throw exception if repository encountered is too old for Hg4J
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 16:02:52 +0200 |
parents | 5dcb4581c8ef |
children | 6526d8adbc0f |
rev | line source |
---|---|
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
1 /* |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
2 * Copyright (c) 2010-2012 TMate Software Ltd |
72
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
3 * |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
7 * |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
11 * GNU General Public License for more details. |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
12 * |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
13 * For information on how to redistribute this software under |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
102
a3a2e5deb320
Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
98
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
72
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
17 package org.tmatesoft.hg.console; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
299
45dc79e545f5
Recognize flag options (options with no arguments) in command line sample apps
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
249
diff
changeset
|
19 import static org.tmatesoft.hg.console.Options.asSet; |
45dc79e545f5
Recognize flag options (options with no arguments) in command line sample apps
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
249
diff
changeset
|
20 |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
21 import java.util.List; |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
60
diff
changeset
|
22 |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
299
diff
changeset
|
23 import org.tmatesoft.hg.core.HgChangesetHandler; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
24 import org.tmatesoft.hg.core.HgFileRenameHandlerMixin; |
249
4c3b9f679412
Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
215
diff
changeset
|
25 import org.tmatesoft.hg.core.HgFileRevision; |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
26 import org.tmatesoft.hg.core.HgLogCommand; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
72
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgDataFile; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
72
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgRepository; |
215
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
29 import org.tmatesoft.hg.util.CancelSupport; |
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
30 import org.tmatesoft.hg.util.ProgressSupport; |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
31 |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 /** |
72
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
34 * @author Artem Tikhomirov |
9a03a80a0f2f
Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
35 * @author TMate Software Ltd. |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 */ |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 public class Log { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 |
197
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
143
diff
changeset
|
39 // -agentlib:hprof=heap=sites,depth=10,etc might be handy to debug speed/memory issues |
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
143
diff
changeset
|
40 |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 public static void main(String[] args) throws Exception { |
299
45dc79e545f5
Recognize flag options (options with no arguments) in command line sample apps
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
249
diff
changeset
|
42 Options cmdLineOpts = Options.parse(args, asSet("--debug", "-v", "--verbose", "--hg4j-order-direct")); |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
72
diff
changeset
|
43 HgRepository hgRepo = cmdLineOpts.findRepository(); |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 if (hgRepo.isInvalid()) { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 return; |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 } |
215
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
48 // |
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
49 // in fact, neither cancel nor progress of any use, need them just to check comamnd API |
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
50 final CancelSupport noCancel = CancelSupport.Factory.get(null); |
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
51 final ProgressSupport noProgress = ProgressSupport.Factory.get(null); |
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
52 // |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
53 final Dump dump = new Dump(hgRepo); |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
54 dump.complete(cmdLineOpts.getBoolean("--debug")); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
55 dump.verbose(cmdLineOpts.getBoolean("-v", "--verbose")); |
299
45dc79e545f5
Recognize flag options (options with no arguments) in command line sample apps
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
249
diff
changeset
|
56 final boolean reverseOrder = !cmdLineOpts.getBoolean("--hg4j-order-direct"); |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
57 dump.reversed(reverseOrder); |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
58 HgLogCommand cmd = new HgLogCommand(hgRepo); |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
59 for (String u : cmdLineOpts.getList("-u", "--user")) { |
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
60 cmd.user(u); |
49
26e3eeaa3962
branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
61 } |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
62 for (String b : cmdLineOpts.getList("-b", "--branches")) { |
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
63 cmd.branch(b); |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
60
diff
changeset
|
64 } |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
65 int limit = cmdLineOpts.getSingleInt(-1, "-l", "--limit"); |
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
66 if (limit != -1) { |
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
67 cmd.limit(limit); |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
60
diff
changeset
|
68 } |
215
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
69 cmd.set(noCancel).set(noProgress); |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
70 List<String> files = cmdLineOpts.getList(""); |
197
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
143
diff
changeset
|
71 final long start = System.currentTimeMillis(); |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
72 if (files.isEmpty()) { |
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
73 if (limit == -1) { |
49
26e3eeaa3962
branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
74 // no revisions and no limit |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
60
diff
changeset
|
75 cmd.execute(dump); |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
76 } else { |
49
26e3eeaa3962
branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
77 // in fact, external (to dump inspector) --limit processing yelds incorrect results when other args |
26e3eeaa3962
branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
78 // e.g. -u or -b are used (i.e. with -u shall give <limit> csets with user, not check last <limit> csets for user |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
79 int[] r = new int[] { 0, hgRepo.getChangelog().getRevisionCount() }; |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
80 if (fixRange(r, reverseOrder, limit) == 0) { |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
81 System.out.println("No changes"); |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
82 return; |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
83 } |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
60
diff
changeset
|
84 cmd.range(r[0], r[1]).execute(dump); |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
85 } |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
86 dump.done(); |
6
5abe5af181bd
Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
87 } else { |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
88 for (String fname : files) { |
6
5abe5af181bd
Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
89 HgDataFile f1 = hgRepo.getFileNode(fname); |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
6
diff
changeset
|
90 System.out.println("History of the file: " + f1.getPath()); |
143
b9700740553a
Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
91 if (limit == -1) { |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
92 cmd.file(f1.getPath(), true).execute(dump); |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
93 } else { |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
94 int[] r = new int[] { 0, f1.getRevisionCount() }; |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
95 if (fixRange(r, reverseOrder, limit) == 0) { |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
96 System.out.println("No changes"); |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
97 continue; |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
98 } |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
99 cmd.range(r[0], r[1]).file(f1.getPath(), true).execute(dump); |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
100 } |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
101 dump.done(); |
6
5abe5af181bd
Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
102 } |
5abe5af181bd
Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
103 } |
197
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
143
diff
changeset
|
104 // cmd = null; |
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
143
diff
changeset
|
105 System.out.println("Total time:" + (System.currentTimeMillis() - start)); |
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
143
diff
changeset
|
106 // Main.force_gc(); |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 } |
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
108 |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
109 private static int fixRange(int[] start_end, boolean reverse, int limit) { |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
110 assert start_end.length == 2; |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
111 if (limit < start_end[1]) { |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
112 if (reverse) { |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
113 // adjust left boundary of the range |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
114 start_end[0] = start_end[1] - limit; |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
115 } else { |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
116 start_end[1] = limit; // adjust right boundary |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
117 } |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
118 } |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
119 int rv = start_end[1] - start_end[0]; |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
120 start_end[1]--; // range needs index, not length |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
121 return rv; |
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
122 } |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
123 |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
299
diff
changeset
|
124 private static final class Dump extends ChangesetDumpHandler implements HgChangesetHandler.WithCopyHistory { |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
125 private final RenameDumpHandler renameHandlerDelegate; |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
126 |
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
127 public Dump(HgRepository hgRepo) { |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
198
diff
changeset
|
128 super(hgRepo); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
129 renameHandlerDelegate = new RenameDumpHandler(); |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
130 } |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
131 |
249
4c3b9f679412
Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
215
diff
changeset
|
132 public void copy(HgFileRevision from, HgFileRevision to) { |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
133 renameHandlerDelegate.copy(from, to); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
134 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
135 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
136 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
137 static class RenameDumpHandler implements HgFileRenameHandlerMixin { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
138 public void copy(HgFileRevision from, HgFileRevision to) { |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
139 System.out.printf("Got notified that %s(%s) was originally known as %s(%s)\n", to.getPath(), to.getRevision(), from.getPath(), from.getRevision()); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
140 } |
47
b01500fe2604
Log command output to match 'hg log'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
141 } |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 } |