Show More
@@ -1005,50 +1005,19 b' def increasingwindows(start, end, window' | |||
|
1005 | 1005 | if windowsize < sizelimit: |
|
1006 | 1006 | windowsize *= 2 |
|
1007 | 1007 | |
|
1008 | def walkchangerevs(repo, match, opts, prepare): | |
|
1009 | '''Iterate over files and the revs in which they changed. | |
|
1010 | ||
|
1011 | Callers most commonly need to iterate backwards over the history | |
|
1012 | in which they are interested. Doing so has awful (quadratic-looking) | |
|
1013 | performance, so we use iterators in a "windowed" way. | |
|
1008 | class FileWalkError(Exception): | |
|
1009 | pass | |
|
1014 | 1010 | |
|
1015 | We walk a window of revisions in the desired order. Within the | |
|
1016 | window, we first walk forwards to gather data, then in the desired | |
|
1017 | order (usually backwards) to display it. | |
|
1018 | ||
|
1019 | This function returns an iterator yielding contexts. Before | |
|
1020 | yielding each context, the iterator will first call the prepare | |
|
1021 | function on each context in the window in forward order.''' | |
|
1022 | ||
|
1023 | follow = opts.get('follow') or opts.get('follow_first') | |
|
1011 | def walkfilerevs(repo, match, follow, revs, fncache): | |
|
1012 | '''Walks the file history for the matched files. | |
|
1024 | 1013 |
|
|
1025 | if opts.get('rev'): | |
|
1026 | revs = scmutil.revrange(repo, opts.get('rev')) | |
|
1027 | elif follow: | |
|
1028 | revs = repo.revs('reverse(:.)') | |
|
1029 | else: | |
|
1030 | revs = list(repo) | |
|
1031 | revs.reverse() | |
|
1032 | if not revs: | |
|
1033 | return [] | |
|
1034 | wanted = set() | |
|
1035 | slowpath = match.anypats() or (match.files() and opts.get('removed')) | |
|
1036 | fncache = {} | |
|
1037 | change = repo.changectx | |
|
1014 | Returns the changeset revs that are involved in the file history. | |
|
1038 | 1015 |
|
|
1039 | # First step is to fill wanted, the set of revisions that we want to yield. | |
|
1040 | # When it does not induce extra cost, we also fill fncache for revisions in | |
|
1041 | # wanted: a cache of filenames that were changed (ctx.files()) and that | |
|
1042 | # match the file filtering conditions. | |
|
1043 | ||
|
1044 | if not slowpath and not match.files(): | |
|
1045 | # No files, no patterns. Display all revs. | |
|
1046 | wanted = set(revs) | |
|
1016 | Throws FileWalkError if the file history can't be walked using | |
|
1017 | filelogs alone. | |
|
1018 | ''' | |
|
1019 | wanted = set() | |
|
1047 | 1020 | copies = [] |
|
1048 | ||
|
1049 | if not slowpath and match.files(): | |
|
1050 | # We only have to read through the filelog to find wanted revisions | |
|
1051 | ||
|
1052 | 1021 |
|
|
1053 | 1022 |
|
|
1054 | 1023 |
|
@@ -1090,6 +1059,7 b' def walkchangerevs(repo, match, opts, pr' | |||
|
1090 | 1059 |
|
|
1091 | 1060 |
|
|
1092 | 1061 |
|
|
1062 | ||
|
1093 | 1063 |
|
|
1094 | 1064 |
|
|
1095 | 1065 |
|
@@ -1099,8 +1069,7 b' def walkchangerevs(repo, match, opts, pr' | |||
|
1099 | 1069 |
|
|
1100 | 1070 |
|
|
1101 | 1071 |
|
|
1102 | slowpath = True | |
|
1103 | break | |
|
1072 | raise FileWalkError("Cannot walk via filelog") | |
|
1104 | 1073 |
|
|
1105 | 1074 |
|
|
1106 | 1075 | |
@@ -1135,10 +1104,59 b' def walkchangerevs(repo, match, opts, pr' | |||
|
1135 | 1104 |
|
|
1136 | 1105 |
|
|
1137 | 1106 | |
|
1107 | return wanted | |
|
1108 | ||
|
1109 | def walkchangerevs(repo, match, opts, prepare): | |
|
1110 | '''Iterate over files and the revs in which they changed. | |
|
1111 | ||
|
1112 | Callers most commonly need to iterate backwards over the history | |
|
1113 | in which they are interested. Doing so has awful (quadratic-looking) | |
|
1114 | performance, so we use iterators in a "windowed" way. | |
|
1115 | ||
|
1116 | We walk a window of revisions in the desired order. Within the | |
|
1117 | window, we first walk forwards to gather data, then in the desired | |
|
1118 | order (usually backwards) to display it. | |
|
1119 | ||
|
1120 | This function returns an iterator yielding contexts. Before | |
|
1121 | yielding each context, the iterator will first call the prepare | |
|
1122 | function on each context in the window in forward order.''' | |
|
1123 | ||
|
1124 | follow = opts.get('follow') or opts.get('follow_first') | |
|
1125 | ||
|
1126 | if opts.get('rev'): | |
|
1127 | revs = scmutil.revrange(repo, opts.get('rev')) | |
|
1128 | elif follow: | |
|
1129 | revs = repo.revs('reverse(:.)') | |
|
1130 | else: | |
|
1131 | revs = list(repo) | |
|
1132 | revs.reverse() | |
|
1133 | if not revs: | |
|
1134 | return [] | |
|
1135 | wanted = set() | |
|
1136 | slowpath = match.anypats() or (match.files() and opts.get('removed')) | |
|
1137 | fncache = {} | |
|
1138 | change = repo.changectx | |
|
1139 | ||
|
1140 | # First step is to fill wanted, the set of revisions that we want to yield. | |
|
1141 | # When it does not induce extra cost, we also fill fncache for revisions in | |
|
1142 | # wanted: a cache of filenames that were changed (ctx.files()) and that | |
|
1143 | # match the file filtering conditions. | |
|
1144 | ||
|
1145 | if not slowpath and not match.files(): | |
|
1146 | # No files, no patterns. Display all revs. | |
|
1147 | wanted = set(revs) | |
|
1148 | ||
|
1149 | if not slowpath and match.files(): | |
|
1150 | # We only have to read through the filelog to find wanted revisions | |
|
1151 | ||
|
1152 | try: | |
|
1153 | wanted = walkfilerevs(repo, match, follow, revs, fncache) | |
|
1154 | except FileWalkError: | |
|
1155 | slowpath = True | |
|
1156 | ||
|
1138 | 1157 | # We decided to fall back to the slowpath because at least one |
|
1139 | 1158 | # of the paths was not a file. Check to see if at least one of them |
|
1140 | 1159 | # existed in history, otherwise simply return |
|
1141 | if slowpath: | |
|
1142 | 1160 | for path in match.files(): |
|
1143 | 1161 | if path == '.' or path in repo.store: |
|
1144 | 1162 | break |
General Comments 0
You need to be logged in to leave comments.
Login now