##// END OF EJS Templates
annotate: pre-calculate the "needed" dictionary (issue5360)...
Jun Wu -
r29861:2f6d5c60 stable
parent child Browse files
Show More
@@ -990,15 +990,29 b' class basefilectx(object):'
990 # bit recursion-hostile. Instead we do an iterative
990 # bit recursion-hostile. Instead we do an iterative
991 # depth-first search.
991 # depth-first search.
992
992
993 # 1st DFS pre-calculates pcache and needed
993 visit = [base]
994 visit = [base]
994 hist = {}
995 pcache = {}
995 pcache = {}
996 needed = {base: 1}
996 needed = {base: 1}
997 while visit:
997 while visit:
998 f = visit.pop()
999 if f in pcache:
1000 continue
1001 pl = parents(f)
1002 pcache[f] = pl
1003 for p in pl:
1004 needed[p] = needed.get(p, 0) + 1
1005 if p not in pcache:
1006 visit.append(p)
1007
1008 # 2nd DFS does the actual annotate
1009 visit[:] = [base]
1010 hist = {}
1011 while visit:
998 f = visit[-1]
1012 f = visit[-1]
999 pcached = f in pcache
1013 if f in hist:
1000 if not pcached:
1014 visit.pop()
1001 pcache[f] = parents(f)
1015 continue
1002
1016
1003 ready = True
1017 ready = True
1004 pl = pcache[f]
1018 pl = pcache[f]
@@ -1006,18 +1020,11 b' class basefilectx(object):'
1006 if p not in hist:
1020 if p not in hist:
1007 ready = False
1021 ready = False
1008 visit.append(p)
1022 visit.append(p)
1009 if not pcached:
1010 needed[p] = needed.get(p, 0) + 1
1011 if ready:
1023 if ready:
1012 visit.pop()
1024 visit.pop()
1013 reusable = f in hist
1025 curr = decorate(f.data(), f)
1014 if reusable:
1015 curr = hist[f]
1016 else:
1017 curr = decorate(f.data(), f)
1018 for p in pl:
1026 for p in pl:
1019 if not reusable:
1027 curr = pair(hist[p], curr)
1020 curr = pair(hist[p], curr)
1021 if needed[p] == 1:
1028 if needed[p] == 1:
1022 del hist[p]
1029 del hist[p]
1023 del needed[p]
1030 del needed[p]
@@ -1025,7 +1032,7 b' class basefilectx(object):'
1025 needed[p] -= 1
1032 needed[p] -= 1
1026
1033
1027 hist[f] = curr
1034 hist[f] = curr
1028 pcache[f] = []
1035 del pcache[f]
1029
1036
1030 return zip(hist[base][0], hist[base][1].splitlines(True))
1037 return zip(hist[base][0], hist[base][1].splitlines(True))
1031
1038
@@ -606,3 +606,35 b' Even when the starting revision is the l'
606 3: B
606 3: B
607
607
608 $ cd ..
608 $ cd ..
609
610 Issue5360: Deleted chunk in p1 of a merge changeset
611
612 $ hg init repo-5360
613 $ cd repo-5360
614 $ echo 1 > a
615 $ hg commit -A a -m 1
616 $ echo 2 >> a
617 $ hg commit -m 2
618 $ echo a > a
619 $ hg commit -m a
620 $ hg update '.^' -q
621 $ echo 3 >> a
622 $ hg commit -m 3 -q
623 $ hg merge 2 -q
624 $ cat > a << EOF
625 > b
626 > 1
627 > 2
628 > 3
629 > a
630 > EOF
631 $ hg resolve --mark -q
632 $ hg commit -m m
633 $ hg annotate a
634 4: b
635 0: 1
636 1: 2
637 3: 3
638 2: a
639
640 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now