comparison src/org/tmatesoft/hg/internal/BundleGenerator.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 6e98d34eaca8
children d25f0324a27a
comparison
equal deleted inserted replaced
666:27a3ddedd6cc 667:fba85bc1dfb8
99 // 99 //
100 RevlogStream manifestStream = repo.getImplAccess().getManifestStream(); 100 RevlogStream manifestStream = repo.getImplAccess().getManifestStream();
101 new ChunkGenerator(outRaw, clogMap).iterate(manifestStream, manifestRevs.toArray(true)); 101 new ChunkGenerator(outRaw, clogMap).iterate(manifestStream, manifestRevs.toArray(true));
102 outRaw.writeInt(0); // null chunk for manifest group 102 outRaw.writeInt(0); // null chunk for manifest group
103 // 103 //
104 EncodingHelper fnEncoder = repo.buildFileNameEncodingHelper();
104 for (HgDataFile df : sortedByName(files)) { 105 for (HgDataFile df : sortedByName(files)) {
105 RevlogStream s = repo.getImplAccess().getStream(df); 106 RevlogStream s = repo.getImplAccess().getStream(df);
106 final IntVector fileRevs = new IntVector(); 107 final IntVector fileRevs = new IntVector();
107 s.iterate(0, TIP, false, new RevlogStream.Inspector() { 108 s.iterate(0, TIP, false, new RevlogStream.Inspector() {
108 109
115 fileRevs.sort(true); 116 fileRevs.sort(true);
116 if (!fileRevs.isEmpty()) { 117 if (!fileRevs.isEmpty()) {
117 // although BundleFormat page says "filename length, filename" for a file, 118 // although BundleFormat page says "filename length, filename" for a file,
118 // in fact there's a sort of 'filename chunk', i.e. filename length field includes 119 // in fact there's a sort of 'filename chunk', i.e. filename length field includes
119 // not only length of filename, but also length of the field itseld, i.e. filename.length+sizeof(int) 120 // not only length of filename, but also length of the field itseld, i.e. filename.length+sizeof(int)
120 byte[] fnameBytes = df.getPath().toString().getBytes(); // FIXME check encoding in native hg (and fix accordingly in HgBundle) 121 byte[] fnameBytes = fnEncoder.toBundle(df.getPath());
121 outRaw.writeInt(fnameBytes.length + 4); 122 outRaw.writeInt(fnameBytes.length + 4);
122 outRaw.writeByte(fnameBytes); 123 outRaw.writeByte(fnameBytes);
123 new ChunkGenerator(outRaw, clogMap).iterate(s, fileRevs.toArray(true)); 124 new ChunkGenerator(outRaw, clogMap).iterate(s, fileRevs.toArray(true));
124 outRaw.writeInt(0); // null chunk for file group 125 outRaw.writeInt(0); // null chunk for file group
125 } 126 }