equal
deleted
inserted
replaced
195 self.ui.warn(_("not in dirstate: %s!\n") % f) |
195 self.ui.warn(_("not in dirstate: %s!\n") % f) |
196 pass |
196 pass |
197 |
197 |
198 def clear(self): |
198 def clear(self): |
199 self.map = {} |
199 self.map = {} |
|
200 self.copies = {} |
|
201 self.markdirty() |
|
202 |
|
203 def rebuild(self, parent, files): |
|
204 self.clear() |
|
205 umask = os.umask(0) |
|
206 os.umask(umask) |
|
207 for f, mode in files: |
|
208 if mode: |
|
209 self.map[f] = ('n', ~umask, -1, 0) |
|
210 else: |
|
211 self.map[f] = ('n', ~umask & 0666, -1, 0) |
|
212 self.pl = (parent, nullid) |
200 self.markdirty() |
213 self.markdirty() |
201 |
214 |
202 def write(self): |
215 def write(self): |
203 st = self.opener("dirstate", "w", atomic=True) |
216 st = self.opener("dirstate", "w", atomic=True) |
204 st.write("".join(self.pl)) |
217 st.write("".join(self.pl)) |
268 if not dc: |
281 if not dc: |
269 dc = self.map.copy() |
282 dc = self.map.copy() |
270 elif not dc: |
283 elif not dc: |
271 dc = self.filterfiles(files) |
284 dc = self.filterfiles(files) |
272 |
285 |
273 def statmatch(file, stat): |
286 def statmatch(file_, stat): |
274 file = util.pconvert(file) |
287 file_ = util.pconvert(file_) |
275 if file not in dc and self.ignore(file): |
288 if file_ not in dc and self.ignore(file_): |
276 return False |
289 return False |
277 return match(file) |
290 return match(file_) |
278 |
291 |
279 return self.walkhelper(files=files, statmatch=statmatch, dc=dc) |
292 return self.walkhelper(files=files, statmatch=statmatch, dc=dc) |
280 |
293 |
281 def walk(self, files=None, match=util.always, dc=None): |
294 def walk(self, files=None, match=util.always, dc=None): |
282 # filter out the stat |
295 # filter out the stat |
348 util.pathto(self.getcwd(), ff), |
361 util.pathto(self.getcwd(), ff), |
349 inst.strerror)) |
362 inst.strerror)) |
350 continue |
363 continue |
351 if stat.S_ISDIR(st.st_mode): |
364 if stat.S_ISDIR(st.st_mode): |
352 cmp1 = (lambda x, y: cmp(x[1], y[1])) |
365 cmp1 = (lambda x, y: cmp(x[1], y[1])) |
353 sorted = [ x for x in findfiles(f) ] |
366 sorted_ = [ x for x in findfiles(f) ] |
354 sorted.sort(cmp1) |
367 sorted_.sort(cmp1) |
355 for e in sorted: |
368 for e in sorted_: |
356 yield e |
369 yield e |
357 else: |
370 else: |
358 ff = util.normpath(ff) |
371 ff = util.normpath(ff) |
359 if seen(ff): |
372 if seen(ff): |
360 continue |
373 continue |
378 lookup, modified, added, unknown = [], [], [], [] |
391 lookup, modified, added, unknown = [], [], [], [] |
379 removed, deleted = [], [] |
392 removed, deleted = [], [] |
380 |
393 |
381 for src, fn, st in self.statwalk(files, match): |
394 for src, fn, st in self.statwalk(files, match): |
382 try: |
395 try: |
383 type, mode, size, time = self[fn] |
396 type_, mode, size, time = self[fn] |
384 except KeyError: |
397 except KeyError: |
385 unknown.append(fn) |
398 unknown.append(fn) |
386 continue |
399 continue |
387 if src == 'm': |
400 if src == 'm': |
388 nonexistent = True |
401 nonexistent = True |
397 # We need to re-check that it is a valid file |
410 # We need to re-check that it is a valid file |
398 if st and self.supported_type(fn, st): |
411 if st and self.supported_type(fn, st): |
399 nonexistent = False |
412 nonexistent = False |
400 # XXX: what to do with file no longer present in the fs |
413 # XXX: what to do with file no longer present in the fs |
401 # who are not removed in the dirstate ? |
414 # who are not removed in the dirstate ? |
402 if nonexistent and type in "nm": |
415 if nonexistent and type_ in "nm": |
403 deleted.append(fn) |
416 deleted.append(fn) |
404 continue |
417 continue |
405 # check the common case first |
418 # check the common case first |
406 if type == 'n': |
419 if type_ == 'n': |
407 if not st: |
420 if not st: |
408 st = os.stat(fn) |
421 st = os.stat(fn) |
409 if size != st.st_size or (mode ^ st.st_mode) & 0100: |
422 if size >= 0 and (size != st.st_size |
|
423 or (mode ^ st.st_mode) & 0100): |
410 modified.append(fn) |
424 modified.append(fn) |
411 elif time != st.st_mtime: |
425 elif time != st.st_mtime: |
412 lookup.append(fn) |
426 lookup.append(fn) |
413 elif type == 'm': |
427 elif type_ == 'm': |
414 modified.append(fn) |
428 modified.append(fn) |
415 elif type == 'a': |
429 elif type_ == 'a': |
416 added.append(fn) |
430 added.append(fn) |
417 elif type == 'r': |
431 elif type_ == 'r': |
418 removed.append(fn) |
432 removed.append(fn) |
419 |
433 |
420 return (lookup, modified, added, removed, deleted, unknown) |
434 return (lookup, modified, added, removed, deleted, unknown) |