comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 157:d5268ca7715b

Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 09 Mar 2011 05:22:17 +0100
parents ba2bf656f00f
children 37f3d4a596e4
comparison
equal deleted inserted replaced
156:643ddec3be36 157:d5268ca7715b
16 */ 16 */
17 package org.tmatesoft.hg.core; 17 package org.tmatesoft.hg.core;
18 18
19 import static org.tmatesoft.hg.repo.HgRepository.TIP; 19 import static org.tmatesoft.hg.repo.HgRepository.TIP;
20 20
21 import java.io.IOException;
21 import java.util.Calendar; 22 import java.util.Calendar;
22 import java.util.Collections; 23 import java.util.Collections;
23 import java.util.ConcurrentModificationException; 24 import java.util.ConcurrentModificationException;
24 import java.util.LinkedList; 25 import java.util.LinkedList;
25 import java.util.List; 26 import java.util.List;
29 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; 30 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
30 import org.tmatesoft.hg.repo.HgChangelog; 31 import org.tmatesoft.hg.repo.HgChangelog;
31 import org.tmatesoft.hg.repo.HgDataFile; 32 import org.tmatesoft.hg.repo.HgDataFile;
32 import org.tmatesoft.hg.repo.HgRepository; 33 import org.tmatesoft.hg.repo.HgRepository;
33 import org.tmatesoft.hg.repo.HgStatusCollector; 34 import org.tmatesoft.hg.repo.HgStatusCollector;
35 import org.tmatesoft.hg.util.ByteChannel;
36 import org.tmatesoft.hg.util.CancelledException;
34 import org.tmatesoft.hg.util.Path; 37 import org.tmatesoft.hg.util.Path;
35 import org.tmatesoft.hg.util.PathPool; 38 import org.tmatesoft.hg.util.PathPool;
36 import org.tmatesoft.hg.util.PathRewrite; 39 import org.tmatesoft.hg.util.PathRewrite;
37 40
38 41
162 } 165 }
163 166
164 /** 167 /**
165 * Similar to {@link #execute(org.tmatesoft.hg.repo.RawChangeset.Inspector)}, collects and return result as a list. 168 * Similar to {@link #execute(org.tmatesoft.hg.repo.RawChangeset.Inspector)}, collects and return result as a list.
166 */ 169 */
167 public List<HgChangeset> execute() { 170 public List<HgChangeset> execute() throws HgException {
168 CollectHandler collector = new CollectHandler(); 171 CollectHandler collector = new CollectHandler();
169 execute(collector); 172 execute(collector);
170 return collector.getChanges(); 173 return collector.getChanges();
171 } 174 }
172 175
174 * 177 *
175 * @param inspector 178 * @param inspector
176 * @throws IllegalArgumentException when inspector argument is null 179 * @throws IllegalArgumentException when inspector argument is null
177 * @throws ConcurrentModificationException if this log command instance is already running 180 * @throws ConcurrentModificationException if this log command instance is already running
178 */ 181 */
179 public void execute(Handler handler) { 182 public void execute(Handler handler) throws HgException {
180 if (handler == null) { 183 if (handler == null) {
181 throw new IllegalArgumentException(); 184 throw new IllegalArgumentException();
182 } 185 }
183 if (delegate != null) { 186 if (delegate != null) {
184 throw new ConcurrentModificationException(); 187 throw new ConcurrentModificationException();
307 return path; 310 return path;
308 } 311 }
309 public Nodeid getRevision() { 312 public Nodeid getRevision() {
310 return revision; 313 return revision;
311 } 314 }
312 public byte[] getContent() { 315 public void putContentTo(ByteChannel sink) throws HgDataStreamException, IOException, CancelledException {
313 // XXX Content wrapper, to allow formats other than byte[], e.g. Stream, DataAccess, etc? 316 HgDataFile fn = repo.getFileNode(path);
314 return repo.getFileNode(path).content(revision); 317 int localRevision = fn.getLocalRevision(revision);
318 fn.contentWithFilters(localRevision, sink);
315 } 319 }
316 } 320 }
317 } 321 }