Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 565:78a9e26e670d
Refactor common code to initialize changelog revision for a command into standalone class
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 09 Apr 2013 17:15:30 +0200 |
parents | 6ca3d0c5b4bc |
children | e4ee4bf4c7d0 |
comparison
equal
deleted
inserted
replaced
564:e6407313bab7 | 565:78a9e26e670d |
---|---|
1 /* | 1 /* |
2 s * Copyright (c) 2011-2012 TMate Software Ltd | 2 s * Copyright (c) 2011-2013 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
34 import java.util.Set; | 34 import java.util.Set; |
35 import java.util.TreeSet; | 35 import java.util.TreeSet; |
36 | 36 |
37 import org.tmatesoft.hg.internal.AdapterPlug; | 37 import org.tmatesoft.hg.internal.AdapterPlug; |
38 import org.tmatesoft.hg.internal.BatchRangeHelper; | 38 import org.tmatesoft.hg.internal.BatchRangeHelper; |
39 import org.tmatesoft.hg.internal.CsetParamKeeper; | |
39 import org.tmatesoft.hg.internal.IntMap; | 40 import org.tmatesoft.hg.internal.IntMap; |
40 import org.tmatesoft.hg.internal.IntVector; | 41 import org.tmatesoft.hg.internal.IntVector; |
41 import org.tmatesoft.hg.internal.Internals; | 42 import org.tmatesoft.hg.internal.Internals; |
42 import org.tmatesoft.hg.internal.Lifecycle; | 43 import org.tmatesoft.hg.internal.Lifecycle; |
43 import org.tmatesoft.hg.internal.LifecycleProxy; | 44 import org.tmatesoft.hg.internal.LifecycleProxy; |
44 import org.tmatesoft.hg.repo.HgChangelog; | 45 import org.tmatesoft.hg.repo.HgChangelog; |
45 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 46 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
46 import org.tmatesoft.hg.repo.HgDataFile; | 47 import org.tmatesoft.hg.repo.HgDataFile; |
47 import org.tmatesoft.hg.repo.HgInvalidControlFileException; | 48 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
48 import org.tmatesoft.hg.repo.HgInvalidRevisionException; | |
49 import org.tmatesoft.hg.repo.HgInvalidStateException; | 49 import org.tmatesoft.hg.repo.HgInvalidStateException; |
50 import org.tmatesoft.hg.repo.HgParentChildMap; | 50 import org.tmatesoft.hg.repo.HgParentChildMap; |
51 import org.tmatesoft.hg.repo.HgRepository; | 51 import org.tmatesoft.hg.repo.HgRepository; |
52 import org.tmatesoft.hg.repo.HgRuntimeException; | 52 import org.tmatesoft.hg.repo.HgRuntimeException; |
53 import org.tmatesoft.hg.repo.HgStatusCollector; | 53 import org.tmatesoft.hg.repo.HgStatusCollector; |
174 endRev = rev1; | 174 endRev = rev1; |
175 } else { | 175 } else { |
176 startRev = rev1; | 176 startRev = rev1; |
177 endRev = rev2; | 177 endRev = rev2; |
178 } | 178 } |
179 // TODO [2.0 API break] shall throw HgBadArgumentException, like other commands do | |
179 return this; | 180 return this; |
180 } | 181 } |
181 | 182 |
182 /** | 183 /** |
183 * Select specific changeset | 184 * Select specific changeset |
186 * @return <code>this</code> for convenience | 187 * @return <code>this</code> for convenience |
187 * @throws HgBadArgumentException if failed to find supplied changeset revision | 188 * @throws HgBadArgumentException if failed to find supplied changeset revision |
188 */ | 189 */ |
189 public HgLogCommand changeset(Nodeid nid) throws HgBadArgumentException { | 190 public HgLogCommand changeset(Nodeid nid) throws HgBadArgumentException { |
190 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions. | 191 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions. |
191 try { | 192 final int csetRevIndex = new CsetParamKeeper(repo).set(nid).get(); |
192 final int csetRevIndex = repo.getChangelog().getRevisionIndex(nid); | 193 return range(csetRevIndex, csetRevIndex); |
193 return range(csetRevIndex, csetRevIndex); | |
194 } catch (HgInvalidRevisionException ex) { | |
195 throw new HgBadArgumentException("Can't find revision", ex).setRevision(nid); | |
196 } | |
197 } | 194 } |
198 | 195 |
199 /** | 196 /** |
200 * Visit history of a given file only. Note, unlike native <code>hg log</code> command argument <code>--follow</code>, this method doesn't | 197 * Visit history of a given file only. Note, unlike native <code>hg log</code> command argument <code>--follow</code>, this method doesn't |
201 * follow file ancestry, but reports complete file history (with <code>followCopyRenames == true</code>, for each | 198 * follow file ancestry, but reports complete file history (with <code>followCopyRenames == true</code>, for each |