Skip to content

Commit

Permalink
Merge pull request #1130 from jelmer/inline-move-in-pack
Browse files Browse the repository at this point in the history
Inline _move_in_pack - only used once
  • Loading branch information
jelmer authored Jan 18, 2023
2 parents 4763ba9 + 51af836 commit be33277
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions dulwich/object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,20 +887,6 @@ def add_thin_pack(self, read_all, read_some, progress=None):
copier.verify(progress=progress)
return self._complete_pack(f, path, len(copier), indexer, progress=progress)

def _move_in_pack(self, path, f):
"""Move a specific file containing a pack into the pack directory.
Note: The file should be on the same file system as the
packs directory.
Args:
path: Path to the pack file.
"""
f.seek(0)
with PackData(path, f) as pd:
indexer = PackIndexer.for_pack_data(pd, resolve_ext_ref=self.get_raw)
return self._complete_pack(f, path, len(pd), indexer)

def add_pack(self):
"""Add a new pack to this object store.
Expand All @@ -916,7 +902,10 @@ def add_pack(self):

def commit():
if f.tell() > 0:
return self._move_in_pack(path, f)
f.seek(0)
with PackData(path, f) as pd:
indexer = PackIndexer.for_pack_data(pd, resolve_ext_ref=self.get_raw)
return self._complete_pack(f, path, len(pd), indexer)
else:
f.close()
os.remove(path)
Expand Down

0 comments on commit be33277

Please sign in to comment.