Mercurial > hg
comparison tests/test-narrow-expanddirstate.t @ 36160:9fd8c2a3db5a
narrowspec: move module into core
Having support for parsing the narrow specification in core is
necessary for moving many other parts of narrow to core.
We do still want to harmonize the narrow spec with the sparse
spec. And the format needs to be documented. But this shouldn't
hold up the code moving to core.
Differential Revision: https://phab.mercurial-scm.org/D2201
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 12 Feb 2018 16:21:34 -0800 |
parents | a2a6e724d61a |
children | 48797b21882e |
comparison
equal
deleted
inserted
replaced
36159:0fe7e39dc683 | 36160:9fd8c2a3db5a |
---|---|
49 > import sys | 49 > import sys |
50 > | 50 > |
51 > from mercurial import extensions | 51 > from mercurial import extensions |
52 > from mercurial import localrepo | 52 > from mercurial import localrepo |
53 > from mercurial import match as matchmod | 53 > from mercurial import match as matchmod |
54 > from mercurial import narrowspec | |
54 > from mercurial import patch | 55 > from mercurial import patch |
55 > from mercurial import util as hgutil | 56 > from mercurial import util as hgutil |
56 > | 57 > |
57 > def expandnarrowspec(ui, repo, newincludes=None): | 58 > def expandnarrowspec(ui, repo, newincludes=None): |
58 > if not newincludes: | 59 > if not newincludes: |
59 > return | 60 > return |
60 > import sys | 61 > import sys |
61 > newincludes = set([newincludes]) | 62 > newincludes = set([newincludes]) |
62 > narrowhg = extensions.find('narrow') | |
63 > includes, excludes = repo.narrowpats | 63 > includes, excludes = repo.narrowpats |
64 > currentmatcher = narrowhg.narrowspec.match(repo.root, includes, excludes) | 64 > currentmatcher = narrowspec.match(repo.root, includes, excludes) |
65 > includes = includes | newincludes | 65 > includes = includes | newincludes |
66 > if not repo.currenttransaction(): | 66 > if not repo.currenttransaction(): |
67 > ui.develwarn('expandnarrowspec called outside of transaction!') | 67 > ui.develwarn('expandnarrowspec called outside of transaction!') |
68 > repo.setnarrowpats(includes, excludes) | 68 > repo.setnarrowpats(includes, excludes) |
69 > newmatcher = narrowhg.narrowspec.match(repo.root, includes, excludes) | 69 > newmatcher = narrowspec.match(repo.root, includes, excludes) |
70 > added = matchmod.differencematcher(newmatcher, currentmatcher) | 70 > added = matchmod.differencematcher(newmatcher, currentmatcher) |
71 > for f in repo['.'].manifest().walk(added): | 71 > for f in repo['.'].manifest().walk(added): |
72 > repo.dirstate.normallookup(f) | 72 > repo.dirstate.normallookup(f) |
73 > | 73 > |
74 > def makeds(ui, repo): | 74 > def makeds(ui, repo): |