##// END OF EJS Templates
Cleaned up localrepo.changes()
Thomas Arendsen Hein -
r1616:f0f9e848 default
parent child Browse files
Show More
@@ -476,7 +476,11 b' class localrepository(object):'
476 yield src, fn
476 yield src, fn
477
477
478 def changes(self, node1=None, node2=None, files=[], match=util.always):
478 def changes(self, node1=None, node2=None, files=[], match=util.always):
479 mf2, u = None, []
479 """return changes between two nodes or node and working directory
480
481 If node1 is None, use the first dirstate parent instead.
482 If node2 is None, compare node1 with working directory.
483 """
480
484
481 def fcmp(fn, mf):
485 def fcmp(fn, mf):
482 t1 = self.wread(fn)
486 t1 = self.wread(fn)
@@ -484,7 +488,8 b' class localrepository(object):'
484 return cmp(t1, t2)
488 return cmp(t1, t2)
485
489
486 def mfmatches(node):
490 def mfmatches(node):
487 mf = dict(self.manifest.read(node))
491 change = self.changelog.read(node)
492 mf = dict(self.manifest.read(change[0]))
488 for fn in mf.keys():
493 for fn in mf.keys():
489 if not match(fn):
494 if not match(fn):
490 del mf[fn]
495 del mf[fn]
@@ -496,61 +501,53 b' class localrepository(object):'
496 wlock = self.wlock(wait=0)
501 wlock = self.wlock(wait=0)
497 except lock.LockHeld:
502 except lock.LockHeld:
498 wlock = None
503 wlock = None
499 l, c, a, d, u = self.dirstate.changes(files, match)
504 lookup, modified, added, deleted, unknown = (
505 self.dirstate.changes(files, match))
500
506
501 # are we comparing working dir against its parent?
507 # are we comparing working dir against its parent?
502 if not node1:
508 if not node1:
503 if l:
509 if lookup:
504 # do a full compare of any files that might have changed
510 # do a full compare of any files that might have changed
505 change = self.changelog.read(self.dirstate.parents()[0])
511 mf2 = mfmatches(self.dirstate.parents()[0])
506 mf2 = mfmatches(change[0])
512 for f in lookup:
507 for f in l:
508 if fcmp(f, mf2):
513 if fcmp(f, mf2):
509 c.append(f)
514 modified.append(f)
510 elif wlock is not None:
515 elif wlock is not None:
511 self.dirstate.update([f], "n")
516 self.dirstate.update([f], "n")
512
517 else:
513 for l in c, a, d, u:
518 # we are comparing working dir against non-parent
514 l.sort()
519 # generate a pseudo-manifest for the working dir
515
520 mf2 = mfmatches(self.dirstate.parents()[0])
516 return (c, a, d, u)
521 for f in lookup + modified + added:
517
522 mf2[f] = ""
518 # are we comparing working dir against non-tip?
523 for f in deleted:
519 # generate a pseudo-manifest for the working dir
524 if f in mf2:
520 if not node2:
525 del mf2[f]
521 if not mf2:
522 change = self.changelog.read(self.dirstate.parents()[0])
523 mf2 = mfmatches(change[0])
524 for f in a + c + l:
525 mf2[f] = ""
526 for f in d:
527 if f in mf2:
528 del mf2[f]
529 else:
526 else:
530 change = self.changelog.read(node2)
527 # we are comparing two revisions
531 mf2 = mfmatches(change[0])
528 unknown = []
529 mf2 = mfmatches(node2)
532
530
533 # flush lists from dirstate before comparing manifests
531 if node1:
534 c, a = [], []
532 # flush lists from dirstate before comparing manifests
533 modified, added = [], []
535
534
536 change = self.changelog.read(node1)
535 mf1 = mfmatches(node1)
537 mf1 = mfmatches(change[0])
538
536
539 for fn in mf2:
537 for fn in mf2:
540 if mf1.has_key(fn):
538 if mf1.has_key(fn):
541 if mf1[fn] != mf2[fn]:
539 if mf1[fn] != mf2[fn] and (mf2[fn] != "" or fcmp(fn, mf1)):
542 if mf2[fn] != "" or fcmp(fn, mf1):
540 modified.append(fn)
543 c.append(fn)
541 del mf1[fn]
544 del mf1[fn]
542 else:
545 else:
543 added.append(fn)
546 a.append(fn)
547
544
548 d = mf1.keys()
545 deleted = mf1.keys()
549
546
550 for l in c, a, d, u:
547 # sort and return results:
548 for l in modified, added, deleted, unknown:
551 l.sort()
549 l.sort()
552
550 return (modified, added, deleted, unknown)
553 return (c, a, d, u)
554
551
555 def add(self, list):
552 def add(self, list):
556 wlock = self.wlock()
553 wlock = self.wlock()
General Comments 0
You need to be logged in to leave comments. Login now