Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgBundle.java @ 667:fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 11 Jul 2013 17:54:08 +0200 |
parents | 46b56864b483 |
children | 545b1d4cc11d |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgBundle.java Wed Jul 10 20:22:07 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/HgBundle.java Thu Jul 11 17:54:08 2013 +0200 @@ -31,12 +31,14 @@ import org.tmatesoft.hg.internal.DataAccessProvider; import org.tmatesoft.hg.internal.DataSerializer; import org.tmatesoft.hg.internal.DigestHelper; +import org.tmatesoft.hg.internal.EncodingHelper; import org.tmatesoft.hg.internal.Experimental; import org.tmatesoft.hg.internal.FileUtils; import org.tmatesoft.hg.internal.InflaterDataAccess; import org.tmatesoft.hg.internal.Internals; import org.tmatesoft.hg.internal.Lifecycle; import org.tmatesoft.hg.internal.Patch; +import org.tmatesoft.hg.repo.HgChangelog.ChangesetParser; import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; import org.tmatesoft.hg.util.Adaptable; import org.tmatesoft.hg.util.CancelledException; @@ -55,12 +57,14 @@ private final File bundleFile; private final DataAccessProvider accessProvider; private final SessionContext ctx; + private final EncodingHelper fnDecorer; private Lifecycle.BasicCallback flowControl; HgBundle(SessionContext sessionContext, DataAccessProvider dap, File bundle) { ctx = sessionContext; accessProvider = dap; bundleFile = bundle; + fnDecorer = Internals.buildFileNameEncodingHelper(new SessionContext.SourcePrim(ctx)); } private DataAccess getDataStream() throws IOException { @@ -112,10 +116,12 @@ boolean emptyChangelog = true; private DataAccess prevRevContent; private int revisionIndex; + private ChangesetParser csetBuilder; public void changelogStart() { emptyChangelog = true; revisionIndex = 0; + csetBuilder = new ChangesetParser(hgRepo, true); } public void changelogEnd() { @@ -172,7 +178,7 @@ throw new HgInvalidStateException(String.format("Integrity check failed on %s, node: %s", bundleFile, ge.node().shortNotation())); } ByteArrayDataAccess csetDataAccess = new ByteArrayDataAccess(csetContent); - RawChangeset cs = RawChangeset.parse(csetDataAccess); + RawChangeset cs = csetBuilder.parse(csetDataAccess); inspector.next(revisionIndex++, ge.node(), cs); prevRevContent.done(); prevRevContent = csetDataAccess.reset(); @@ -397,7 +403,7 @@ } byte[] fnameBuf = new byte[fnameLen - 4]; da.readBytes(fnameBuf, 0, fnameBuf.length); - String name = new String(fnameBuf); + String name = fnDecorer.fromBundle(fnameBuf, 0, fnameBuf.length); inspector.fileStart(name); if (flowControl.isStopped()) { return;