Show More
@@ -1,164 +1,158 b'' | |||||
1 | $ . "$TESTDIR/narrow-library.sh" |
|
1 | $ . "$TESTDIR/narrow-library.sh" | |
2 |
|
2 | |||
3 | $ hg init master |
|
3 | $ hg init master | |
4 | $ cd master |
|
4 | $ cd master | |
5 |
|
5 | |||
6 | $ mkdir inside |
|
6 | $ mkdir inside | |
7 | $ echo inside > inside/f1 |
|
7 | $ echo inside > inside/f1 | |
8 | $ mkdir outside |
|
8 | $ mkdir outside | |
9 | $ echo outside > outside/f2 |
|
9 | $ echo outside > outside/f2 | |
10 | $ mkdir patchdir |
|
10 | $ mkdir patchdir | |
11 | $ echo patch_this > patchdir/f3 |
|
11 | $ echo patch_this > patchdir/f3 | |
12 | $ hg ci -Aqm 'initial' |
|
12 | $ hg ci -Aqm 'initial' | |
13 |
|
13 | |||
14 | $ cd .. |
|
14 | $ cd .. | |
15 |
|
15 | |||
16 | $ hg clone --narrow ssh://user@dummy/master narrow --include inside |
|
16 | $ hg clone --narrow ssh://user@dummy/master narrow --include inside | |
17 | requesting all changes |
|
17 | requesting all changes | |
18 | adding changesets |
|
18 | adding changesets | |
19 | adding manifests |
|
19 | adding manifests | |
20 | adding file changes |
|
20 | adding file changes | |
21 | added 1 changesets with 1 changes to 1 files |
|
21 | added 1 changesets with 1 changes to 1 files | |
22 | new changesets dff6a2a6d433 |
|
22 | new changesets dff6a2a6d433 | |
23 | updating to branch default |
|
23 | updating to branch default | |
24 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
24 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
25 |
|
25 | |||
26 | $ cd narrow |
|
26 | $ cd narrow | |
27 |
|
27 | |||
28 | $ mkdir outside |
|
28 | $ mkdir outside | |
29 | $ echo other_contents > outside/f2 |
|
29 | $ echo other_contents > outside/f2 | |
30 | $ hg tracked | grep outside |
|
30 | $ hg tracked | grep outside | |
31 | [1] |
|
31 | [1] | |
32 | $ hg files | grep outside |
|
32 | $ hg files | grep outside | |
33 | [1] |
|
33 | [1] | |
34 | $ hg status |
|
34 | $ hg status | |
35 |
|
35 | |||
36 | `hg status` did not add outside. |
|
36 | `hg status` did not add outside. | |
37 | $ hg tracked | grep outside |
|
37 | $ hg tracked | grep outside | |
38 | [1] |
|
38 | [1] | |
39 | $ hg files | grep outside |
|
39 | $ hg files | grep outside | |
40 | [1] |
|
40 | [1] | |
41 |
|
41 | |||
42 | Unfortunately this is not really a candidate for adding to narrowhg proper, |
|
42 | Unfortunately this is not really a candidate for adding to narrowhg proper, | |
43 | since it depends on some other source for providing the manifests (when using |
|
43 | since it depends on some other source for providing the manifests (when using | |
44 | treemanifests) and file contents. Something like a virtual filesystem and/or |
|
44 | treemanifests) and file contents. Something like a virtual filesystem and/or | |
45 | remotefilelog. We want to be useful when not using those systems, so we do not |
|
45 | remotefilelog. We want to be useful when not using those systems, so we do not | |
46 | have this method available in narrowhg proper at the moment. |
|
46 | have this method available in narrowhg proper at the moment. | |
47 | $ cat > "$TESTTMP/expand_extension.py" <<EOF |
|
47 | $ cat > "$TESTTMP/expand_extension.py" <<EOF | |
48 | > import os |
|
48 | > import os | |
49 | > import sys |
|
49 | > import sys | |
50 | > |
|
50 | > | |
51 | > from mercurial import encoding |
|
51 | > from mercurial import encoding | |
52 | > from mercurial import extensions |
|
52 | > from mercurial import extensions | |
53 | > from mercurial import localrepo |
|
53 | > from mercurial import localrepo | |
54 | > from mercurial import match as matchmod |
|
54 | > from mercurial import match as matchmod | |
55 | > from mercurial import narrowspec |
|
55 | > from mercurial import narrowspec | |
56 | > from mercurial import patch |
|
56 | > from mercurial import patch | |
57 | > from mercurial import util as hgutil |
|
57 | > from mercurial import util as hgutil | |
58 | > |
|
58 | > | |
|
59 | > narrowspecexpanded = False | |||
59 | > def expandnarrowspec(ui, repo, newincludes=None): |
|
60 | > def expandnarrowspec(ui, repo, newincludes=None): | |
60 | > if not newincludes: |
|
61 | > if not newincludes: | |
61 | > return |
|
62 | > return | |
|
63 | > if getattr(repo, '_narrowspecexpanded', False): | |||
|
64 | > return | |||
|
65 | > repo._narrowspecexpanded = True | |||
62 | > import sys |
|
66 | > import sys | |
63 | > newincludes = set([newincludes]) |
|
67 | > newincludes = set([newincludes]) | |
64 | > includes, excludes = repo.narrowpats |
|
68 | > includes, excludes = repo.narrowpats | |
65 | > currentmatcher = narrowspec.match(repo.root, includes, excludes) |
|
69 | > currentmatcher = narrowspec.match(repo.root, includes, excludes) | |
66 | > includes = includes | newincludes |
|
70 | > includes = includes | newincludes | |
67 | > if not repo.currenttransaction(): |
|
71 | > if not repo.currenttransaction(): | |
68 | > ui.develwarn(b'expandnarrowspec called outside of transaction!') |
|
72 | > ui.develwarn(b'expandnarrowspec called outside of transaction!') | |
69 | > repo.setnarrowpats(includes, excludes) |
|
73 | > repo.setnarrowpats(includes, excludes) | |
70 | > newmatcher = narrowspec.match(repo.root, includes, excludes) |
|
74 | > newmatcher = narrowspec.match(repo.root, includes, excludes) | |
71 | > added = matchmod.differencematcher(newmatcher, currentmatcher) |
|
75 | > added = matchmod.differencematcher(newmatcher, currentmatcher) | |
72 | > for f in repo[b'.'].manifest().walk(added): |
|
76 | > for f in repo[b'.'].manifest().walk(added): | |
73 | > repo.dirstate.normallookup(f) |
|
77 | > repo.dirstate.normallookup(f) | |
74 | > |
|
78 | > | |
75 |
> def |
|
79 | > def reposetup(ui, repo): | |
76 |
> class expanding |
|
80 | > class expandingrepo(repo.__class__): | |
77 | > @hgutil.propertycache |
|
81 | > def narrowmatch(self, *args, **kwargs): | |
78 | > def _map(self): |
|
|||
79 | > ret = super(expandingdirstate, self)._map |
|
|||
80 | > with repo.wlock(), repo.lock(), repo.transaction( |
|
82 | > with repo.wlock(), repo.lock(), repo.transaction( | |
81 | > b'expandnarrowspec'): |
|
83 | > b'expandnarrowspec'): | |
82 | > expandnarrowspec(ui, repo, |
|
84 | > expandnarrowspec(ui, repo, | |
83 | > encoding.environ.get(b'DIRSTATEINCLUDES')) |
|
85 | > encoding.environ.get(b'DIRSTATEINCLUDES')) | |
84 | > return ret |
|
86 | > return super(expandingrepo, self).narrowmatch(*args, **kwargs) | |
85 | > ds.__class__ = expandingdirstate |
|
|||
86 | > return ds |
|
|||
87 | > |
|
|||
88 | > def reposetup(ui, repo): |
|
|||
89 | > class expandingrepo(repo.__class__): |
|
|||
90 | > def _makedirstate(self): |
|
|||
91 | > dirstate = super(expandingrepo, self)._makedirstate() |
|
|||
92 | > return wrapds(ui, repo, dirstate) |
|
|||
93 | > repo.__class__ = expandingrepo |
|
87 | > repo.__class__ = expandingrepo | |
94 | > |
|
88 | > | |
95 | > def extsetup(unused_ui): |
|
89 | > def extsetup(unused_ui): | |
96 | > def overridepatch(orig, ui, repo, *args, **kwargs): |
|
90 | > def overridepatch(orig, ui, repo, *args, **kwargs): | |
97 | > with repo.wlock(): |
|
91 | > with repo.wlock(): | |
98 | > expandnarrowspec(ui, repo, encoding.environ.get(b'PATCHINCLUDES')) |
|
92 | > expandnarrowspec(ui, repo, encoding.environ.get(b'PATCHINCLUDES')) | |
99 | > return orig(ui, repo, *args, **kwargs) |
|
93 | > return orig(ui, repo, *args, **kwargs) | |
100 | > |
|
94 | > | |
101 | > extensions.wrapfunction(patch, b'patch', overridepatch) |
|
95 | > extensions.wrapfunction(patch, b'patch', overridepatch) | |
102 | > EOF |
|
96 | > EOF | |
103 | $ cat >> ".hg/hgrc" <<EOF |
|
97 | $ cat >> ".hg/hgrc" <<EOF | |
104 | > [extensions] |
|
98 | > [extensions] | |
105 | > expand_extension = $TESTTMP/expand_extension.py |
|
99 | > expand_extension = $TESTTMP/expand_extension.py | |
106 | > EOF |
|
100 | > EOF | |
107 |
|
101 | |||
108 | Since we do not have the ability to rely on a virtual filesystem or |
|
102 | Since we do not have the ability to rely on a virtual filesystem or | |
109 | remotefilelog in the test, we just fake it by copying the data from the 'master' |
|
103 | remotefilelog in the test, we just fake it by copying the data from the 'master' | |
110 | repo. |
|
104 | repo. | |
111 | $ cp -a ../master/.hg/store/data/* .hg/store/data |
|
105 | $ cp -a ../master/.hg/store/data/* .hg/store/data | |
112 | Do that for patchdir as well. |
|
106 | Do that for patchdir as well. | |
113 | $ cp -a ../master/patchdir . |
|
107 | $ cp -a ../master/patchdir . | |
114 |
|
108 | |||
115 | `hg status` will now add outside, but not patchdir. |
|
109 | `hg status` will now add outside, but not patchdir. | |
116 | $ DIRSTATEINCLUDES=path:outside hg status |
|
110 | $ DIRSTATEINCLUDES=path:outside hg status | |
117 | M outside/f2 |
|
111 | M outside/f2 | |
118 | $ hg tracked | grep outside |
|
112 | $ hg tracked | grep outside | |
119 | I path:outside |
|
113 | I path:outside | |
120 | $ hg files | grep outside > /dev/null |
|
114 | $ hg files | grep outside > /dev/null | |
121 | $ hg tracked | grep patchdir |
|
115 | $ hg tracked | grep patchdir | |
122 | [1] |
|
116 | [1] | |
123 | $ hg files | grep patchdir |
|
117 | $ hg files | grep patchdir | |
124 | [1] |
|
118 | [1] | |
125 |
|
119 | |||
126 | Get rid of the modification to outside/f2. |
|
120 | Get rid of the modification to outside/f2. | |
127 | $ hg update -C . |
|
121 | $ hg update -C . | |
128 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
122 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
129 |
|
123 | |||
130 | This patch will not apply cleanly at the moment, so `hg import` will break |
|
124 | This patch will not apply cleanly at the moment, so `hg import` will break | |
131 | $ cat > "$TESTTMP/foo.patch" <<EOF |
|
125 | $ cat > "$TESTTMP/foo.patch" <<EOF | |
132 | > --- patchdir/f3 |
|
126 | > --- patchdir/f3 | |
133 | > +++ patchdir/f3 |
|
127 | > +++ patchdir/f3 | |
134 | > @@ -1,1 +1,1 @@ |
|
128 | > @@ -1,1 +1,1 @@ | |
135 | > -this should be "patch_this", but its not, so patch fails |
|
129 | > -this should be "patch_this", but its not, so patch fails | |
136 | > +this text is irrelevant |
|
130 | > +this text is irrelevant | |
137 | > EOF |
|
131 | > EOF | |
138 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m ignored |
|
132 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m ignored | |
139 | applying $TESTTMP/foo.patch |
|
133 | applying $TESTTMP/foo.patch | |
140 | patching file patchdir/f3 |
|
134 | patching file patchdir/f3 | |
141 | Hunk #1 FAILED at 0 |
|
135 | Hunk #1 FAILED at 0 | |
142 | 1 out of 1 hunks FAILED -- saving rejects to file patchdir/f3.rej |
|
136 | 1 out of 1 hunks FAILED -- saving rejects to file patchdir/f3.rej | |
143 | abort: patch failed to apply |
|
137 | abort: patch failed to apply | |
144 | [255] |
|
138 | [255] | |
145 | $ hg tracked | grep patchdir |
|
139 | $ hg tracked | grep patchdir | |
146 | [1] |
|
140 | [1] | |
147 | $ hg files | grep patchdir > /dev/null |
|
141 | $ hg files | grep patchdir > /dev/null | |
148 | [1] |
|
142 | [1] | |
149 |
|
143 | |||
150 | Let's make it apply cleanly and see that it *did* expand properly |
|
144 | Let's make it apply cleanly and see that it *did* expand properly | |
151 | $ cat > "$TESTTMP/foo.patch" <<EOF |
|
145 | $ cat > "$TESTTMP/foo.patch" <<EOF | |
152 | > --- patchdir/f3 |
|
146 | > --- patchdir/f3 | |
153 | > +++ patchdir/f3 |
|
147 | > +++ patchdir/f3 | |
154 | > @@ -1,1 +1,1 @@ |
|
148 | > @@ -1,1 +1,1 @@ | |
155 | > -patch_this |
|
149 | > -patch_this | |
156 | > +patched_this |
|
150 | > +patched_this | |
157 | > EOF |
|
151 | > EOF | |
158 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m message |
|
152 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m message | |
159 | applying $TESTTMP/foo.patch |
|
153 | applying $TESTTMP/foo.patch | |
160 | $ cat patchdir/f3 |
|
154 | $ cat patchdir/f3 | |
161 | patched_this |
|
155 | patched_this | |
162 | $ hg tracked | grep patchdir |
|
156 | $ hg tracked | grep patchdir | |
163 | I path:patchdir |
|
157 | I path:patchdir | |
164 | $ hg files | grep patchdir > /dev/null |
|
158 | $ hg files | grep patchdir > /dev/null |
General Comments 0
You need to be logged in to leave comments.
Login now