##// END OF EJS Templates
revset: add a 'descend' argument to followlines to return descendants...
Denis Laxalde -
r31938:5e3b49de default
parent child Browse files
Show More
@@ -901,17 +901,22 b' def _followfirst(repo, subset, x):'
901 # of every revisions or files revisions.
901 # of every revisions or files revisions.
902 return _follow(repo, subset, x, '_followfirst', followfirst=True)
902 return _follow(repo, subset, x, '_followfirst', followfirst=True)
903
903
904 @predicate('followlines(file, fromline:toline[, startrev=.])', safe=True)
904 @predicate('followlines(file, fromline:toline[, startrev=., descend=False])',
905 safe=True)
905 def followlines(repo, subset, x):
906 def followlines(repo, subset, x):
906 """Changesets modifying `file` in line range ('fromline', 'toline').
907 """Changesets modifying `file` in line range ('fromline', 'toline').
907
908
908 Line range corresponds to 'file' content at 'startrev' and should hence be
909 Line range corresponds to 'file' content at 'startrev' and should hence be
909 consistent with file size. If startrev is not specified, working directory's
910 consistent with file size. If startrev is not specified, working directory's
910 parent is used.
911 parent is used.
912
913 By default, ancestors of 'startrev' are returned. If 'descend' is True,
914 descendants of 'startrev' are returned though renames are (currently) not
915 followed in this direction.
911 """
916 """
912 from . import context # avoid circular import issues
917 from . import context # avoid circular import issues
913
918
914 args = getargsdict(x, 'followlines', 'file *lines startrev')
919 args = getargsdict(x, 'followlines', 'file *lines startrev descend')
915 if len(args['lines']) != 1:
920 if len(args['lines']) != 1:
916 raise error.ParseError(_("followlines requires a line range"))
921 raise error.ParseError(_("followlines requires a line range"))
917
922
@@ -939,9 +944,17 b' def followlines(repo, subset, x):'
939 fromline, toline = util.processlinerange(fromline, toline)
944 fromline, toline = util.processlinerange(fromline, toline)
940
945
941 fctx = repo[rev].filectx(fname)
946 fctx = repo[rev].filectx(fname)
942 revs = (c.rev() for c, _linerange
947 if args.get('descend', False):
943 in context.blockancestors(fctx, fromline, toline))
948 rs = generatorset(
944 return subset & generatorset(revs, iterasc=False)
949 (c.rev() for c, _linerange
950 in context.blockdescendants(fctx, fromline, toline)),
951 iterasc=True)
952 else:
953 rs = generatorset(
954 (c.rev() for c, _linerange
955 in context.blockancestors(fctx, fromline, toline)),
956 iterasc=False)
957 return subset & rs
945
958
946 @predicate('all()', safe=True)
959 @predicate('all()', safe=True)
947 def getall(repo, subset, x):
960 def getall(repo, subset, x):
@@ -484,7 +484,9 b' annotate removed file'
484 $ hg id -n
484 $ hg id -n
485 20
485 20
486
486
487 Test followlines() revset
487 Test followlines() revset; we usually check both followlines(pat, range) and
488 followlines(pat, range, descend=True) to make sure both give the same result
489 when they should.
488
490
489 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5)'
491 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5)'
490 16: baz:0
492 16: baz:0
@@ -494,9 +496,11 b' Test followlines() revset'
494 16: baz:0
496 16: baz:0
495 19: baz:3
497 19: baz:3
496 20: baz:4
498 20: baz:4
497 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=.^)'
499 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19)'
498 16: baz:0
500 16: baz:0
499 19: baz:3
501 19: baz:3
502 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=True)'
503 20: baz:4
500 $ printf "0\n0\n" | cat - baz > baz1
504 $ printf "0\n0\n" | cat - baz > baz1
501 $ mv baz1 baz
505 $ mv baz1 baz
502 $ hg ci -m 'added two lines with 0'
506 $ hg ci -m 'added two lines with 0'
@@ -504,12 +508,16 b' Test followlines() revset'
504 16: baz:0
508 16: baz:0
505 19: baz:3
509 19: baz:3
506 20: baz:4
510 20: baz:4
511 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, descend=True, startrev=19)'
512 20: baz:4
507 $ echo 6 >> baz
513 $ echo 6 >> baz
508 $ hg ci -m 'added line 8'
514 $ hg ci -m 'added line 8'
509 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)'
515 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)'
510 16: baz:0
516 16: baz:0
511 19: baz:3
517 19: baz:3
512 20: baz:4
518 20: baz:4
519 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=True)'
520 20: baz:4
513 $ sed 's/3/3+/' baz > baz.new
521 $ sed 's/3/3+/' baz > baz.new
514 $ mv baz.new baz
522 $ mv baz.new baz
515 $ hg ci -m 'baz:3->3+'
523 $ hg ci -m 'baz:3->3+'
@@ -518,6 +526,9 b' Test followlines() revset'
518 19: baz:3
526 19: baz:3
519 20: baz:4
527 20: baz:4
520 23: baz:3->3+
528 23: baz:3->3+
529 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=True)'
530 20: baz:4
531 23: baz:3->3+
521 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 1:2)'
532 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 1:2)'
522 21: added two lines with 0
533 21: added two lines with 0
523
534
@@ -536,9 +547,13 b' renames are followed'
536 20: baz:4
547 20: baz:4
537 23: baz:3->3+
548 23: baz:3->3+
538 24: qux:4->4+
549 24: qux:4->4+
539 $ hg up 23 --quiet
550
551 but are missed when following children
552 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, startrev=22, descend=True)'
553 23: baz:3->3+
540
554
541 merge
555 merge
556 $ hg up 23 --quiet
542 $ echo 7 >> baz
557 $ echo 7 >> baz
543 $ hg ci -m 'one more line, out of line range'
558 $ hg ci -m 'one more line, out of line range'
544 created new head
559 created new head
@@ -581,6 +596,10 b' merge'
581 28: merge from other side
596 28: merge from other side
582 $ hg up 23 --quiet
597 $ hg up 23 --quiet
583
598
599 we are missing the branch with rename when following children
600 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, startrev=25, descend=True)'
601 26: baz:3+->3-
602
584 check error cases
603 check error cases
585 $ hg log -r 'followlines()'
604 $ hg log -r 'followlines()'
586 hg: parse error: followlines takes at least 1 positional arguments
605 hg: parse error: followlines takes at least 1 positional arguments
General Comments 0
You need to be logged in to leave comments. Login now