Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgAnnotateCommand.java @ 686:f1f095e42555
Annotated file is not always changed in the latest changeset, need to find out last changest it was changed at (iow, diffed to with BlameHelper)
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 25 Jul 2013 22:12:14 +0200 |
| parents | 58a6900f845d |
| children | 7839ff0bfd78 |
comparison
equal
deleted
inserted
replaced
| 685:9897cbfd2790 | 686:f1f095e42555 |
|---|---|
| 13 * For information on how to redistribute this software under | 13 * For information on how to redistribute this software under |
| 14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
| 15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
| 16 */ | 16 */ |
| 17 package org.tmatesoft.hg.core; | 17 package org.tmatesoft.hg.core; |
| 18 | |
| 19 import static org.tmatesoft.hg.repo.HgRepository.TIP; | |
| 18 | 20 |
| 19 import org.tmatesoft.hg.internal.Callback; | 21 import org.tmatesoft.hg.internal.Callback; |
| 20 import org.tmatesoft.hg.internal.CsetParamKeeper; | 22 import org.tmatesoft.hg.internal.CsetParamKeeper; |
| 21 import org.tmatesoft.hg.internal.ForwardAnnotateInspector; | 23 import org.tmatesoft.hg.internal.ForwardAnnotateInspector; |
| 22 import org.tmatesoft.hg.repo.HgDataFile; | 24 import org.tmatesoft.hg.repo.HgDataFile; |
| 42 private boolean followRename; | 44 private boolean followRename; |
| 43 | 45 |
| 44 public HgAnnotateCommand(HgRepository hgRepo) { | 46 public HgAnnotateCommand(HgRepository hgRepo) { |
| 45 repo = hgRepo; | 47 repo = hgRepo; |
| 46 annotateRevision = new CsetParamKeeper(repo); | 48 annotateRevision = new CsetParamKeeper(repo); |
| 47 annotateRevision.doSet(HgRepository.TIP); | 49 annotateRevision.doSet(TIP); |
| 48 } | 50 } |
| 49 | 51 |
| 50 public HgAnnotateCommand changeset(Nodeid nodeid) throws HgBadArgumentException { | 52 public HgAnnotateCommand changeset(Nodeid nodeid) throws HgBadArgumentException { |
| 51 annotateRevision.set(nodeid); | 53 annotateRevision.set(nodeid); |
| 52 return this; | 54 return this; |
| 117 HgDataFile df = repo.getFileNode(file); | 119 HgDataFile df = repo.getFileNode(file); |
| 118 if (!df.exists()) { | 120 if (!df.exists()) { |
| 119 return; | 121 return; |
| 120 } | 122 } |
| 121 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0); | 123 final int changesetStart = followRename ? 0 : df.getChangesetRevisionIndex(0); |
| 122 final int annotateRevIndex = annotateRevision.get(); | 124 final int annotateRevIndex = annotateRevision.get(TIP); |
| 123 HgDiffCommand cmd = new HgDiffCommand(repo).file(df); | 125 HgDiffCommand cmd = new HgDiffCommand(repo).file(df); |
| 124 cmd.range(changesetStart, annotateRevIndex); | 126 cmd.range(changesetStart, annotateRevIndex); |
| 125 cmd.set(cancellation); | 127 cmd.set(cancellation); |
| 126 cmd.set(new ProgressSupport.Sub(progress, 100)); | 128 cmd.set(new ProgressSupport.Sub(progress, 100)); |
| 127 // | 129 // |
| 129 ForwardAnnotateInspector ai = new ForwardAnnotateInspector(); | 131 ForwardAnnotateInspector ai = new ForwardAnnotateInspector(); |
| 130 cmd.order(ai.iterateDirection()); | 132 cmd.order(ai.iterateDirection()); |
| 131 // | 133 // |
| 132 cmd.executeAnnotate(ai); | 134 cmd.executeAnnotate(ai); |
| 133 cancellation.checkCancelled(); | 135 cancellation.checkCancelled(); |
| 134 ai.report(annotateRevIndex, inspector, new ProgressSupport.Sub(progress, 100), cancellation); | 136 final int lastCsetWithFileChange; |
| 137 Nodeid fileRev = repo.getManifest().getFileRevision(annotateRevIndex, df.getPath()); | |
| 138 if (fileRev != null) { | |
| 139 lastCsetWithFileChange = df.getChangesetRevisionIndex(df.getRevisionIndex(fileRev)); | |
| 140 } else { | |
| 141 lastCsetWithFileChange = annotateRevIndex; | |
| 142 } | |
| 143 ai.report(lastCsetWithFileChange, inspector, new ProgressSupport.Sub(progress, 100), cancellation); | |
| 135 } catch (HgRuntimeException ex) { | 144 } catch (HgRuntimeException ex) { |
| 136 throw new HgLibraryFailureException(ex); | 145 throw new HgLibraryFailureException(ex); |
| 137 } | 146 } |
| 138 progress.done(); | 147 progress.done(); |
| 139 } | 148 } |
