# # # patch "dumb.py" # from [536a9da7bbb83e05da4a8b1572feb86b191f368c] # to [64b9448246fb3ae79838786b65bca5ba0fc831dc] # # patch "merkle_dir.py" # from [f7196d93da8e8c1a004e7ed257130363ea09b0a3] # to [19d4f2bc491bcbce8645e6549c0470ee0bc0c372] # # patch "monotone.py" # from [19f2084cc8a210e3de900ee4ff60f9745bba31bf] # to [23c5f87220af71491e81661b0f3bab303f276b93] # ============================================================ --- dumb.py 536a9da7bbb83e05da4a8b1572feb86b191f368c +++ dumb.py 64b9448246fb3ae79838786b65bca5ba0fc831dc @@ -30,16 +30,14 @@ kp = monotone.get_pubkey_packet(k) id = sha.new(kp).hexdigest() if id not in curr_ids: - data = zlib.compress(kp) - md.add(id, data) + md.add(id, kp) for rid in monotone.toposort(monotone.revisions_list()): - print "processing revision ", rid + print "processing revision ", rid certs = monotone.get_cert_packets(rid) for cert in certs: id = sha.new(cert).hexdigest() if id not in curr_ids: - data = zlib.compress(cert) - md.add(id, data) + md.add(id, cert) if rid not in curr_ids: rdata = StringIO() revision_text = monotone.get_revision(rid) @@ -51,32 +49,44 @@ stanza_type = stanza[0][0] if stanza_type == "new_manifest": new_manifest = stanza[0][1] +# print stanza_type, ":", new_manifest elif stanza_type == "old_revision": if not old_manifest: old_manifest = stanza[0][1] +# print stanza_type, ":", old_manifest elif stanza_type == "add_file": new_files[stanza[1][1]] = None +# print stanza_type, ":", stanza[1][1] elif stanza_type == "patch": - old_fid = stanza[1][1][0] - new_fid = stanza[2][1][0] + old_fid = stanza[1][1] + new_fid = stanza[2][1] if not new_files.has_key(new_fid): new_files[new_fid] = None if old_fid: new_files[new_fid] = old_fid +# print stanza_type, ":", stanza[1][1],":", stanza[2][1] rdata.write(monotone.get_revision_packet(rid)) if old_manifest: - rdata.write(monotone.get_manifest_delta_packet(old_manifest, - new_manifest)) + mdp = monotone.get_manifest_delta_packet(old_manifest, + new_manifest) +# print "manifest_delta:",mdp + rdata.write(mdp) else: - rdata.write(monotone.get_manifest_packet(new_manifest)) + mpp=monotone.get_manifest_packet(new_manifest) +# print "manifest_packet:",mpp + rdata.write(mpp) for new_fid, old_fid in new_files.items(): if old_fid: - rdata.write(monotone.get_file_delta_packet(old_fid, - new_fid)) +# print "get_file_delta:",old_fid, new_fid + fdp =monotone.get_file_delta_packet(old_fid, new_fid) +# print "file_delta:",fdp + rdata.write(fdp) else: - rdata.write(monotone.get_file_packet(new_fid)) - md.add(rid, zlib.compress(rdata.getvalue())) + fpp = monotone.get_file_packet(new_fid) +# print "file_packet:",fpp + rdata.write(fpp) + md.add(rid, rdata.getvalue()) md.commit() except LockError: raise @@ -134,8 +144,11 @@ print "Pushed %s packets to %s" % (push_c.added, other_url) def main(name, args): - monotone = Monotone("etherape.db") - do_export(monotone, "guzi") + #monotone = Monotone("etherape.db") + #do_export(monotone, "guzi") + #monotone = Monotone("e.db") + #do_full_import(monotone,"guzi") + pass if __name__ == "__main__": import sys ============================================================ --- merkle_dir.py f7196d93da8e8c1a004e7ed257130363ea09b0a3 +++ merkle_dir.py 19d4f2bc491bcbce8645e6549c0470ee0bc0c372 @@ -6,7 +6,8 @@ # What's on disk: # We write all interesting data out to a file DATA # It consists of a bunch of "chunks", appended one after another -# each chunk is a raw block of bytes, as passed to add() +# each chunk is a raw block of bytes, as passed to add(), +# wich compresses the chunk (unlike _add_verbatim()) # each chunk has a unique id. it is assumed that the id<->data mapping is # immutable; in particular, when transferring, we assumed that if we have # an id already, then we already have the corresponding data @@ -295,7 +296,7 @@ #### Adding new items # can only be called from inside a transaction. - def add(self, id, data): + def _add_verbatim(self, id, data): self._need_lock() assert None not in (self._data_handle, self._curr_data_length) @@ -305,6 +306,13 @@ self._curr_data_length += length self._ids_to_flush.append((id, location)) + #### Compressing and adding new items + # can only be called from inside a transaction. + def add(self, id, data): +# print ">>>>>>>>>>\n",data,"<<<<<<<<<<<<<<<\n" + cp_data = zlib.compress(data) + self._add_verbatim(id, cp_data) + #### Getting data back out to outside world # returns an iterator over id, (offset, length) tuples def _all_chunk_locations(self): @@ -367,7 +375,7 @@ # call, to give the chunk optimized and pipelining maximum # opportunity to work for id, data in self.get_chunks(new_chunks): - target.add(id, data) + target._add_verbatim(id, data) if new_chunk_callback is not None: new_chunk_callback(id, data) target.commit() ============================================================ --- monotone.py 19f2084cc8a210e3de900ee4ff60f9745bba31bf +++ monotone.py 23c5f87220af71491e81661b0f3bab303f276b93 @@ -78,9 +78,11 @@ return self.automate("packet_for_fdelta", old_fid, new_fid) def get_manifest_packet(self, mid): + return "" return self.automate("packet_for_mdata", mid) def get_manifest_delta_packet(self, old_mid, new_mid): + return "" return self.automate("packet_for_mdelta", old_mid, new_mid) def get_cert_packets(self, rid): @@ -173,7 +175,7 @@ basic_io_string_re = re.compile(r'^ *(\S+) (\".*)$') def unescape_string_value(str): rv = "" - valuestr = [] + valuestr = [] is_terminated = False in_escape = False if str[0] != '"': @@ -188,17 +190,19 @@ if c == '\\': in_escape = True elif c == ' ' and is_terminated: - pass + pass elif c == '"': - if is_terminated: - if len(rv)>0: - raise Exception("basic_io parse error; string ends twice! '"+ str+"'") - else: - is_terminated=False - else: - is_terminated = True - valuestr.append(rv) - rv = "" + # this can be a start of new string (when is_terminated true) or the + # end of the current one (is_terminated false) + if is_terminated: + if len(rv)>0: + raise Exception("basic_io parse error; string ends twice! '"+ str+"'") + else: + is_terminated=False + else: + is_terminated = True + valuestr.append(rv) + rv = "" else: rv += c return is_terminated, valuestr