Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgLogCommand.java @ 131:aa1629f36482
Renamed .core classes to start with Hg prefix
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 16 Feb 2011 20:47:56 +0100 |
parents | src/org/tmatesoft/hg/core/LogCommand.java@645829962785 |
children | 4a948ec83980 |
rev | line source |
---|---|
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
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:
94
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.util.Calendar; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.util.Collections; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import java.util.ConcurrentModificationException; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.util.LinkedList; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import java.util.List; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import java.util.Set; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import java.util.TreeSet; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
29 import org.tmatesoft.hg.repo.HgChangelog.Changeset; |
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
30 import org.tmatesoft.hg.repo.HgChangelog; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
31 import org.tmatesoft.hg.repo.HgDataFile; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
32 import org.tmatesoft.hg.repo.HgRepository; |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
33 import org.tmatesoft.hg.repo.HgStatusCollector; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 import org.tmatesoft.hg.util.PathPool; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 /** |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
38 * Access to changelog, 'hg log' command counterpart. |
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
39 * |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 * <pre> |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
41 * Usage: |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
42 * new LogCommand().limit(20).branch("maintenance-2.1").user("me").execute(new MyHandler()); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 * </pre> |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
44 * Not thread-safe (each thread has to use own {@link HgLogCommand} instance). |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 * @author Artem Tikhomirov |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 * @author TMate Software Ltd. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
49 public class HgLogCommand implements HgChangelog.Inspector { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 private final HgRepository repo; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 private Set<String> users; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 private Set<String> branches; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 private int limit = 0, count = 0; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 private int startRev = 0, endRev = TIP; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 private Handler delegate; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 private Calendar date; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
58 private Path file; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
59 private boolean followHistory; // makes sense only when file != null |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
60 private HgChangeset changeset; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
61 |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
62 public HgLogCommand(HgRepository hgRepo) { |
107 | 63 repo = hgRepo; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 * Limit search to specified user. Multiple user names may be specified. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 * @param user - full or partial name of the user, case-insensitive, non-null. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 * @return <code>this</code> instance for convenience |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
71 public HgLogCommand user(String user) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 if (user == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 if (users == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 users = new TreeSet<String>(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 users.add(user.toLowerCase()); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 * Limit search to specified branch. Multiple branch specification possible (changeset from any of these |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 * would be included in result). If unspecified, all branches are considered. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 * @param branch - branch name, case-sensitive, non-null. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 * @return <code>this</code> instance for convenience |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
88 public HgLogCommand branch(String branch) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 if (branch == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 if (branches == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 branches = new TreeSet<String>(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 branches.add(branch); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
99 // limit search to specific date |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
100 // multiple? |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
101 public HgLogCommand date(Calendar date) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 this.date = date; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 // FIXME implement |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 // isSet(field) - false => don't use in detection of 'same date' |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 throw HgRepository.notImplemented(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 * @param num - number of changeset to produce. Pass 0 to clear the limit. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 * @return <code>this</code> instance for convenience |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
113 public HgLogCommand limit(int num) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 limit = num; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
117 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
118 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 * Limit to specified subset of Changelog, [min(rev1,rev2), max(rev1,rev2)], inclusive. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 * Revision may be specified with {@link HgRepository#TIP} |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 * @param rev1 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 * @param rev2 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 * @return <code>this</code> instance for convenience |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
125 public HgLogCommand range(int rev1, int rev2) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 if (rev1 != TIP && rev2 != TIP) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 startRev = rev2 < rev1 ? rev2 : rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 endRev = startRev == rev2 ? rev1 : rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 } else if (rev1 == TIP && rev2 != TIP) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 startRev = rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 endRev = rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 } else { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 startRev = rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 endRev = rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
139 /** |
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
140 * Visit history of a given file only. |
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
141 * @param file path relative to repository root. Pass <code>null</code> to reset. |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
142 * @param followCopyRename true to report changesets of the original file(-s), if copy/rename ever occured to the file. |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
143 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
144 public HgLogCommand file(Path file, boolean followCopyRename) { |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
145 // multiple? Bad idea, would need to include extra method into Handler to tell start of next file |
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
146 this.file = file; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
147 followHistory = followCopyRename; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
148 return this; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
149 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
150 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
151 /** |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
152 * Similar to {@link #execute(org.tmatesoft.hg.repo.Changeset.Inspector)}, collects and return result as a list. |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
153 */ |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
154 public List<HgChangeset> execute() { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
155 CollectHandler collector = new CollectHandler(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
156 execute(collector); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
157 return collector.getChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
158 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
160 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
162 * @param inspector |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
163 * @throws IllegalArgumentException when inspector argument is null |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
164 * @throws ConcurrentModificationException if this log command instance is already running |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 */ |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
166 public void execute(Handler handler) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
167 if (handler == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
168 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
169 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
170 if (delegate != null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
171 throw new ConcurrentModificationException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
172 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
173 try { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
174 delegate = handler; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
175 count = 0; |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
176 changeset = new HgChangeset(new HgStatusCollector(repo), new PathPool(repo.getPathHelper())); |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
177 if (file == null) { |
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
178 repo.getChangelog().range(startRev, endRev, this); |
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
179 } else { |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
180 HgDataFile fileNode = repo.getFileNode(file); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
181 fileNode.history(startRev, endRev, this); |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
182 if (fileNode.isCopy()) { |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
183 // even if we do not follow history, report file rename |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
184 do { |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
185 if (handler instanceof FileHistoryHandler) { |
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
186 FileRevision src = new FileRevision(repo, fileNode.getCopySourceRevision(), fileNode.getCopySourceName()); |
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
187 FileRevision dst = new FileRevision(repo, fileNode.getRevision(0), fileNode.getPath()); |
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
188 ((FileHistoryHandler) handler).copy(src, dst); |
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
189 } |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
190 if (limit > 0 && count >= limit) { |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
191 // if limit reach, follow is useless. |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
192 break; |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
193 } |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
194 if (followHistory) { |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
195 fileNode = repo.getFileNode(fileNode.getCopySourceName()); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
196 fileNode.history(this); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
197 } |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
198 } while (followHistory && fileNode.isCopy()); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
199 } |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
200 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
201 } finally { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 delegate = null; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
203 changeset = null; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
204 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
205 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
206 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 // |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
209 public void next(int revisionNumber, Nodeid nodeid, Changeset cset) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
210 if (limit > 0 && count >= limit) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
211 return; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
212 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
213 if (branches != null && !branches.contains(cset.branch())) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
214 return; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
215 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
216 if (users != null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
217 String csetUser = cset.user().toLowerCase(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
218 boolean found = false; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
219 for (String u : users) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
220 if (csetUser.indexOf(u) != -1) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
221 found = true; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
222 break; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
223 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
224 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
225 if (!found) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
226 return; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
227 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
228 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
229 if (date != null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
230 // FIXME |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
232 count++; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
233 changeset.init(revisionNumber, nodeid, cset); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
234 delegate.next(changeset); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
235 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
236 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
237 public interface Handler { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
238 /** |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
239 * @param changeset not necessarily a distinct instance each time, {@link HgChangeset#clone() clone()} if need a copy. |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
240 */ |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
241 void next(HgChangeset changeset); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
242 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
243 |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
244 /** |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
245 * When {@link HgLogCommand} is executed against file, handler passed to {@link HgLogCommand#execute(Handler)} may optionally |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
246 * implement this interface to get information about file renames. Method {@link #copy(FileRevision, FileRevision)} would |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
247 * get invoked prior any changeset of the original file (if file history being followed) is reported via {@link #next(HgChangeset)}. |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
248 * |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
249 * For {@link HgLogCommand#file(Path, boolean)} with renamed file path and follow argument set to false, |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
250 * {@link #copy(FileRevision, FileRevision)} would be invoked for the first copy/rename in the history of the file, but not |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
251 * followed by any changesets. |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
252 * |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
253 * @author Artem Tikhomirov |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
254 * @author TMate Software Ltd. |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
255 */ |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
256 public interface FileHistoryHandler extends Handler { |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
257 // XXX perhaps, should distinguish copy from rename? And what about merged revisions and following them? |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
258 void copy(FileRevision from, FileRevision to); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
259 } |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
260 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
261 public static class CollectHandler implements Handler { |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
262 private final List<HgChangeset> result = new LinkedList<HgChangeset>(); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
263 |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
264 public List<HgChangeset> getChanges() { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
265 return Collections.unmodifiableList(result); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
266 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
267 |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
268 public void next(HgChangeset changeset) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
269 result.add(changeset.clone()); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
270 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
271 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
272 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
273 public static final class FileRevision { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
274 private final HgRepository repo; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
275 private final Nodeid revision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
276 private final Path path; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
277 |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
278 /*package-local*/FileRevision(HgRepository hgRepo, Nodeid rev, Path p) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
279 if (hgRepo == null || rev == null || p == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
280 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
281 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
282 repo = hgRepo; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
283 revision = rev; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
284 path = p; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
285 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
286 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
287 public Path getPath() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 return path; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
290 public Nodeid getRevision() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
291 return revision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 public byte[] getContent() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
294 // XXX Content wrapper, to allow formats other than byte[], e.g. Stream, DataAccess, etc? |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
295 return repo.getFileNode(path).content(revision); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
297 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
298 } |