git.fiddlerwoaroof.com
Browse code

refactor: delta class to its own package

Edward Langley authored on 08/11/2023 12:18:40
Showing 4 changed files
... ...
@@ -1,6 +1,6 @@
1
-(in-package :fwoar.cl-git)
1
+(in-package :fwoar.cl-git.delta)
2 2
 
3
-(defclass delta (git-object)
3
+(defclass delta (fwoar.cl-git:git-object)
4 4
   ((%repository :initarg :repository :reader repository)
5 5
    (%base :initarg :base :reader base)
6 6
    (%commands :initarg :commands :reader commands)
... ...
@@ -9,10 +9,10 @@
9 9
   (:documentation
10 10
    "The base type for deltified git objects"))
11 11
 
12
-(defclass+ ofs-delta (delta)
12
+(fwoar.cl-git::defclass+ ofs-delta (delta)
13 13
   ())
14 14
 
15
-(defclass+ ref-delta (delta)
15
+(fwoar.cl-git::defclass+ ref-delta (delta)
16 16
   ()
17 17
   (:documentation "TODO: mostly unimplemented/untested"))
18 18
 
... ...
@@ -41,9 +41,9 @@
41 41
 
42 42
 (defun obj-to-type (obj)
43 43
   (etypecase obj
44
-    (git-commit :commit)
45
-    (git-tree :tree)
46
-    (blob :blob)))
44
+    (fwoar.cl-git:git-commit :commit)
45
+    (fwoar.cl-git:git-tree :tree)
46
+    (fwoar.cl-git:blob :blob)))
47 47
 
48 48
 (defun trace-bases (pack delta)
49 49
   (assert (typep delta 'delta))
... ...
@@ -51,7 +51,7 @@
51 51
          (o (fwoar.cl-git.pack::extract-object-at-pos
52 52
              pack
53 53
              offset
54
-             (make-instance 'git-ref
54
+             (make-instance 'fwoar.cl-git:git-ref
55 55
                             :hash "00000000"
56 56
                             :repo nil)))
57 57
          (obj (serapeum:assocdr :object-data o))
... ...
@@ -74,18 +74,19 @@
74 74
                                                  maybe-delta)
75 75
              (-extract-object-of-type type
76 76
                                       raw-data
77
-                                      (ref-repo ref)
78
-                                      :hash (ref-hash ref))))
77
+                                      (fwoar.cl-git::ref-repo ref)
78
+                                      :hash (fwoar.cl-git::ref-hash ref))))
79 79
     (t maybe-delta)))
80 80
 
81 81
 (defun get-bases (pack delta)
82 82
   (if (typep delta 'delta)
83 83
       (let* ((offset (second (base delta)))
84
-             (o (extract-object-at-pos pack
85
-                                       offset
86
-                                       (make-instance 'git-ref
87
-                                                      :hash "00000000"
88
-                                                      :repo nil)))
84
+             (o (fwoar.cl-git.pack:extract-object-at-pos
85
+                 pack
86
+                 offset
87
+                 (make-instance 'fwoar.cl-git:git-ref
88
+                                :hash "00000000"
89
+                                :repo nil)))
89 90
              (obj (serapeum:assocdr :object-data o)))
90 91
         (cons delta (get-bases pack obj)))
91 92
       (list delta)))
... ...
@@ -182,7 +182,7 @@
182 182
          (size (fwoar.cl-git::get-object-size metadata))
183 183
          (delta-base (case type
184 184
                        (:ref-delta (error ":ref-delta not implemented yet"))
185
-                       (:ofs-delta (fwoar.cl-git::get-ofs-delta-offset-streaming s))))
185
+                       (:ofs-delta (fwoar.cl-git.delta::get-ofs-delta-offset-streaming s))))
186 186
          (decompressed (chipz:decompress nil (chipz:make-dstate 'chipz:zlib) s))
187 187
          (object-data (fwoar.cl-git::extract-object-of-type type decompressed repository pos (pathname s) ref delta-base)))
188 188
     (list (cons :type (fwoar.cl-git::object-type->sym type))
... ...
@@ -208,5 +208,5 @@
208 208
                                              object))))
209 209
     (if *want-delta*
210 210
         maybe-delta
211
-        (fwoar.cl-git::resolve-delta object
212
-                                     maybe-delta))))
211
+        (fwoar.cl-git.delta:resolve-delta object
212
+                                          maybe-delta))))
... ...
@@ -11,12 +11,18 @@
11 11
   (:use :cl :fwoar.cl-git.protocol)
12 12
   (:export #:git-commit #:metadata #:data))
13 13
 
14
+(defpackage :fwoar.cl-git.delta
15
+  (:use :cl :fwoar.cl-git.protocol)
16
+  (:export #:delta #:repository #:base #:commands #:src-size
17
+           #:delta-size #:resolve-delta))
18
+
14 19
 (defpackage :fwoar.cl-git.pack
15 20
   (:use :cl)
16 21
   (:export #:pack #:pack-file #:index-file #:idx-toc
17 22
            #:with-pack-streams #:seek-to-object-in-pack #:packed-ref
18 23
            #:packed-ref-pack #:packed-ref-offset #:extract-object #:git-ref
19
-           #:loose-ref))
24
+           #:loose-ref
25
+           #:extract-object-at-pos))
20 26
 
21 27
 (defpackage :fwoar.cl-git
22 28
   (:use :cl :fwoar.cl-git.protocol)
... ...
@@ -24,7 +30,9 @@
24 30
   (:import-from :fwoar.cl-git.pack #:packed-ref)
25 31
   (:export #:ensure-ref #:repository #:*want-delta* #:git-object
26 32
            #:hash #:*git-encoding* #:git-commit #:ref #:component
27
-           #:*git-repository* #:git-ref #:extract-object))
33
+           #:*git-repository* #:git-ref #:extract-object
34
+           #:git-tree
35
+           #:blob))
28 36
 
29 37
 (defpackage :fwoar.cl-git.types
30 38
   (:use :cl )
... ...
@@ -201,7 +201,7 @@
201 201
     (loop for (ref . base-offset) in expectations
202 202
           do (5am:is (equal base-offset
203 203
                             (second
204
-                             (fwoar.cl-git::base
204
+                             (fwoar.cl-git.delta:base
205 205
                               (fwoar.cl-git:extract-object
206 206
                                (fwoar.cl-git.pack:packed-ref *fake-repo-2* ref)))))))
207 207
     ))