Show More
@@ -15,6 +15,7 b' from . import (' | |||||
15 | merge, |
|
15 | merge, | |
16 | parser, |
|
16 | parser, | |
17 | registrar, |
|
17 | registrar, | |
|
18 | scmutil, | |||
18 | util, |
|
19 | util, | |
19 | ) |
|
20 | ) | |
20 |
|
21 | |||
@@ -438,6 +439,30 b' def copied(mctx, x):' | |||||
438 | s.append(f) |
|
439 | s.append(f) | |
439 | return s |
|
440 | return s | |
440 |
|
441 | |||
|
442 | @predicate('revs(revs, pattern)') | |||
|
443 | def revs(mctx, x): | |||
|
444 | """``revs(set, revspec)`` | |||
|
445 | ||||
|
446 | Evaluate set in the specified revisions. If the revset match multiple revs, | |||
|
447 | this will return file matching pattern in any of the revision. | |||
|
448 | """ | |||
|
449 | # i18n: "revs" is a keyword | |||
|
450 | r, x = getargs(x, 2, 2, _("revs takes two arguments")) | |||
|
451 | # i18n: "revs" is a keyword | |||
|
452 | revspec = getstring(r, _("first argument to revs must be a revision")) | |||
|
453 | repo = mctx.ctx.repo() | |||
|
454 | revs = scmutil.revrange(repo, [revspec]) | |||
|
455 | ||||
|
456 | found = set() | |||
|
457 | result = [] | |||
|
458 | for r in revs: | |||
|
459 | ctx = repo[r] | |||
|
460 | for f in getset(mctx.switch(ctx, _buildstatus(ctx, x)), x): | |||
|
461 | if f not in found: | |||
|
462 | found.add(f) | |||
|
463 | result.append(f) | |||
|
464 | return result | |||
|
465 | ||||
441 | @predicate('subrepo([pattern])') |
|
466 | @predicate('subrepo([pattern])') | |
442 | def subrepo(mctx, x): |
|
467 | def subrepo(mctx, x): | |
443 | """Subrepositories whose paths match the given pattern. |
|
468 | """Subrepositories whose paths match the given pattern. | |
@@ -512,6 +537,7 b' class fullmatchctx(matchctx):' | |||||
512 |
|
537 | |||
513 | # filesets using matchctx.switch() |
|
538 | # filesets using matchctx.switch() | |
514 | _switchcallers = [ |
|
539 | _switchcallers = [ | |
|
540 | 'revs', | |||
515 | ] |
|
541 | ] | |
516 |
|
542 | |||
517 | def _intree(funcs, tree): |
|
543 | def _intree(funcs, tree): |
@@ -69,6 +69,10 b' Some sample queries:' | |||||
69 |
|
69 | |||
70 | hg revert "set:copied() and binary() and size('>1M')" |
|
70 | hg revert "set:copied() and binary() and size('>1M')" | |
71 |
|
71 | |||
|
72 | - Revert files that were added to the working directory:: | |||
|
73 | ||||
|
74 | hg revert "set:wdir(added())" | |||
|
75 | ||||
72 | - Remove files listed in foo.lst that contain the letter a or b:: |
|
76 | - Remove files listed in foo.lst that contain the letter a or b:: | |
73 |
|
77 | |||
74 | hg remove "set: 'listfile:foo.lst' and (**a* or **b*)" |
|
78 | hg remove "set: 'listfile:foo.lst' and (**a* or **b*)" |
@@ -88,6 +88,35 b' Test files status' | |||||
88 | $ fileset 'copied()' |
|
88 | $ fileset 'copied()' | |
89 | c1 |
|
89 | c1 | |
90 |
|
90 | |||
|
91 | Test files status in different revisions | |||
|
92 | ||||
|
93 | $ hg status -m | |||
|
94 | M b2 | |||
|
95 | $ fileset -r0 'revs("wdir()", modified())' --traceback | |||
|
96 | b2 | |||
|
97 | $ hg status -a | |||
|
98 | A c1 | |||
|
99 | $ fileset -r0 'revs("wdir()", added())' | |||
|
100 | c1 | |||
|
101 | $ hg status --change 0 -a | |||
|
102 | A a1 | |||
|
103 | A a2 | |||
|
104 | A b1 | |||
|
105 | A b2 | |||
|
106 | $ hg status -mru | |||
|
107 | M b2 | |||
|
108 | R a2 | |||
|
109 | ? c3 | |||
|
110 | $ fileset -r0 'added() and revs("wdir()", modified() or removed() or unknown())' | |||
|
111 | b2 | |||
|
112 | a2 | |||
|
113 | $ fileset -r0 'added() or revs("wdir()", added())' | |||
|
114 | a1 | |||
|
115 | a2 | |||
|
116 | b1 | |||
|
117 | b2 | |||
|
118 | c1 | |||
|
119 | ||||
91 | Test files properties |
|
120 | Test files properties | |
92 |
|
121 | |||
93 | >>> file('bin', 'wb').write('\0a') |
|
122 | >>> file('bin', 'wb').write('\0a') | |
@@ -367,3 +396,128 b" Test detection of unintentional 'matchct" | |||||
367 |
|
396 | |||
368 | $ fileset 'existingcaller()' 2>&1 | tail -1 |
|
397 | $ fileset 'existingcaller()' 2>&1 | tail -1 | |
369 | AssertionError: unexpected existing() invocation |
|
398 | AssertionError: unexpected existing() invocation | |
|
399 | ||||
|
400 | Test 'revs(...)' | |||
|
401 | ================ | |||
|
402 | ||||
|
403 | small reminder of the repository state | |||
|
404 | ||||
|
405 | $ hg log -G | |||
|
406 | @ changeset: 4:160936123545 | |||
|
407 | | tag: tip | |||
|
408 | | user: test | |||
|
409 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
410 | | summary: subrepo | |||
|
411 | | | |||
|
412 | o changeset: 3:9d594e11b8c9 | |||
|
413 | |\ parent: 2:55b05bdebf36 | |||
|
414 | | | parent: 1:830839835f98 | |||
|
415 | | | user: test | |||
|
416 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
417 | | | summary: merge | |||
|
418 | | | | |||
|
419 | | o changeset: 2:55b05bdebf36 | |||
|
420 | | | parent: 0:8a9576c51c1f | |||
|
421 | | | user: test | |||
|
422 | | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
423 | | | summary: diverging | |||
|
424 | | | | |||
|
425 | o | changeset: 1:830839835f98 | |||
|
426 | |/ user: test | |||
|
427 | | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
428 | | summary: manychanges | |||
|
429 | | | |||
|
430 | o changeset: 0:8a9576c51c1f | |||
|
431 | user: test | |||
|
432 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
433 | summary: addfiles | |||
|
434 | ||||
|
435 | $ hg status --change 0 | |||
|
436 | A a1 | |||
|
437 | A a2 | |||
|
438 | A b1 | |||
|
439 | A b2 | |||
|
440 | $ hg status --change 1 | |||
|
441 | M b2 | |||
|
442 | A 1k | |||
|
443 | A 2k | |||
|
444 | A b2link | |||
|
445 | A bin | |||
|
446 | A c1 | |||
|
447 | A con.xml | |||
|
448 | R a2 | |||
|
449 | $ hg status --change 2 | |||
|
450 | M b2 | |||
|
451 | $ hg status --change 3 | |||
|
452 | M b2 | |||
|
453 | A 1k | |||
|
454 | A 2k | |||
|
455 | A b2link | |||
|
456 | A bin | |||
|
457 | A c1 | |||
|
458 | A con.xml | |||
|
459 | R a2 | |||
|
460 | $ hg status --change 4 | |||
|
461 | A .hgsub | |||
|
462 | A .hgsubstate | |||
|
463 | $ hg status | |||
|
464 | A dos | |||
|
465 | A mac | |||
|
466 | A mixed | |||
|
467 | R con.xml | |||
|
468 | ! a1 | |||
|
469 | ? b2.orig | |||
|
470 | ? c3 | |||
|
471 | ? unknown | |||
|
472 | ||||
|
473 | Test files at -r0 should be filtered by files at wdir | |||
|
474 | ----------------------------------------------------- | |||
|
475 | ||||
|
476 | $ fileset -r0 '* and revs("wdir()", *)' | |||
|
477 | a1 | |||
|
478 | b1 | |||
|
479 | b2 | |||
|
480 | ||||
|
481 | Test that "revs()" work at all | |||
|
482 | ------------------------------ | |||
|
483 | ||||
|
484 | $ fileset "revs('2', modified())" | |||
|
485 | b2 | |||
|
486 | ||||
|
487 | Test that "revs()" work for file missing in the working copy/current context | |||
|
488 | ---------------------------------------------------------------------------- | |||
|
489 | ||||
|
490 | (a2 not in working copy) | |||
|
491 | ||||
|
492 | $ fileset "revs('0', added())" | |||
|
493 | a1 | |||
|
494 | a2 | |||
|
495 | b1 | |||
|
496 | b2 | |||
|
497 | ||||
|
498 | (none of the file exist in "0") | |||
|
499 | ||||
|
500 | $ fileset -r 0 "revs('4', added())" | |||
|
501 | .hgsub | |||
|
502 | .hgsubstate | |||
|
503 | ||||
|
504 | Call with empty revset | |||
|
505 | -------------------------- | |||
|
506 | ||||
|
507 | $ fileset "revs('2-2', modified())" | |||
|
508 | ||||
|
509 | Call with revset matching multiple revs | |||
|
510 | --------------------------------------- | |||
|
511 | ||||
|
512 | $ fileset "revs('0+4', added())" | |||
|
513 | a1 | |||
|
514 | a2 | |||
|
515 | b1 | |||
|
516 | b2 | |||
|
517 | .hgsub | |||
|
518 | .hgsubstate | |||
|
519 | ||||
|
520 | overlapping set | |||
|
521 | ||||
|
522 | $ fileset "revs('1+2', modified())" | |||
|
523 | b2 |
General Comments 0
You need to be logged in to leave comments.
Login now