Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 17746:6d218e47cf9b
log: speed up hg log for untracked files (issue1340)
'hg log' on untracked files tends to be fairly slow. The root cause is that we end up using the 'slowpath' when we can't find a revlog for the files listed. This could happen if the file in question is an untracked file, or it is a directory.
This diff tries to speed up 'hg log' (by avoiding the slowpath) for files if we can determine if that file is not (and was never) a directory. We use the previously added store.__contains__ methods to test if the directory exists (or existed) in the store.
To avoid changing any existing semantics, this 'optimization' kicks in only when none of the files listed as arguments to the hg log command exist in the store.
author | smuralid |
---|---|
date | Thu, 13 Sep 2012 23:50:45 -0700 |
parents | f87683a1b02a |
children | 9912baaae7df |
comparison
equal
deleted
inserted
replaced
17745:b9a56b816ff2 | 17746:6d218e47cf9b |
---|---|
1109 | 1109 |
1110 fncache.setdefault(rev, []).append(file_) | 1110 fncache.setdefault(rev, []).append(file_) |
1111 wanted.add(rev) | 1111 wanted.add(rev) |
1112 if copied: | 1112 if copied: |
1113 copies.append(copied) | 1113 copies.append(copied) |
1114 | |
1115 # We decided to fall back to the slowpath because at least one | |
1116 # of the paths was not a file. Check to see if at least one of them | |
1117 # existed in history, otherwise simply return | |
1118 if slowpath: | |
1119 for path in match.files(): | |
1120 if path == '.' or path in repo.store: | |
1121 break | |
1122 else: | |
1123 return [] | |
1124 | |
1114 if slowpath: | 1125 if slowpath: |
1115 # We have to read the changelog to match filenames against | 1126 # We have to read the changelog to match filenames against |
1116 # changed files | 1127 # changed files |
1117 | 1128 |
1118 if follow: | 1129 if follow: |
1284 # try to find matching entries on the slow path. | 1295 # try to find matching entries on the slow path. |
1285 if follow: | 1296 if follow: |
1286 raise util.Abort( | 1297 raise util.Abort( |
1287 _('cannot follow nonexistent file: "%s"') % f) | 1298 _('cannot follow nonexistent file: "%s"') % f) |
1288 slowpath = True | 1299 slowpath = True |
1300 | |
1301 # We decided to fall back to the slowpath because at least one | |
1302 # of the paths was not a file. Check to see if at least one of them | |
1303 # existed in history - in that case, we'll continue down the | |
1304 # slowpath; otherwise, we can turn off the slowpath | |
1305 if slowpath: | |
1306 for path in match.files(): | |
1307 if path == '.' or path in repo.store: | |
1308 break | |
1309 else: | |
1310 slowpath = False | |
1311 | |
1289 if slowpath: | 1312 if slowpath: |
1290 # See walkchangerevs() slow path. | 1313 # See walkchangerevs() slow path. |
1291 # | 1314 # |
1292 if follow: | 1315 if follow: |
1293 raise util.Abort(_('can only follow copies/renames for explicit ' | 1316 raise util.Abort(_('can only follow copies/renames for explicit ' |