comparison mercurial/hg.py @ 894:62ec665759f2

Merge with TAH.
author Bryan O'Sullivan <bos@serpentine.com>
date Sat, 13 Aug 2005 15:23:06 -0800
parents f481c9b6786e 6d6095823b82
children 77b52b864249
comparison
equal deleted inserted replaced
893:36c991554ebb 894:62ec665759f2
395 self.copies[dest] = source 395 self.copies[dest] = source
396 396
397 def copied(self, file): 397 def copied(self, file):
398 return self.copies.get(file, None) 398 return self.copies.get(file, None)
399 399
400 def update(self, files, state): 400 def update(self, files, state, **kw):
401 ''' current states: 401 ''' current states:
402 n normal 402 n normal
403 m needs merging 403 m needs merging
404 r marked for removal 404 r marked for removal
405 a marked for addition''' 405 a marked for addition'''
410 for f in files: 410 for f in files:
411 if state == "r": 411 if state == "r":
412 self.map[f] = ('r', 0, 0, 0) 412 self.map[f] = ('r', 0, 0, 0)
413 else: 413 else:
414 s = os.stat(os.path.join(self.root, f)) 414 s = os.stat(os.path.join(self.root, f))
415 self.map[f] = (state, s.st_mode, s.st_size, s.st_mtime) 415 st_size = kw.get('st_size', s.st_size)
416 st_mtime = kw.get('st_mtime', s.st_mtime)
417 self.map[f] = (state, s.st_mode, st_size, st_mtime)
416 418
417 def forget(self, files): 419 def forget(self, files):
418 if not files: return 420 if not files: return
419 self.read() 421 self.read()
420 self.markdirty() 422 self.markdirty()
542 if fn not in dc and self.ignore(fn): 544 if fn not in dc and self.ignore(fn):
543 continue 545 continue
544 if match(fn): 546 if match(fn):
545 yield src, fn 547 yield src, fn
546 548
547 def changes(self, files = None, match = util.always): 549 def changes(self, files=None, match=util.always):
548 self.read() 550 self.read()
549 if not files: 551 if not files:
550 dc = self.map.copy() 552 dc = self.map.copy()
551 else: 553 else:
552 dc = self.filterfiles(files) 554 dc = self.filterfiles(files)
553 lookup, changed, added, unknown = [], [], [], [] 555 lookup, modified, added, unknown = [], [], [], []
556 removed, deleted = [], []
554 557
555 for src, fn in self.walk(files, match, dc=dc): 558 for src, fn in self.walk(files, match, dc=dc):
556 try: s = os.stat(os.path.join(self.root, fn)) 559 try:
557 except: continue 560 s = os.stat(os.path.join(self.root, fn))
558 561 except OSError:
559 if fn in dc: 562 continue
560 c = dc[fn] 563 if not stat.S_ISREG(s.st_mode):
564 continue
565 c = dc.get(fn)
566 if c:
561 del dc[fn] 567 del dc[fn]
562
563 if c[0] == 'm': 568 if c[0] == 'm':
564 changed.append(fn) 569 modified.append(fn)
565 elif c[0] == 'a': 570 elif c[0] == 'a':
566 added.append(fn) 571 added.append(fn)
567 elif c[0] == 'r': 572 elif c[0] == 'r':
568 unknown.append(fn) 573 unknown.append(fn)
569 elif c[2] != s.st_size or (c[1] ^ s.st_mode) & 0100: 574 elif c[2] != s.st_size or (c[1] ^ s.st_mode) & 0100:
570 changed.append(fn) 575 modified.append(fn)
571 elif c[1] != s.st_mode or c[3] != s.st_mtime: 576 elif c[3] != s.st_mtime:
572 lookup.append(fn) 577 lookup.append(fn)
573 else: 578 else:
574 if match(fn): unknown.append(fn) 579 unknown.append(fn)
575 580
576 return (lookup, changed, added, filter(match, dc.keys()), unknown) 581 for fn, c in [(fn, c) for fn, c in dc.items() if match(fn)]:
582 if c[0] == 'r':
583 removed.append(fn)
584 else:
585 deleted.append(fn)
586 return (lookup, modified, added, removed + deleted, unknown)
577 587
578 # used to avoid circular references so destructors work 588 # used to avoid circular references so destructors work
579 def opener(base): 589 def opener(base):
580 p = base 590 p = base
581 def o(path, mode="r"): 591 def o(path, mode="r"):
1622 for f in files: 1632 for f in files:
1623 self.ui.status("merging %s\n" % f) 1633 self.ui.status("merging %s\n" % f)
1624 m, o, flag = merge[f] 1634 m, o, flag = merge[f]
1625 self.merge3(f, m, o) 1635 self.merge3(f, m, o)
1626 util.set_exec(self.wjoin(f), flag) 1636 util.set_exec(self.wjoin(f), flag)
1627 if moddirstate and mode == 'm': 1637 if moddirstate:
1628 # only update dirstate on branch merge, otherwise we 1638 if mode == 'm':
1629 # could mark files with changes as unchanged 1639 # only update dirstate on branch merge, otherwise we
1630 self.dirstate.update([f], mode) 1640 # could mark files with changes as unchanged
1641 self.dirstate.update([f], mode)
1642 elif p2 == nullid:
1643 # update dirstate from parent1's manifest
1644 m1n = self.changelog.read(p1)[0]
1645 m1 = self.manifest.read(m1n)
1646 f_len = len(self.file(f).read(m1[f]))
1647 self.dirstate.update([f], mode, st_size=f_len, st_mtime=0)
1648 else:
1649 self.ui.warn("Second parent without branch merge!?\n"
1650 "Dirstate for file %s may be wrong.\n" % f)
1631 1651
1632 remove.sort() 1652 remove.sort()
1633 for f in remove: 1653 for f in remove:
1634 self.ui.note("removing %s\n" % f) 1654 self.ui.note("removing %s\n" % f)
1635 try: 1655 try: