Mercurial > hg > mercurial-source
comparison mercurial/revset.py @ 15964:6e37b8282aa2 stable
revsets: provide contexts for filesets
Before this change, revsets containing fileset patterns failed. This
allows queries like:
hg log -r "contains('set: added() and symlink()')"
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 20 Jan 2012 23:05:04 -0600 |
parents | d5edbbf55a75 |
children | 57738b9130ae |
comparison
equal
deleted
inserted
replaced
15963:042e84e39dee | 15964:6e37b8282aa2 |
---|---|
294 b.add(repo[r].branch()) | 294 b.add(repo[r].branch()) |
295 s = set(s) | 295 s = set(s) |
296 return [r for r in subset if r in s or repo[r].branch() in b] | 296 return [r for r in subset if r in s or repo[r].branch() in b] |
297 | 297 |
298 def checkstatus(repo, subset, pat, field): | 298 def checkstatus(repo, subset, pat, field): |
299 m = matchmod.match(repo.root, repo.getcwd(), [pat]) | 299 m = None |
300 s = [] | 300 s = [] |
301 fast = (m.files() == [pat]) | 301 fast = not matchmod.patkind(pat) |
302 for r in subset: | 302 for r in subset: |
303 c = repo[r] | 303 c = repo[r] |
304 if fast: | 304 if fast: |
305 if pat not in c.files(): | 305 if pat not in c.files(): |
306 continue | 306 continue |
307 else: | 307 else: |
308 if not m or matchmod.patkind(pat) == 'set': | |
309 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
308 for f in c.files(): | 310 for f in c.files(): |
309 if m(f): | 311 if m(f): |
310 break | 312 break |
311 else: | 313 else: |
312 continue | 314 continue |
352 Revision contains a file matching pattern. See :hg:`help patterns` | 354 Revision contains a file matching pattern. See :hg:`help patterns` |
353 for information about file patterns. | 355 for information about file patterns. |
354 """ | 356 """ |
355 # i18n: "contains" is a keyword | 357 # i18n: "contains" is a keyword |
356 pat = getstring(x, _("contains requires a pattern")) | 358 pat = getstring(x, _("contains requires a pattern")) |
357 m = matchmod.match(repo.root, repo.getcwd(), [pat]) | 359 m = None |
358 s = [] | 360 s = [] |
359 if m.files() == [pat]: | 361 if not matchmod.patkind(pat): |
360 for r in subset: | 362 for r in subset: |
361 if pat in repo[r]: | 363 if pat in repo[r]: |
362 s.append(r) | 364 s.append(r) |
363 else: | 365 else: |
364 for r in subset: | 366 for r in subset: |
365 for f in repo[r].manifest(): | 367 c = repo[r] |
368 if not m or matchmod.patkind(pat) == 'set': | |
369 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
370 for f in c.manifest(): | |
366 if m(f): | 371 if m(f): |
367 s.append(r) | 372 s.append(r) |
368 break | 373 break |
369 return s | 374 return s |
370 | 375 |
410 """``filelog(pattern)`` | 415 """``filelog(pattern)`` |
411 Changesets connected to the specified filelog. | 416 Changesets connected to the specified filelog. |
412 """ | 417 """ |
413 | 418 |
414 pat = getstring(x, _("filelog requires a pattern")) | 419 pat = getstring(x, _("filelog requires a pattern")) |
415 m = matchmod.match(repo.root, repo.getcwd(), [pat], default='relpath') | 420 m = matchmod.match(repo.root, repo.getcwd(), [pat], default='relpath', |
421 ctx=repo[None]) | |
416 s = set() | 422 s = set() |
417 | 423 |
418 if not m.anypats(): | 424 if not matchmod.patkind(pat): |
419 for f in m.files(): | 425 for f in m.files(): |
420 fl = repo.file(f) | 426 fl = repo.file(f) |
421 for fr in fl: | 427 for fr in fl: |
422 s.add(fl.linkrev(fr)) | 428 s.add(fl.linkrev(fr)) |
423 else: | 429 else: |
498 """``file(pattern)`` | 504 """``file(pattern)`` |
499 Changesets affecting files matched by pattern. | 505 Changesets affecting files matched by pattern. |
500 """ | 506 """ |
501 # i18n: "file" is a keyword | 507 # i18n: "file" is a keyword |
502 pat = getstring(x, _("file requires a pattern")) | 508 pat = getstring(x, _("file requires a pattern")) |
503 m = matchmod.match(repo.root, repo.getcwd(), [pat]) | 509 m = None |
504 s = [] | 510 s = [] |
505 for r in subset: | 511 for r in subset: |
506 for f in repo[r].files(): | 512 c = repo[r] |
513 if not m or matchmod.patkind(pat) == 'set': | |
514 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
515 for f in c.files(): | |
507 if m(f): | 516 if m(f): |
508 s.append(r) | 517 s.append(r) |
509 break | 518 break |
510 return s | 519 return s |
511 | 520 |