Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/PatchGenerator.java @ 538:dd4f6311af52
Commit: first working version
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 05 Feb 2013 22:30:21 +0100 |
parents | e6f72c9829a6 |
children | 946b13196252 |
comparison
equal
deleted
inserted
replaced
537:5a455624be4f | 538:dd4f6311af52 |
---|---|
23 import org.tmatesoft.hg.repo.HgDataFile; | 23 import org.tmatesoft.hg.repo.HgDataFile; |
24 import org.tmatesoft.hg.repo.HgLookup; | 24 import org.tmatesoft.hg.repo.HgLookup; |
25 import org.tmatesoft.hg.repo.HgRepository; | 25 import org.tmatesoft.hg.repo.HgRepository; |
26 | 26 |
27 /** | 27 /** |
28 * Mercurial cares about changes only up to the line level, e.g. a simple file version bump in manifest looks like (RevlogDump output): | 28 * Mercurial cares about changes only up to the line level, e.g. a simple file version dump in manifest looks like (RevlogDump output): |
29 * | 29 * |
30 * 522: 233748 0 103 17438 433 522 521 -1 756073cf2321df44d3ed0585f2a5754bc8a1b2f6 | 30 * 522: 233748 0 103 17438 433 522 521 -1 756073cf2321df44d3ed0585f2a5754bc8a1b2f6 |
31 * <PATCH>: | 31 * <PATCH>: |
32 * 3487..3578, 91:src/org/tmatesoft/hg/core/HgIterateDirection.java\00add61a8a665c5d8f092210767f812fe0d335ac8 | 32 * 3487..3578, 91:src/org/tmatesoft/hg/core/HgIterateDirection.java\00add61a8a665c5d8f092210767f812fe0d335ac8 |
33 * | 33 * |
175 } | 175 } |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 public static void main(String[] args) throws Exception { | 179 public static void main(String[] args) throws Exception { |
180 PatchGenerator pg1 = new PatchGenerator(); | |
181 pg1.init("hello".getBytes(), "hello\nworld".getBytes()); | |
182 pg1.findMatchingBlocks(); | |
183 if (Boolean.TRUE.booleanValue()) { | |
184 return; | |
185 } | |
180 HgRepository repo = new HgLookup().detectFromWorkingDir(); | 186 HgRepository repo = new HgLookup().detectFromWorkingDir(); |
181 HgDataFile df = repo.getFileNode("cmdline/org/tmatesoft/hg/console/Main.java"); | 187 HgDataFile df = repo.getFileNode("cmdline/org/tmatesoft/hg/console/Main.java"); |
182 ByteArrayChannel bac1, bac2; | 188 ByteArrayChannel bac1, bac2; |
183 df.content(80, bac1 = new ByteArrayChannel()); | 189 df.content(80, bac1 = new ByteArrayChannel()); |
184 df.content(81, bac2 = new ByteArrayChannel()); | 190 df.content(81, bac2 = new ByteArrayChannel()); |
221 } | 227 } |
222 } | 228 } |
223 if (lastStart < input.length) { | 229 if (lastStart < input.length) { |
224 lines.add(new ByteChain(lastStart, input.length)); | 230 lines.add(new ByteChain(lastStart, input.length)); |
225 } | 231 } |
232 // empty chunk to keep offset of input end | |
233 lines.add(new ByteChain(input.length, input.length)); | |
226 } | 234 } |
227 | 235 |
228 public ByteChain chunk(int index) { | 236 public ByteChain chunk(int index) { |
229 return lines.get(index); | 237 return lines.get(index); |
230 } | 238 } |