comparison src/org/tmatesoft/hg/core/HgFileInformer.java @ 251:8c951645bea0

Some javadoc to explain HgFileInformer
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 12 Aug 2011 19:12:04 +0200
parents 3fbfce107f94
children 9fb50c04f03c
comparison
equal deleted inserted replaced
250:9ef71bd26db1 251:8c951645bea0
22 import org.tmatesoft.hg.util.Path; 22 import org.tmatesoft.hg.util.Path;
23 23
24 /** 24 /**
25 * Primary purpose is to provide information about file revisions at specific changeset. Multiple {@link #check(Path)} calls 25 * Primary purpose is to provide information about file revisions at specific changeset. Multiple {@link #check(Path)} calls
26 * are possible once {@link #changeset(Nodeid)} (and optionally, {@link #followRenames(boolean)}) were set. 26 * are possible once {@link #changeset(Nodeid)} (and optionally, {@link #followRenames(boolean)}) were set.
27 *
28 * <p>Sample:
29 * <pre><code>
30 * HgFileInformer i = new HgFileInformer(hgRepo).changeset(Nodeid.fromString("<40 digits>")).followRenames(true);
31 * if (i.check(file)) {
32 * HgCatCommand catCmd = new HgCatCommand(hgRepo).revision(i.getFileRevision());
33 * catCmd.execute(...);
34 * ...
35 * }
36 * </pre></code>
27 * 37 *
28 * @author Artem Tikhomirov 38 * @author Artem Tikhomirov
29 * @author TMate Software Ltd. 39 * @author TMate Software Ltd.
30 */ 40 */
31 public class HgFileInformer { 41 public class HgFileInformer {
39 49
40 public HgFileInformer(HgRepository hgRepo) { 50 public HgFileInformer(HgRepository hgRepo) {
41 repo = hgRepo; 51 repo = hgRepo;
42 } 52 }
43 53
54 /**
55 * Select specific changelog revision
56 *
57 * @param nid changeset identifier
58 * @return <code>this</code> for convenience
59 */
44 public HgFileInformer changeset(Nodeid nid) { 60 public HgFileInformer changeset(Nodeid nid) {
45 if (nid == null || Nodeid.NULL.equals(nid)) { 61 if (nid == null || Nodeid.NULL.equals(nid)) {
46 throw new IllegalArgumentException(); 62 throw new IllegalArgumentException();
47 } 63 }
48 cset = nid; 64 cset = nid;
49 cachedManifest = null; 65 cachedManifest = null;
50 fileRevision = null; 66 fileRevision = null;
51 return this; 67 return this;
52 } 68 }
53 69
70 /**
71 * Whether to check file origins, default is false (look up only the name supplied)
72 *
73 * @param follow <code>true</code> to check copy/rename origin of the file if it is a copy.
74 * @return <code>this</code> for convenience
75 */
54 public HgFileInformer followRenames(boolean follow) { 76 public HgFileInformer followRenames(boolean follow) {
55 followRenames = follow; 77 followRenames = follow;
56 fileRevision = null; 78 fileRevision = null;
57 return this; 79 return this;
58 } 80 }
59 81
82 /**
83 * Find file (or its origin, if {@link #followRenames(boolean)} was set to <code>true</code>) among files known at specified {@link #changeset(Nodeid)}.
84 *
85 * @param file name of the file in question
86 * @return <code>true</code> if file is known at the selected changeset.
87 * @throws IllegalArgumentException if {@link #changeset(Nodeid)} not specified or file argument is bad.
88 */
60 public boolean check(Path file) { // XXX IStatus instead of boolean? 89 public boolean check(Path file) { // XXX IStatus instead of boolean?
61 fileRevision = null; 90 fileRevision = null;
62 checked = false; 91 checked = false;
63 renamed = false; 92 renamed = false;
64 if (cset == null || file == null || file.isDirectory()) { 93 if (cset == null || file == null || file.isDirectory()) {