MCPcopy Create free account
hub / github.com/libgit2/pygit2 / pack

Method pack

pygit2/repository.py:150–185  ·  view source on GitHub ↗

Pack the objects in the odb chosen by the pack_delegate function and write `.pack` and `.idx` files for them. Returns: the number of objects written to the pack Parameters: path The path to which the `.pack` and `.idx` files should be written. `None` wi

(
        self,
        path: str | Path | None = None,
        pack_delegate: Callable[[PackBuilder], None] | None = None,
        n_threads: int | None = None,
    )

Source from the content-addressed store, hash-verified

148 return self.odb.write(type, data)
149
150 def pack(
151 self,
152 path: str | Path | None = None,
153 pack_delegate: Callable[[PackBuilder], None] | None = None,
154 n_threads: int | None = None,
155 ) -> int:
156 """Pack the objects in the odb chosen by the pack_delegate function
157 and write `.pack` and `.idx` files for them.
158
159 Returns: the number of objects written to the pack
160
161 Parameters:
162
163 path
164 The path to which the `.pack` and `.idx` files should be written. `None` will write to the default location.
165
166 pack_delegate
167 The method which will provide add the objects to the pack builder. Defaults to all objects.
168
169 n_threads
170 The number of threads the `PackBuilder` will spawn. If set to 0, libgit2 will autodetect the number of CPUs.
171 """
172
173 def pack_all_objects(pack_builder):
174 for obj in self.odb:
175 pack_builder.add(obj)
176
177 pack_delegate = pack_delegate or pack_all_objects
178
179 builder = PackBuilder(self)
180 if n_threads is not None:
181 builder.set_threads(n_threads)
182 pack_delegate(builder)
183 builder.write(path=path)
184
185 return builder.written_objects_count
186
187 def hashfile(
188 self,

Callers 1

Calls 4

set_threadsMethod · 0.95
writeMethod · 0.95
PackBuilderClass · 0.85
pack_delegateFunction · 0.85

Tested by 1