equal
deleted
inserted
replaced
45 |
45 |
46 |
46 |
47 if pycompat.TYPE_CHECKING: |
47 if pycompat.TYPE_CHECKING: |
48 from typing import ( |
48 from typing import ( |
49 Any, |
49 Any, |
|
50 Callable, |
50 Dict, |
51 Dict, |
51 List, |
52 List, |
52 Optional, |
53 Optional, |
53 Tuple, |
54 Tuple, |
54 ) |
55 ) |
55 |
56 |
56 for t in (Any, Dict, List, Optional, Tuple): |
57 for t in (Any, Callable, Dict, List, Optional, Tuple): |
57 assert t |
58 assert t |
58 |
59 |
59 |
60 |
60 def getlimit(opts): |
61 def getlimit(opts): |
61 """get the log limit according to option -l/--limit""" |
62 """get the log limit according to option -l/--limit""" |
719 |
720 |
720 def parseopts(ui, pats, opts): |
721 def parseopts(ui, pats, opts): |
721 # type: (Any, List[bytes], Dict[bytes, Any]) -> walkopts |
722 # type: (Any, List[bytes], Dict[bytes, Any]) -> walkopts |
722 """Parse log command options into walkopts |
723 """Parse log command options into walkopts |
723 |
724 |
724 The returned walkopts will be passed in to getrevs(). |
725 The returned walkopts will be passed in to getrevs() or makewalker(). |
725 """ |
726 """ |
726 if opts.get(b'follow_first'): |
727 if opts.get(b'follow_first'): |
727 follow = 1 |
728 follow = 1 |
728 elif opts.get(b'follow'): |
729 elif opts.get(b'follow'): |
729 follow = 2 |
730 follow = 2 |
954 revs = smartset.spanset(repo) |
955 revs = smartset.spanset(repo) |
955 revs.reverse() |
956 revs.reverse() |
956 return revs |
957 return revs |
957 |
958 |
958 |
959 |
959 def getrevs(repo, wopts): |
960 def makewalker(repo, wopts): |
960 # type: (Any, walkopts) -> Tuple[smartset.abstractsmartset, Optional[changesetdiffer]] |
961 # type: (Any, walkopts) -> Tuple[smartset.abstractsmartset, Optional[Callable[[Any], matchmod.basematcher]]] |
961 """Return (revs, differ) where revs is a smartset |
962 """Build (revs, makefilematcher) to scan revision/file history |
962 |
963 |
963 differ is a changesetdiffer with pre-configured file matcher. |
964 - revs is the smartset to be traversed. |
|
965 - makefilematcher is a function to map ctx to a matcher for that revision |
964 """ |
966 """ |
965 revs = _initialrevs(repo, wopts) |
967 revs = _initialrevs(repo, wopts) |
966 if not revs: |
968 if not revs: |
967 return smartset.baseset(), None |
969 return smartset.baseset(), None |
968 # TODO: might want to merge slowpath with wopts.force_changelog_traversal |
970 # TODO: might want to merge slowpath with wopts.force_changelog_traversal |
1001 matcher = revset.match(None, expr) |
1003 matcher = revset.match(None, expr) |
1002 revs = matcher(repo, revs) |
1004 revs = matcher(repo, revs) |
1003 if wopts.limit is not None: |
1005 if wopts.limit is not None: |
1004 revs = revs.slice(0, wopts.limit) |
1006 revs = revs.slice(0, wopts.limit) |
1005 |
1007 |
|
1008 return revs, filematcher |
|
1009 |
|
1010 |
|
1011 def getrevs(repo, wopts): |
|
1012 # type: (Any, walkopts) -> Tuple[smartset.abstractsmartset, Optional[changesetdiffer]] |
|
1013 """Return (revs, differ) where revs is a smartset |
|
1014 |
|
1015 differ is a changesetdiffer with pre-configured file matcher. |
|
1016 """ |
|
1017 revs, filematcher = makewalker(repo, wopts) |
|
1018 if not revs: |
|
1019 return revs, None |
1006 differ = changesetdiffer() |
1020 differ = changesetdiffer() |
1007 differ._makefilematcher = filematcher |
1021 differ._makefilematcher = filematcher |
1008 return revs, differ |
1022 return revs, differ |
1009 |
1023 |
1010 |
1024 |