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

Add docstrings, only determine pack directory once.

Changeset f99649c01b7b

Parent aa596748f954

by Jelmer Vernooij

Changes to one file · Browse files at f99649c01b7b Showing diff from parent aa596748f954 Diff from another changeset...

 
42
43
44
 
45
46
47
48
49
 
 
 
 
50
51
52
53
54
55
56
 
64
65
66
67
 
68
69
70
 
125
126
127
128
 
129
130
131
132
 
133
134
135
 
144
145
146
147
 
148
149
150
 
156
157
158
159
 
160
161
162
 
171
172
173
174
 
175
176
177
 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
 
 
56
57
58
 
66
67
68
 
69
70
71
72
 
127
128
129
 
130
131
132
133
 
134
135
136
137
 
146
147
148
 
149
150
151
152
 
158
159
160
 
161
162
163
164
 
173
174
175
 
176
177
178
179
@@ -42,15 +42,17 @@
  def __init__(self, path):   self.path = path   self._packs = None + self.pack_dir = os.path.join(self.path, PACKDIR)     def determine_wants_all(self, refs):   return [sha for (ref, sha) in refs.iteritems() if not sha in self and not ref.endswith("^{}")]     def iter_shas(self, shas): + """Iterate over the objects for the specified shas. + + :param shas: Iterable object with SHAs + """   return ObjectStoreIterator(self, shas) - - def pack_dir(self): - return os.path.join(self.path, PACKDIR)     def __contains__(self, sha):   # TODO: This can be more efficient @@ -64,7 +66,7 @@
  def packs(self):   """List with pack objects."""   if self._packs is None: - self._packs = list(load_packs(self.pack_dir())) + self._packs = list(load_packs(self.pack_dir))   return self._packs     def _add_known_pack(self, path): @@ -125,11 +127,11 @@
  :param path: Path to the pack file.   """   p = PackData(path) - temppath = os.path.join(self.pack_dir(), + temppath = os.path.join(self.pack_dir,   sha_to_hex(urllib2.randombytes(20))+".temppack")   write_pack(temppath, p.iterobjects(self.get_raw), len(p))   pack_sha = PackIndex(temppath+".idx").objects_sha1() - newbasename = os.path.join(self.pack_dir(), "pack-%s" % pack_sha) + newbasename = os.path.join(self.pack_dir, "pack-%s" % pack_sha)   os.rename(temppath+".pack", newbasename+".pack")   os.rename(temppath+".idx", newbasename+".idx")   self._add_known_pack(newbasename) @@ -144,7 +146,7 @@
  """   p = PackData(path)   entries = p.sorted_entries() - basename = os.path.join(self.pack_dir(), + basename = os.path.join(self.pack_dir,   "pack-%s" % iter_sha1(entry[0] for entry in entries))   write_pack_index_v2(basename+".idx", entries, p.get_stored_checksum())   os.rename(path, basename + ".pack") @@ -156,7 +158,7 @@
  Thin packs are packs that contain deltas with parents that exist   in a different pack.   """ - fd, path = tempfile.mkstemp(dir=self.pack_dir(), suffix=".pack") + fd, path = tempfile.mkstemp(dir=self.pack_dir, suffix=".pack")   f = os.fdopen(fd, 'w')   def commit():   os.fsync(fd) @@ -171,7 +173,7 @@
  :return: Fileobject to write to and a commit function to   call when the pack is finished.   """ - fd, path = tempfile.mkstemp(dir=self.pack_dir(), suffix=".pack") + fd, path = tempfile.mkstemp(dir=self.pack_dir, suffix=".pack")   f = os.fdopen(fd, 'w')   def commit():   os.fsync(fd)