Show More
@@ -1,159 +1,165 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 | > narrowspecexpanded = False | |
60 | > def expandnarrowspec(ui, repo, newincludes=None): |
|
60 | > def expandnarrowspec(ui, repo, newincludes=None): | |
61 | > if not newincludes: |
|
61 | > if not newincludes: | |
62 | > return |
|
62 | > return | |
63 | > if getattr(repo, '_narrowspecexpanded', False): |
|
63 | > if getattr(repo, '_narrowspecexpanded', False): | |
64 | > return |
|
64 | > return | |
65 | > repo._narrowspecexpanded = True |
|
65 | > repo._narrowspecexpanded = True | |
66 | > import sys |
|
66 | > import sys | |
67 | > newincludes = set([newincludes]) |
|
67 | > newincludes = set([newincludes]) | |
68 | > includes, excludes = repo.narrowpats |
|
68 | > includes, excludes = repo.narrowpats | |
69 | > currentmatcher = narrowspec.match(repo.root, includes, excludes) |
|
69 | > currentmatcher = narrowspec.match(repo.root, includes, excludes) | |
70 | > includes = includes | newincludes |
|
70 | > includes = includes | newincludes | |
71 | > if not repo.currenttransaction(): |
|
71 | > if not repo.currenttransaction(): | |
72 | > ui.develwarn(b'expandnarrowspec called outside of transaction!') |
|
72 | > ui.develwarn(b'expandnarrowspec called outside of transaction!') | |
73 | > repo.setnarrowpats(includes, excludes) |
|
73 | > repo.setnarrowpats(includes, excludes) | |
74 | > narrowspec.copytoworkingcopy(repo) |
|
74 | > narrowspec.copytoworkingcopy(repo) | |
75 | > newmatcher = narrowspec.match(repo.root, includes, excludes) |
|
75 | > newmatcher = narrowspec.match(repo.root, includes, excludes) | |
76 | > added = matchmod.differencematcher(newmatcher, currentmatcher) |
|
76 | > added = matchmod.differencematcher(newmatcher, currentmatcher) | |
77 | > for f in repo[b'.'].manifest().walk(added): |
|
77 | > with repo.dirstate.parentchange(): | |
78 | > repo.dirstate.normallookup(f) |
|
78 | > for f in repo[b'.'].manifest().walk(added): | |
|
79 | > repo.dirstate.update_file( | |||
|
80 | > f, | |||
|
81 | > p1_tracked=True, | |||
|
82 | > wc_tracked=True, | |||
|
83 | > possibly_dirty=True, | |||
|
84 | > ) | |||
79 | > |
|
85 | > | |
80 | > def reposetup(ui, repo): |
|
86 | > def reposetup(ui, repo): | |
81 | > class expandingrepo(repo.__class__): |
|
87 | > class expandingrepo(repo.__class__): | |
82 | > def narrowmatch(self, *args, **kwargs): |
|
88 | > def narrowmatch(self, *args, **kwargs): | |
83 | > with repo.wlock(), repo.lock(), repo.transaction( |
|
89 | > with repo.wlock(), repo.lock(), repo.transaction( | |
84 | > b'expandnarrowspec'): |
|
90 | > b'expandnarrowspec'): | |
85 | > expandnarrowspec(ui, repo, |
|
91 | > expandnarrowspec(ui, repo, | |
86 | > encoding.environ.get(b'DIRSTATEINCLUDES')) |
|
92 | > encoding.environ.get(b'DIRSTATEINCLUDES')) | |
87 | > return super(expandingrepo, self).narrowmatch(*args, **kwargs) |
|
93 | > return super(expandingrepo, self).narrowmatch(*args, **kwargs) | |
88 | > repo.__class__ = expandingrepo |
|
94 | > repo.__class__ = expandingrepo | |
89 | > |
|
95 | > | |
90 | > def extsetup(unused_ui): |
|
96 | > def extsetup(unused_ui): | |
91 | > def overridepatch(orig, ui, repo, *args, **kwargs): |
|
97 | > def overridepatch(orig, ui, repo, *args, **kwargs): | |
92 | > with repo.wlock(): |
|
98 | > with repo.wlock(): | |
93 | > expandnarrowspec(ui, repo, encoding.environ.get(b'PATCHINCLUDES')) |
|
99 | > expandnarrowspec(ui, repo, encoding.environ.get(b'PATCHINCLUDES')) | |
94 | > return orig(ui, repo, *args, **kwargs) |
|
100 | > return orig(ui, repo, *args, **kwargs) | |
95 | > |
|
101 | > | |
96 | > extensions.wrapfunction(patch, b'patch', overridepatch) |
|
102 | > extensions.wrapfunction(patch, b'patch', overridepatch) | |
97 | > EOF |
|
103 | > EOF | |
98 | $ cat >> ".hg/hgrc" <<EOF |
|
104 | $ cat >> ".hg/hgrc" <<EOF | |
99 | > [extensions] |
|
105 | > [extensions] | |
100 | > expand_extension = $TESTTMP/expand_extension.py |
|
106 | > expand_extension = $TESTTMP/expand_extension.py | |
101 | > EOF |
|
107 | > EOF | |
102 |
|
108 | |||
103 | Since we do not have the ability to rely on a virtual filesystem or |
|
109 | Since we do not have the ability to rely on a virtual filesystem or | |
104 | remotefilelog in the test, we just fake it by copying the data from the 'master' |
|
110 | remotefilelog in the test, we just fake it by copying the data from the 'master' | |
105 | repo. |
|
111 | repo. | |
106 | $ cp -a ../master/.hg/store/data/* .hg/store/data |
|
112 | $ cp -a ../master/.hg/store/data/* .hg/store/data | |
107 | Do that for patchdir as well. |
|
113 | Do that for patchdir as well. | |
108 | $ cp -a ../master/patchdir . |
|
114 | $ cp -a ../master/patchdir . | |
109 |
|
115 | |||
110 | `hg status` will now add outside, but not patchdir. |
|
116 | `hg status` will now add outside, but not patchdir. | |
111 | $ DIRSTATEINCLUDES=path:outside hg status |
|
117 | $ DIRSTATEINCLUDES=path:outside hg status | |
112 | M outside/f2 |
|
118 | M outside/f2 | |
113 | $ hg tracked | grep outside |
|
119 | $ hg tracked | grep outside | |
114 | I path:outside |
|
120 | I path:outside | |
115 | $ hg files | grep outside > /dev/null |
|
121 | $ hg files | grep outside > /dev/null | |
116 | $ hg tracked | grep patchdir |
|
122 | $ hg tracked | grep patchdir | |
117 | [1] |
|
123 | [1] | |
118 | $ hg files | grep patchdir |
|
124 | $ hg files | grep patchdir | |
119 | [1] |
|
125 | [1] | |
120 |
|
126 | |||
121 | Get rid of the modification to outside/f2. |
|
127 | Get rid of the modification to outside/f2. | |
122 | $ hg update -C . |
|
128 | $ hg update -C . | |
123 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
129 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
124 |
|
130 | |||
125 | This patch will not apply cleanly at the moment, so `hg import` will break |
|
131 | This patch will not apply cleanly at the moment, so `hg import` will break | |
126 | $ cat > "$TESTTMP/foo.patch" <<EOF |
|
132 | $ cat > "$TESTTMP/foo.patch" <<EOF | |
127 | > --- patchdir/f3 |
|
133 | > --- patchdir/f3 | |
128 | > +++ patchdir/f3 |
|
134 | > +++ patchdir/f3 | |
129 | > @@ -1,1 +1,1 @@ |
|
135 | > @@ -1,1 +1,1 @@ | |
130 | > -this should be "patch_this", but its not, so patch fails |
|
136 | > -this should be "patch_this", but its not, so patch fails | |
131 | > +this text is irrelevant |
|
137 | > +this text is irrelevant | |
132 | > EOF |
|
138 | > EOF | |
133 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m ignored |
|
139 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m ignored | |
134 | applying $TESTTMP/foo.patch |
|
140 | applying $TESTTMP/foo.patch | |
135 | patching file patchdir/f3 |
|
141 | patching file patchdir/f3 | |
136 | Hunk #1 FAILED at 0 |
|
142 | Hunk #1 FAILED at 0 | |
137 | 1 out of 1 hunks FAILED -- saving rejects to file patchdir/f3.rej |
|
143 | 1 out of 1 hunks FAILED -- saving rejects to file patchdir/f3.rej | |
138 | abort: patch failed to apply |
|
144 | abort: patch failed to apply | |
139 | [255] |
|
145 | [255] | |
140 | $ hg tracked | grep patchdir |
|
146 | $ hg tracked | grep patchdir | |
141 | [1] |
|
147 | [1] | |
142 | $ hg files | grep patchdir > /dev/null |
|
148 | $ hg files | grep patchdir > /dev/null | |
143 | [1] |
|
149 | [1] | |
144 |
|
150 | |||
145 | Let's make it apply cleanly and see that it *did* expand properly |
|
151 | Let's make it apply cleanly and see that it *did* expand properly | |
146 | $ cat > "$TESTTMP/foo.patch" <<EOF |
|
152 | $ cat > "$TESTTMP/foo.patch" <<EOF | |
147 | > --- patchdir/f3 |
|
153 | > --- patchdir/f3 | |
148 | > +++ patchdir/f3 |
|
154 | > +++ patchdir/f3 | |
149 | > @@ -1,1 +1,1 @@ |
|
155 | > @@ -1,1 +1,1 @@ | |
150 | > -patch_this |
|
156 | > -patch_this | |
151 | > +patched_this |
|
157 | > +patched_this | |
152 | > EOF |
|
158 | > EOF | |
153 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m message |
|
159 | $ PATCHINCLUDES=path:patchdir hg import -p0 -e "$TESTTMP/foo.patch" -m message | |
154 | applying $TESTTMP/foo.patch |
|
160 | applying $TESTTMP/foo.patch | |
155 | $ cat patchdir/f3 |
|
161 | $ cat patchdir/f3 | |
156 | patched_this |
|
162 | patched_this | |
157 | $ hg tracked | grep patchdir |
|
163 | $ hg tracked | grep patchdir | |
158 | I path:patchdir |
|
164 | I path:patchdir | |
159 | $ hg files | grep patchdir > /dev/null |
|
165 | $ hg files | grep patchdir > /dev/null |
General Comments 0
You need to be logged in to leave comments.
Login now