Rev 2: Add the ability to rebuild an arbitrary knit. in http://bazaar.launchpad.net/%7Ebzr/bzr-rebuild-knit/trunk

John Arbash Meinel john at arbash-meinel.com
Tue May 22 12:50:44 BST 2007


At http://bazaar.launchpad.net/%7Ebzr/bzr-rebuild-knit/trunk

------------------------------------------------------------
revno: 2
revision-id: john at arbash-meinel.com-20070522115028-tt76imivkl1ze6au
parent: john at arbash-meinel.com-20070314160554-b914k3s4b2m3jlqo
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: rebuild_knit
timestamp: Tue 2007-05-22 13:50:28 +0200
message:
  Add the ability to rebuild an arbitrary knit.
  Also add the ability to set the max number of deltas before
  forcing a full text.
modified:
  __init__.py                    __init__.py-20070314160550-5zi5l45h9nonub98-1
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-03-14 16:05:54 +0000
+++ b/__init__.py	2007-05-22 11:50:28 +0000
@@ -65,7 +65,12 @@
 
     takes_args = ['out_file']
 
-    def run(self, out_file=None, location='.'):
+    takes_options = [option.Option('max-chain', type=int,
+                        help='set the maximum number of deltas between'
+                             ' fulltexts (default 200)'),
+                    ]
+
+    def run(self, out_file=None, location='.', max_chain=None):
         out_dir, out_fname = urlutils.split(out_file)
         out_transport = transport.get_transport(out_dir)
         out_knit = knit.KnitVersionedFile(out_fname, out_transport,
@@ -73,6 +78,8 @@
                                           factory=knit.KnitPlainFactory(),
                                           create=True,
                                           )
+        if max_chain:
+            out_knit._max_delta_chain = max_chain
         local_branch = branch.Branch.open_containing(location)[0]
         repo = local_branch.repository
         repo.lock_read()
@@ -84,3 +91,35 @@
 
 
 commands.register_command(cmd_rebuild_inventory_knit)
+
+
+class cmd_rebuild_knit(commands.Command):
+    """Rebuild a specific knit to improve compression."""
+
+    takes_args = ['in_file', 'out_file']
+    takes_options = [option.Option('max-chain', type=int,
+                        help='set the maximum number of deltas between'
+                             ' fulltexts (default 200)'),
+                    ]
+
+    def run(self, in_file, out_file, max_chain=None):
+        in_dir, in_fname = urlutils.split(in_file)
+        in_transport = transport.get_transport(in_dir)
+        out_dir, out_fname = urlutils.split(out_file)
+        out_transport = transport.get_transport(out_dir)
+        in_knit = knit.KnitVersionedFile(in_fname, in_transport,
+                                          access_mode='r',
+                                          factory=knit.KnitAnnotateFactory(),
+                                          create=True,
+                                          )
+        out_knit = knit.KnitVersionedFile(out_fname, out_transport,
+                                          access_mode='w',
+                                          factory=knit.KnitAnnotateFactory(),
+                                          create=True,
+                                          )
+        if max_chain:
+            out_knit._max_delta_chain = max_chain
+        copy_knit_into(in_knit, out_knit)
+
+commands.register_command(cmd_rebuild_knit)
+



More information about the bazaar-commits mailing list