]> arthur.barton.de Git - bup.git/commitdiff
Inline git.cat() inside server-cmd.py
authorGabriel Filion <lelutin@gmail.com>
Fri, 25 Jun 2010 08:07:03 +0000 (04:07 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 27 Jun 2010 19:01:44 +0000 (15:01 -0400)
Since the cat() function in git.py is used only inside the server-cmd.py
script, and since it is a discouraged use of CatPipe, inline the code
inside the server-cmd.py script.

At the same time, make the CatPipe object persistent between calls to
the "cat" command to remove unnecessary deletion/creation or resources.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
cmd/server-cmd.py
lib/bup/git.py

index c74ffbffb43339f6b6bd9f0345dfc4f939a5375a..b1a7f6f7ac3c607fa10ce9002e4cedb0641faf18 100755 (executable)
@@ -122,10 +122,14 @@ def update_ref(conn, refname):
     conn.ok()
 
 
+cat_pipe = None
 def cat(conn, id):
+    global cat_pipe
     git.check_repo_or_die()
+    if not cat_pipe:
+        cat_pipe = git.CatPipe()
     try:
-        for blob in git.cat(id):
+        for blob in cat_pipe.join(id):
             conn.write(struct.pack('!I', len(blob)))
             conn.write(blob)
     except KeyError, e:
index d7230f77b0596c26b2f524b2f4b59ae8a72f80a1..d9f1944de4a1fbe61b68cb746980e59835c91b48 100644 (file)
@@ -872,9 +872,3 @@ class CatPipe:
                 yield d
         except StopIteration:
             log('booger!\n')
-
-
-def cat(id):
-    c = CatPipe()
-    for d in c.join(id):
-        yield d