|
@@ -24,6 +24,7 @@
|
|
|
import mmap
|
|
|
import os
|
|
|
import sha
|
|
|
+import stat
|
|
|
import zlib
|
|
|
|
|
|
from dulwich.errors import (
|
|
@@ -112,6 +113,9 @@ class ShaFile(object):
|
|
|
self.serialize()
|
|
|
return self._text
|
|
|
|
|
|
+ def as_pretty_string(self):
|
|
|
+ return self.as_raw_string()
|
|
|
+
|
|
|
def _ensure_parsed(self):
|
|
|
if self._needs_parsing:
|
|
|
self._parse_text()
|
|
@@ -436,6 +440,16 @@ class Tree(ShaFile):
|
|
|
self._text += "%04o %s\0%s" % (mode, name, hex_to_sha(hexsha))
|
|
|
self._needs_serialization = False
|
|
|
|
|
|
+ def as_pretty_string(self):
|
|
|
+ text = ""
|
|
|
+ for name, mode, hexsha in self.iteritems():
|
|
|
+ if mode & stat.S_IFDIR:
|
|
|
+ kind = "tree"
|
|
|
+ else:
|
|
|
+ kind = "blob"
|
|
|
+ text += "%04o %s %s\t%s\n" % (mode, kind, hexsha, name)
|
|
|
+ return text
|
|
|
+
|
|
|
|
|
|
class Commit(ShaFile):
|
|
|
"""A git commit object"""
|