174
174
self._root_row = None
175
175
self._state_file=None
177
def add(self, path, file_id, kind, stat, sha1):
178
"""Add a path to be tracked.
180
:param path: The path within the dirstate - '' is the root, 'foo' is the
181
path foo within the root, 'foo/bar' is the path bar within foo
183
:param file_id: The file id of the path being added.
184
:param kind: The kind of the path.
185
:param stat: The output of os.lstate for the path.
186
:param sha1: The sha value of the file, IFF it has one.
189
# find the block its in.
190
# find the location in the block.
191
# check its not there
193
dirname, basename = os.path.split(path.encode('utf8'))
194
block_index = bisect.bisect_left(self._dirblocks, (dirname, []))
195
assert self._dirblocks[block_index][0] == dirname, \
196
"dirname %r not in dirstate, found %r instead" % (
197
dirname, self._dirblocks[block_index][0])
198
block = self._dirblocks[block_index][1]
199
row_data = (dirname, basename, kind, file_id.encode('utf8'),
200
stat.st_size, pack_stat(stat), sha1)
201
row_index = bisect.bisect_left(block, row_data)
202
if len(block) > row_index:
203
assert block[row_index][1] != basename, \
204
"basename %r already added" % basename
205
block.insert(row_index, row_data)
207
# if kind == 'directory':
208
# # insert a new dirblock
209
# self._dirblocks.insert(block_index, (dirname, []))
177
212
def add_parent_tree(self, tree_id, tree):
178
213
"""Add tree as a parent to this dirstate."""
179
214
self._read_dirblocks_if_needed()
327
362
result._state_file = open(path, 'wb+')
328
363
# a new root directory, with a pack_stat (the x's) that is just noise and will
329
364
# never match the output of base64 encode.
330
root_row_data = ('', '', 'directory', bzrlib.inventory.ROOT_ID, 0,
365
root_row_data = ('', '', 'directory', bzrlib.inventory.ROOT_ID, 0,
331
366
DirState.NULLSTAT, '')
332
367
root_parents = []
333
368
root_row = (root_row_data, root_parents)