dumppack 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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.errors import ApplyDeltaError
  20. from dulwich.pack import Pack, sha_to_hex
  21. import sys
  22. basename = sys.argv[1]
  23. x = Pack(basename)
  24. print "Object names checksum: %s" % x.name()
  25. print "Checksum: %s" % sha_to_hex(x.get_stored_checksum())
  26. if not x.check():
  27. print "CHECKSUM DOES NOT MATCH"
  28. print "Length: %d" % len(x)
  29. for name in x:
  30. try:
  31. print "\t%s: %s" % (name, x[name])
  32. except KeyError, k:
  33. print "\t%s: Unable to resolve base %s" % (name, k)
  34. except ApplyDeltaError, e:
  35. print "\t%s: Unable to apply delta: %r" % (name, e)