2
0

dumppack 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/python
  2. # dumppack - Simple pack dumper for dulwich
  3. # Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; version 2
  8. # of the License.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  18. # MA 02110-1301, USA.
  19. from dulwich.pack import PackData, PackIndex, sha_to_hex
  20. import sys
  21. basename = sys.argv[1]
  22. print "Index file:"
  23. print "-----------"
  24. x = PackIndex(basename + ".idx")
  25. if not x.check():
  26. print "CHECKSUM DOES NOT MATCH"
  27. print "Length: %d" % len(x)
  28. print "Entries in index:"
  29. for name, offset, crc in x.iterentries():
  30. print "\t%s: %d" % (sha_to_hex(name), offset)
  31. print ""
  32. x = PackData(basename + ".pack")
  33. print "Pack file:"
  34. print "----------"
  35. if not x.check():
  36. print "CHECKSUM DOES NOT MATCH"
  37. print "Number of objects: %d" % len(x)