Dulwich.io dulwich / 0cbe77c
Add porcelain.repack(). Jelmer Vernooij 4 years ago
3 changed file(s) with 31 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
238238 porcelain.tag('.', args[0])
239239
240240
241 def cmd_repack(args):
242 opts, args = getopt(args, "", [])
243 opts = dict(opts)
244 porcelain.repack('.')
245
246
241247 def cmd_reset(args):
242248 opts, args = getopt(args, "", ["hard", "soft", "mixed"])
243249 opts = dict(opts)
368374 "log": cmd_log,
369375 "ls-remote": cmd_ls_remote,
370376 "receive-pack": cmd_receive_pack,
377 "repack": cmd_repack,
371378 "reset": cmd_reset,
372379 "rev-list": cmd_rev_list,
373380 "rm": cmd_rm,
811811 def ls_remote(remote):
812812 client, host_path = get_transport_and_path(remote)
813813 return client.get_refs(encode_path(host_path))
814
815
816 def repack(repo):
817 """Repack loose files in a repository.
818
819 Currently this only packs loose objects.
820
821 :param repo: Path to the repository
822 """
823 with open_repo_closing(repo) as r:
824 r.object_store.pack_loose_objects()
739739 # Check the target repo for pushed changes
740740 with closing(Repo(target_path)) as r:
741741 self.assertTrue(self.repo[b'HEAD'].id in r)
742
743
744 class RepackTests(PorcelainTestCase):
745
746 def test_empty(self):
747 porcelain.repack(self.repo)
748
749 def test_simple(self):
750 handle, fullpath = tempfile.mkstemp(dir=self.repo.path)
751 os.close(handle)
752 filename = os.path.basename(fullpath)
753 porcelain.add(repo=self.repo.path, paths=filename)
754 porcelain.repack(self.repo)