Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master, master-1, and master-0

Avoid converting back and forth between hex and sha for every pack.

Changeset 623bf1c9878e

Parent 597fd49d1242

by Jelmer Vernooij

Changes to one file · Browse files at 623bf1c9878e Showing diff from parent 597fd49d1242 Diff from another changeset...

 
103
104
105
106
 
107
108
109
 
110
111
 
 
 
 
 
 
 
 
112
113
114
115
116
117
118
 
119
120
121
 
122
123
124
 
103
104
105
 
106
107
108
 
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 
 
125
126
127
 
128
129
130
131
@@ -103,22 +103,29 @@
  finally:   f.close()   - def get_raw(self, sha): + def get_raw(self, name):   """Obtain the raw text for an object.   - :param sha: Sha for the object. + :param name: sha for the object.   :return: tuple with object type and object contents.   """ + if len(name) == 40: + sha = hex_to_sha(name) + hexsha = name + elif len(name) == 20: + sha = name + hexsha = sha_to_hex(name) + else: + raise AssertionError   for pack in self.packs:   try:   return pack.get_raw(sha, self.get_raw)   except KeyError:   pass - # FIXME: Are thin pack deltas ever against on-disk shafiles ? - ret = self._get_shafile(sha) + ret = self._get_shafile(hexsha)   if ret is not None:   return ret.as_raw_string() - raise KeyError(sha) + raise KeyError(hexsha)     def __getitem__(self, sha):   type, uncomp = self.get_raw(sha)