Show More
@@ -1,225 +1,229 b'' | |||
|
1 | 1 | # sshrepo.py - ssh repository proxy class for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 | 9 | import util, error, wireproto |
|
10 | 10 | |
|
11 | 11 | class remotelock(object): |
|
12 | 12 | def __init__(self, repo): |
|
13 | 13 | self.repo = repo |
|
14 | 14 | def release(self): |
|
15 | 15 | self.repo.unlock() |
|
16 | 16 | self.repo = None |
|
17 | 17 | def __del__(self): |
|
18 | 18 | if self.repo: |
|
19 | 19 | self.release() |
|
20 | 20 | |
|
21 | def _serverquote(s): | |
|
22 | '''quote a string for the remote shell ... which we assume is sh''' | |
|
23 | return "'%s'" % s.replace("'", "'\\''") | |
|
24 | ||
|
21 | 25 | class sshrepository(wireproto.wirerepository): |
|
22 | 26 | def __init__(self, ui, path, create=False): |
|
23 | 27 | self._url = path |
|
24 | 28 | self.ui = ui |
|
25 | 29 | |
|
26 | 30 | u = util.url(path, parsequery=False, parsefragment=False) |
|
27 | 31 | if u.scheme != 'ssh' or not u.host or u.path is None: |
|
28 | 32 | self._abort(error.RepoError(_("couldn't parse location %s") % path)) |
|
29 | 33 | |
|
30 | 34 | self.user = u.user |
|
31 | 35 | if u.passwd is not None: |
|
32 | 36 | self._abort(error.RepoError(_("password in URL not supported"))) |
|
33 | 37 | self.host = u.host |
|
34 | 38 | self.port = u.port |
|
35 | 39 | self.path = u.path or "." |
|
36 | 40 | |
|
37 | 41 | sshcmd = self.ui.config("ui", "ssh", "ssh") |
|
38 | 42 | remotecmd = self.ui.config("ui", "remotecmd", "hg") |
|
39 | 43 | |
|
40 | 44 | args = util.sshargs(sshcmd, self.host, self.user, self.port) |
|
41 | 45 | |
|
42 | 46 | if create: |
|
43 |
cmd = '%s %s |
|
|
44 | cmd = cmd % (sshcmd, args, remotecmd, self.path) | |
|
45 | ||
|
47 | cmd = '%s %s %s' % (sshcmd, args, | |
|
48 | util.shellquote("%s init %s" % | |
|
49 | (_serverquote(remotecmd), _serverquote(self.path)))) | |
|
46 | 50 | ui.note(_('running %s\n') % cmd) |
|
47 | 51 | res = util.system(cmd) |
|
48 | 52 | if res != 0: |
|
49 | 53 | self._abort(error.RepoError(_("could not create remote repo"))) |
|
50 | 54 | |
|
51 | 55 | self.validate_repo(ui, sshcmd, args, remotecmd) |
|
52 | 56 | |
|
53 | 57 | def url(self): |
|
54 | 58 | return self._url |
|
55 | 59 | |
|
56 | 60 | def validate_repo(self, ui, sshcmd, args, remotecmd): |
|
57 | 61 | # cleanup up previous run |
|
58 | 62 | self.cleanup() |
|
59 | 63 | |
|
60 |
cmd = '%s %s |
|
|
61 | cmd = cmd % (sshcmd, args, remotecmd, self.path) | |
|
62 | ||
|
64 | cmd = '%s %s %s' % (sshcmd, args, | |
|
65 | util.shellquote("%s -R %s serve --stdio" % | |
|
66 | (_serverquote(remotecmd), _serverquote(self.path)))) | |
|
67 | ui.note(_('running %s\n') % cmd) | |
|
63 | 68 | cmd = util.quotecommand(cmd) |
|
64 | ui.note(_('running %s\n') % cmd) | |
|
65 | 69 | self.pipeo, self.pipei, self.pipee = util.popen3(cmd) |
|
66 | 70 | |
|
67 | 71 | # skip any noise generated by remote shell |
|
68 | 72 | self._callstream("hello") |
|
69 | 73 | r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) |
|
70 | 74 | lines = ["", "dummy"] |
|
71 | 75 | max_noise = 500 |
|
72 | 76 | while lines[-1] and max_noise: |
|
73 | 77 | l = r.readline() |
|
74 | 78 | self.readerr() |
|
75 | 79 | if lines[-1] == "1\n" and l == "\n": |
|
76 | 80 | break |
|
77 | 81 | if l: |
|
78 | 82 | ui.debug("remote: ", l) |
|
79 | 83 | lines.append(l) |
|
80 | 84 | max_noise -= 1 |
|
81 | 85 | else: |
|
82 | 86 | self._abort(error.RepoError(_("no suitable response from remote hg"))) |
|
83 | 87 | |
|
84 | 88 | self.capabilities = set() |
|
85 | 89 | for l in reversed(lines): |
|
86 | 90 | if l.startswith("capabilities:"): |
|
87 | 91 | self.capabilities.update(l[:-1].split(":")[1].split()) |
|
88 | 92 | break |
|
89 | 93 | |
|
90 | 94 | def readerr(self): |
|
91 | 95 | while True: |
|
92 | 96 | size = util.fstat(self.pipee).st_size |
|
93 | 97 | if size == 0: |
|
94 | 98 | break |
|
95 | 99 | s = self.pipee.read(size) |
|
96 | 100 | if not s: |
|
97 | 101 | break |
|
98 | 102 | for l in s.splitlines(): |
|
99 | 103 | self.ui.status(_("remote: "), l, '\n') |
|
100 | 104 | |
|
101 | 105 | def _abort(self, exception): |
|
102 | 106 | self.cleanup() |
|
103 | 107 | raise exception |
|
104 | 108 | |
|
105 | 109 | def cleanup(self): |
|
106 | 110 | try: |
|
107 | 111 | self.pipeo.close() |
|
108 | 112 | self.pipei.close() |
|
109 | 113 | # read the error descriptor until EOF |
|
110 | 114 | for l in self.pipee: |
|
111 | 115 | self.ui.status(_("remote: "), l) |
|
112 | 116 | self.pipee.close() |
|
113 | 117 | except: |
|
114 | 118 | pass |
|
115 | 119 | |
|
116 | 120 | __del__ = cleanup |
|
117 | 121 | |
|
118 | 122 | def _callstream(self, cmd, **args): |
|
119 | 123 | self.ui.debug("sending %s command\n" % cmd) |
|
120 | 124 | self.pipeo.write("%s\n" % cmd) |
|
121 | 125 | _func, names = wireproto.commands[cmd] |
|
122 | 126 | keys = names.split() |
|
123 | 127 | wireargs = {} |
|
124 | 128 | for k in keys: |
|
125 | 129 | if k == '*': |
|
126 | 130 | wireargs['*'] = args |
|
127 | 131 | break |
|
128 | 132 | else: |
|
129 | 133 | wireargs[k] = args[k] |
|
130 | 134 | del args[k] |
|
131 | 135 | for k, v in sorted(wireargs.iteritems()): |
|
132 | 136 | self.pipeo.write("%s %d\n" % (k, len(v))) |
|
133 | 137 | if isinstance(v, dict): |
|
134 | 138 | for dk, dv in v.iteritems(): |
|
135 | 139 | self.pipeo.write("%s %d\n" % (dk, len(dv))) |
|
136 | 140 | self.pipeo.write(dv) |
|
137 | 141 | else: |
|
138 | 142 | self.pipeo.write(v) |
|
139 | 143 | self.pipeo.flush() |
|
140 | 144 | |
|
141 | 145 | return self.pipei |
|
142 | 146 | |
|
143 | 147 | def _call(self, cmd, **args): |
|
144 | 148 | self._callstream(cmd, **args) |
|
145 | 149 | return self._recv() |
|
146 | 150 | |
|
147 | 151 | def _callpush(self, cmd, fp, **args): |
|
148 | 152 | r = self._call(cmd, **args) |
|
149 | 153 | if r: |
|
150 | 154 | return '', r |
|
151 | 155 | while True: |
|
152 | 156 | d = fp.read(4096) |
|
153 | 157 | if not d: |
|
154 | 158 | break |
|
155 | 159 | self._send(d) |
|
156 | 160 | self._send("", flush=True) |
|
157 | 161 | r = self._recv() |
|
158 | 162 | if r: |
|
159 | 163 | return '', r |
|
160 | 164 | return self._recv(), '' |
|
161 | 165 | |
|
162 | 166 | def _decompress(self, stream): |
|
163 | 167 | return stream |
|
164 | 168 | |
|
165 | 169 | def _recv(self): |
|
166 | 170 | l = self.pipei.readline() |
|
167 | 171 | if l == '\n': |
|
168 | 172 | err = [] |
|
169 | 173 | while True: |
|
170 | 174 | line = self.pipee.readline() |
|
171 | 175 | if line == '-\n': |
|
172 | 176 | break |
|
173 | 177 | err.extend([line]) |
|
174 | 178 | if len(err) > 0: |
|
175 | 179 | # strip the trailing newline added to the last line server-side |
|
176 | 180 | err[-1] = err[-1][:-1] |
|
177 | 181 | self._abort(error.OutOfBandError(*err)) |
|
178 | 182 | self.readerr() |
|
179 | 183 | try: |
|
180 | 184 | l = int(l) |
|
181 | 185 | except ValueError: |
|
182 | 186 | self._abort(error.ResponseError(_("unexpected response:"), l)) |
|
183 | 187 | return self.pipei.read(l) |
|
184 | 188 | |
|
185 | 189 | def _send(self, data, flush=False): |
|
186 | 190 | self.pipeo.write("%d\n" % len(data)) |
|
187 | 191 | if data: |
|
188 | 192 | self.pipeo.write(data) |
|
189 | 193 | if flush: |
|
190 | 194 | self.pipeo.flush() |
|
191 | 195 | self.readerr() |
|
192 | 196 | |
|
193 | 197 | def lock(self): |
|
194 | 198 | self._call("lock") |
|
195 | 199 | return remotelock(self) |
|
196 | 200 | |
|
197 | 201 | def unlock(self): |
|
198 | 202 | self._call("unlock") |
|
199 | 203 | |
|
200 | 204 | def addchangegroup(self, cg, source, url, lock=None): |
|
201 | 205 | '''Send a changegroup to the remote server. Return an integer |
|
202 | 206 | similar to unbundle(). DEPRECATED, since it requires locking the |
|
203 | 207 | remote.''' |
|
204 | 208 | d = self._call("addchangegroup") |
|
205 | 209 | if d: |
|
206 | 210 | self._abort(error.RepoError(_("push refused: %s") % d)) |
|
207 | 211 | while True: |
|
208 | 212 | d = cg.read(4096) |
|
209 | 213 | if not d: |
|
210 | 214 | break |
|
211 | 215 | self.pipeo.write(d) |
|
212 | 216 | self.readerr() |
|
213 | 217 | |
|
214 | 218 | self.pipeo.flush() |
|
215 | 219 | |
|
216 | 220 | self.readerr() |
|
217 | 221 | r = self._recv() |
|
218 | 222 | if not r: |
|
219 | 223 | return 1 |
|
220 | 224 | try: |
|
221 | 225 | return int(r) |
|
222 | 226 | except ValueError: |
|
223 | 227 | self._abort(error.ResponseError(_("unexpected response:"), r)) |
|
224 | 228 | |
|
225 | 229 | instance = sshrepository |
@@ -1,196 +1,196 b'' | |||
|
1 | 1 | $ "$TESTDIR/hghave" no-windows || exit 80 |
|
2 | 2 | |
|
3 | 3 | This test tries to exercise the ssh functionality with a dummy script |
|
4 | 4 | |
|
5 | 5 | $ checknewrepo() |
|
6 | 6 | > { |
|
7 | 7 | > name=$1 |
|
8 | 8 | > if [ -d "$name"/.hg/store ]; then |
|
9 | 9 | > echo store created |
|
10 | 10 | > fi |
|
11 | 11 | > if [ -f "$name"/.hg/00changelog.i ]; then |
|
12 | 12 | > echo 00changelog.i created |
|
13 | 13 | > fi |
|
14 | 14 | > cat "$name"/.hg/requires |
|
15 | 15 | > } |
|
16 | 16 | |
|
17 | 17 | creating 'local' |
|
18 | 18 | |
|
19 | 19 | $ hg init local |
|
20 | 20 | $ checknewrepo local |
|
21 | 21 | store created |
|
22 | 22 | 00changelog.i created |
|
23 | 23 | revlogv1 |
|
24 | 24 | fncache |
|
25 | 25 | store |
|
26 | 26 | dotencode |
|
27 | 27 | $ echo this > local/foo |
|
28 | 28 | $ hg ci --cwd local -A -m "init" |
|
29 | 29 | adding foo |
|
30 | 30 | |
|
31 | 31 | creating repo with format.usestore=false |
|
32 | 32 | |
|
33 | 33 | $ hg --config format.usestore=false init old |
|
34 | 34 | $ checknewrepo old |
|
35 | 35 | revlogv1 |
|
36 | 36 | |
|
37 | 37 | creating repo with format.usefncache=false |
|
38 | 38 | |
|
39 | 39 | $ hg --config format.usefncache=false init old2 |
|
40 | 40 | $ checknewrepo old2 |
|
41 | 41 | store created |
|
42 | 42 | 00changelog.i created |
|
43 | 43 | revlogv1 |
|
44 | 44 | store |
|
45 | 45 | |
|
46 | 46 | creating repo with format.dotencode=false |
|
47 | 47 | |
|
48 | 48 | $ hg --config format.dotencode=false init old3 |
|
49 | 49 | $ checknewrepo old3 |
|
50 | 50 | store created |
|
51 | 51 | 00changelog.i created |
|
52 | 52 | revlogv1 |
|
53 | 53 | fncache |
|
54 | 54 | store |
|
55 | 55 | |
|
56 | 56 | test failure |
|
57 | 57 | |
|
58 | 58 | $ hg init local |
|
59 | 59 | abort: repository local already exists! |
|
60 | 60 | [255] |
|
61 | 61 | |
|
62 | 62 | init+push to remote2 |
|
63 | 63 | |
|
64 | 64 | $ hg init -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote2 |
|
65 | 65 | $ hg incoming -R remote2 local |
|
66 | 66 | comparing with local |
|
67 | 67 | changeset: 0:08b9e9f63b32 |
|
68 | 68 | tag: tip |
|
69 | 69 | user: test |
|
70 | 70 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
71 | 71 | summary: init |
|
72 | 72 | |
|
73 | 73 | |
|
74 | 74 | $ hg push -R local -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote2 |
|
75 | 75 | pushing to ssh://user@dummy/remote2 |
|
76 | 76 | searching for changes |
|
77 | 77 | remote: adding changesets |
|
78 | 78 | remote: adding manifests |
|
79 | 79 | remote: adding file changes |
|
80 | 80 | remote: added 1 changesets with 1 changes to 1 files |
|
81 | 81 | |
|
82 | 82 | clone to remote1 |
|
83 | 83 | |
|
84 | 84 | $ hg clone -e "python $TESTDIR/dummyssh" local ssh://user@dummy/remote1 |
|
85 | 85 | searching for changes |
|
86 | 86 | remote: adding changesets |
|
87 | 87 | remote: adding manifests |
|
88 | 88 | remote: adding file changes |
|
89 | 89 | remote: added 1 changesets with 1 changes to 1 files |
|
90 | 90 | |
|
91 | 91 | init to existing repo |
|
92 | 92 | |
|
93 | 93 | $ hg init -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote1 |
|
94 | 94 | abort: repository remote1 already exists! |
|
95 | 95 | abort: could not create remote repo! |
|
96 | 96 | [255] |
|
97 | 97 | |
|
98 | 98 | clone to existing repo |
|
99 | 99 | |
|
100 | 100 | $ hg clone -e "python $TESTDIR/dummyssh" local ssh://user@dummy/remote1 |
|
101 | 101 | abort: repository remote1 already exists! |
|
102 | 102 | abort: could not create remote repo! |
|
103 | 103 | [255] |
|
104 | 104 | |
|
105 | 105 | output of dummyssh |
|
106 | 106 | |
|
107 | 107 | $ cat dummylog |
|
108 | Got arguments 1:user@dummy 2:hg init remote2 | |
|
109 | Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio | |
|
110 | Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio | |
|
111 | Got arguments 1:user@dummy 2:hg init remote1 | |
|
112 | Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio | |
|
113 | Got arguments 1:user@dummy 2:hg init remote1 | |
|
114 | Got arguments 1:user@dummy 2:hg init remote1 | |
|
108 | Got arguments 1:user@dummy 2:'hg' init 'remote2' | |
|
109 | Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio | |
|
110 | Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio | |
|
111 | Got arguments 1:user@dummy 2:'hg' init 'remote1' | |
|
112 | Got arguments 1:user@dummy 2:'hg' -R 'remote1' serve --stdio | |
|
113 | Got arguments 1:user@dummy 2:'hg' init 'remote1' | |
|
114 | Got arguments 1:user@dummy 2:'hg' init 'remote1' | |
|
115 | 115 | |
|
116 | 116 | comparing repositories |
|
117 | 117 | |
|
118 | 118 | $ hg tip -q -R local |
|
119 | 119 | 0:08b9e9f63b32 |
|
120 | 120 | $ hg tip -q -R remote1 |
|
121 | 121 | 0:08b9e9f63b32 |
|
122 | 122 | $ hg tip -q -R remote2 |
|
123 | 123 | 0:08b9e9f63b32 |
|
124 | 124 | |
|
125 | 125 | check names for repositories (clashes with URL schemes, special chars) |
|
126 | 126 | |
|
127 | 127 | $ for i in bundle file hg http https old-http ssh static-http " " "with space"; do |
|
128 | 128 | > printf "hg init \"$i\"... " |
|
129 | 129 | > hg init "$i" |
|
130 | 130 | > test -d "$i" -a -d "$i/.hg" && echo "ok" || echo "failed" |
|
131 | 131 | > done |
|
132 | 132 | hg init "bundle"... ok |
|
133 | 133 | hg init "file"... ok |
|
134 | 134 | hg init "hg"... ok |
|
135 | 135 | hg init "http"... ok |
|
136 | 136 | hg init "https"... ok |
|
137 | 137 | hg init "old-http"... ok |
|
138 | 138 | hg init "ssh"... ok |
|
139 | 139 | hg init "static-http"... ok |
|
140 | 140 | hg init " "... ok |
|
141 | 141 | hg init "with space"... ok |
|
142 | 142 | |
|
143 | 143 | creating 'local/sub/repo' |
|
144 | 144 | |
|
145 | 145 | $ hg init local/sub/repo |
|
146 | 146 | $ checknewrepo local/sub/repo |
|
147 | 147 | store created |
|
148 | 148 | 00changelog.i created |
|
149 | 149 | revlogv1 |
|
150 | 150 | fncache |
|
151 | 151 | store |
|
152 | 152 | dotencode |
|
153 | 153 | |
|
154 | 154 | prepare test of init of url configured from paths |
|
155 | 155 | |
|
156 | 156 | $ echo '[paths]' >> $HGRCPATH |
|
157 | 157 | $ echo "somewhere = `pwd`/url from paths" >> $HGRCPATH |
|
158 | 158 | $ echo "elsewhere = `pwd`/another paths url" >> $HGRCPATH |
|
159 | 159 | |
|
160 | 160 | init should (for consistency with clone) expand the url |
|
161 | 161 | |
|
162 | 162 | $ hg init somewhere |
|
163 | 163 | $ checknewrepo "url from paths" |
|
164 | 164 | store created |
|
165 | 165 | 00changelog.i created |
|
166 | 166 | revlogv1 |
|
167 | 167 | fncache |
|
168 | 168 | store |
|
169 | 169 | dotencode |
|
170 | 170 | |
|
171 | 171 | verify that clone also expand urls |
|
172 | 172 | |
|
173 | 173 | $ hg clone somewhere elsewhere |
|
174 | 174 | updating to branch default |
|
175 | 175 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
176 | 176 | $ checknewrepo "another paths url" |
|
177 | 177 | store created |
|
178 | 178 | 00changelog.i created |
|
179 | 179 | revlogv1 |
|
180 | 180 | fncache |
|
181 | 181 | store |
|
182 | 182 | dotencode |
|
183 | 183 | |
|
184 | 184 | clone bookmarks |
|
185 | 185 | |
|
186 | 186 | $ hg -R local bookmark test |
|
187 | 187 | $ hg -R local bookmarks |
|
188 | 188 | * test 0:08b9e9f63b32 |
|
189 | 189 | $ hg clone -e "python $TESTDIR/dummyssh" local ssh://user@dummy/remote-bookmarks |
|
190 | 190 | searching for changes |
|
191 | 191 | remote: adding changesets |
|
192 | 192 | remote: adding manifests |
|
193 | 193 | remote: adding file changes |
|
194 | 194 | remote: added 1 changesets with 1 changes to 1 files |
|
195 | 195 | $ hg -R remote-bookmarks bookmarks |
|
196 | 196 | test 0:08b9e9f63b32 |
@@ -1,290 +1,301 b'' | |||
|
1 | 1 | |
|
2 | 2 | |
|
3 | 3 | This test tries to exercise the ssh functionality with a dummy script |
|
4 | 4 | |
|
5 | 5 | creating 'remote' repo |
|
6 | 6 | |
|
7 | 7 | $ hg init remote |
|
8 | 8 | $ cd remote |
|
9 | 9 | $ echo this > foo |
|
10 | 10 | $ echo this > fooO |
|
11 | 11 | $ hg ci -A -m "init" foo fooO |
|
12 | 12 | $ cat <<EOF > .hg/hgrc |
|
13 | 13 | > [server] |
|
14 | 14 | > uncompressed = True |
|
15 | 15 | > |
|
16 | 16 | > [hooks] |
|
17 | 17 | > changegroup = python "$TESTDIR"/printenv.py changegroup-in-remote 0 ../dummylog |
|
18 | 18 | > EOF |
|
19 | 19 | $ cd .. |
|
20 | 20 | |
|
21 | 21 | repo not found error |
|
22 | 22 | |
|
23 | 23 | $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/nonexistent local |
|
24 | 24 | remote: abort: There is no Mercurial repository here (.hg not found)! |
|
25 | 25 | abort: no suitable response from remote hg! |
|
26 | 26 | [255] |
|
27 | 27 | |
|
28 | 28 | non-existent absolute path |
|
29 | 29 | |
|
30 | 30 | $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy//`pwd`/nonexistent local |
|
31 | 31 | remote: abort: There is no Mercurial repository here (.hg not found)! |
|
32 | 32 | abort: no suitable response from remote hg! |
|
33 | 33 | [255] |
|
34 | 34 | |
|
35 | 35 | clone remote via stream |
|
36 | 36 | |
|
37 | 37 | $ hg clone -e "python $TESTDIR/dummyssh" --uncompressed ssh://user@dummy/remote local-stream |
|
38 | 38 | streaming all changes |
|
39 | 39 | 4 files to transfer, 392 bytes of data |
|
40 | 40 | transferred 392 bytes in * seconds (*/sec) (glob) |
|
41 | 41 | updating to branch default |
|
42 | 42 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
43 | 43 | $ cd local-stream |
|
44 | 44 | $ hg verify |
|
45 | 45 | checking changesets |
|
46 | 46 | checking manifests |
|
47 | 47 | crosschecking files in changesets and manifests |
|
48 | 48 | checking files |
|
49 | 49 | 2 files, 1 changesets, 2 total revisions |
|
50 | 50 | $ cd .. |
|
51 | 51 | |
|
52 | 52 | clone remote via pull |
|
53 | 53 | |
|
54 | 54 | $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote local |
|
55 | 55 | requesting all changes |
|
56 | 56 | adding changesets |
|
57 | 57 | adding manifests |
|
58 | 58 | adding file changes |
|
59 | 59 | added 1 changesets with 2 changes to 2 files |
|
60 | 60 | updating to branch default |
|
61 | 61 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
62 | 62 | |
|
63 | 63 | verify |
|
64 | 64 | |
|
65 | 65 | $ cd local |
|
66 | 66 | $ hg verify |
|
67 | 67 | checking changesets |
|
68 | 68 | checking manifests |
|
69 | 69 | crosschecking files in changesets and manifests |
|
70 | 70 | checking files |
|
71 | 71 | 2 files, 1 changesets, 2 total revisions |
|
72 | 72 | $ echo '[hooks]' >> .hg/hgrc |
|
73 | 73 | $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc |
|
74 | 74 | |
|
75 | 75 | empty default pull |
|
76 | 76 | |
|
77 | 77 | $ hg paths |
|
78 | 78 | default = ssh://user@dummy/remote |
|
79 | 79 | $ hg pull -e "python $TESTDIR/dummyssh" |
|
80 | 80 | pulling from ssh://user@dummy/remote |
|
81 | 81 | searching for changes |
|
82 | 82 | no changes found |
|
83 | 83 | |
|
84 | 84 | local change |
|
85 | 85 | |
|
86 | 86 | $ echo bleah > foo |
|
87 | 87 | $ hg ci -m "add" |
|
88 | 88 | |
|
89 | 89 | updating rc |
|
90 | 90 | |
|
91 | 91 | $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc |
|
92 | 92 | $ echo "[ui]" >> .hg/hgrc |
|
93 | 93 | $ echo "ssh = python $TESTDIR/dummyssh" >> .hg/hgrc |
|
94 | 94 | |
|
95 | 95 | find outgoing |
|
96 | 96 | |
|
97 | 97 | $ hg out ssh://user@dummy/remote |
|
98 | 98 | comparing with ssh://user@dummy/remote |
|
99 | 99 | searching for changes |
|
100 | 100 | changeset: 1:a28a9d1a809c |
|
101 | 101 | tag: tip |
|
102 | 102 | user: test |
|
103 | 103 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
104 | 104 | summary: add |
|
105 | 105 | |
|
106 | 106 | |
|
107 | 107 | find incoming on the remote side |
|
108 | 108 | |
|
109 | 109 | $ hg incoming -R ../remote -e "python $TESTDIR/dummyssh" ssh://user@dummy/local |
|
110 | 110 | comparing with ssh://user@dummy/local |
|
111 | 111 | searching for changes |
|
112 | 112 | changeset: 1:a28a9d1a809c |
|
113 | 113 | tag: tip |
|
114 | 114 | user: test |
|
115 | 115 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
116 | 116 | summary: add |
|
117 | 117 | |
|
118 | 118 | |
|
119 | 119 | find incoming on the remote side (using absolute path) |
|
120 | 120 | |
|
121 | 121 | $ hg incoming -R ../remote -e "python $TESTDIR/dummyssh" "ssh://user@dummy/`pwd`" |
|
122 | 122 | comparing with ssh://user@dummy/$TESTTMP/local |
|
123 | 123 | searching for changes |
|
124 | 124 | changeset: 1:a28a9d1a809c |
|
125 | 125 | tag: tip |
|
126 | 126 | user: test |
|
127 | 127 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
128 | 128 | summary: add |
|
129 | 129 | |
|
130 | 130 | |
|
131 | 131 | push |
|
132 | 132 | |
|
133 | 133 | $ hg push |
|
134 | 134 | pushing to ssh://user@dummy/remote |
|
135 | 135 | searching for changes |
|
136 | 136 | remote: adding changesets |
|
137 | 137 | remote: adding manifests |
|
138 | 138 | remote: adding file changes |
|
139 | 139 | remote: added 1 changesets with 1 changes to 1 files |
|
140 | 140 | $ cd ../remote |
|
141 | 141 | |
|
142 | 142 | check remote tip |
|
143 | 143 | |
|
144 | 144 | $ hg tip |
|
145 | 145 | changeset: 1:a28a9d1a809c |
|
146 | 146 | tag: tip |
|
147 | 147 | user: test |
|
148 | 148 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
149 | 149 | summary: add |
|
150 | 150 | |
|
151 | 151 | $ hg verify |
|
152 | 152 | checking changesets |
|
153 | 153 | checking manifests |
|
154 | 154 | crosschecking files in changesets and manifests |
|
155 | 155 | checking files |
|
156 | 156 | 2 files, 2 changesets, 3 total revisions |
|
157 | 157 | $ hg cat -r tip foo |
|
158 | 158 | bleah |
|
159 | 159 | $ echo z > z |
|
160 | 160 | $ hg ci -A -m z z |
|
161 | 161 | created new head |
|
162 | 162 | |
|
163 | 163 | test pushkeys and bookmarks |
|
164 | 164 | |
|
165 | 165 | $ cd ../local |
|
166 | 166 | $ hg debugpushkey --config ui.ssh="python $TESTDIR/dummyssh" ssh://user@dummy/remote namespaces |
|
167 | 167 | bookmarks |
|
168 | 168 | namespaces |
|
169 | 169 | $ hg book foo -r 0 |
|
170 | 170 | $ hg out -B |
|
171 | 171 | comparing with ssh://user@dummy/remote |
|
172 | 172 | searching for changed bookmarks |
|
173 | 173 | foo 1160648e36ce |
|
174 | 174 | $ hg push -B foo |
|
175 | 175 | pushing to ssh://user@dummy/remote |
|
176 | 176 | searching for changes |
|
177 | 177 | no changes found |
|
178 | 178 | exporting bookmark foo |
|
179 | 179 | $ hg debugpushkey --config ui.ssh="python $TESTDIR/dummyssh" ssh://user@dummy/remote bookmarks |
|
180 | 180 | foo 1160648e36cec0054048a7edc4110c6f84fde594 |
|
181 | 181 | $ hg book -f foo |
|
182 | 182 | $ hg push --traceback |
|
183 | 183 | pushing to ssh://user@dummy/remote |
|
184 | 184 | searching for changes |
|
185 | 185 | no changes found |
|
186 | 186 | updating bookmark foo |
|
187 | 187 | $ hg book -d foo |
|
188 | 188 | $ hg in -B |
|
189 | 189 | comparing with ssh://user@dummy/remote |
|
190 | 190 | searching for changed bookmarks |
|
191 | 191 | foo a28a9d1a809c |
|
192 | 192 | $ hg book -f -r 0 foo |
|
193 | 193 | $ hg pull -B foo |
|
194 | 194 | pulling from ssh://user@dummy/remote |
|
195 | 195 | no changes found |
|
196 | 196 | updating bookmark foo |
|
197 | 197 | importing bookmark foo |
|
198 | 198 | $ hg book -d foo |
|
199 | 199 | $ hg push -B foo |
|
200 | 200 | pushing to ssh://user@dummy/remote |
|
201 | 201 | searching for changes |
|
202 | 202 | no changes found |
|
203 | 203 | deleting remote bookmark foo |
|
204 | 204 | |
|
205 | 205 | a bad, evil hook that prints to stdout |
|
206 | 206 | |
|
207 | 207 | $ cat <<EOF > $TESTTMP/badhook |
|
208 | 208 | > import sys |
|
209 | 209 | > sys.stdout.write("KABOOM\n") |
|
210 | 210 | > EOF |
|
211 | 211 | |
|
212 | 212 | $ echo '[hooks]' >> ../remote/.hg/hgrc |
|
213 | 213 | $ echo "changegroup.stdout = python $TESTTMP/badhook" >> ../remote/.hg/hgrc |
|
214 | 214 | $ echo r > r |
|
215 | 215 | $ hg ci -A -m z r |
|
216 | 216 | |
|
217 | 217 | push should succeed even though it has an unexpected response |
|
218 | 218 | |
|
219 | 219 | $ hg push |
|
220 | 220 | pushing to ssh://user@dummy/remote |
|
221 | 221 | searching for changes |
|
222 | 222 | note: unsynced remote changes! |
|
223 | 223 | remote: adding changesets |
|
224 | 224 | remote: adding manifests |
|
225 | 225 | remote: adding file changes |
|
226 | 226 | remote: added 1 changesets with 1 changes to 1 files |
|
227 | 227 | remote: KABOOM |
|
228 | 228 | $ hg -R ../remote heads |
|
229 | 229 | changeset: 3:1383141674ec |
|
230 | 230 | tag: tip |
|
231 | 231 | parent: 1:a28a9d1a809c |
|
232 | 232 | user: test |
|
233 | 233 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
234 | 234 | summary: z |
|
235 | 235 | |
|
236 | 236 | changeset: 2:6c0482d977a3 |
|
237 | 237 | parent: 0:1160648e36ce |
|
238 | 238 | user: test |
|
239 | 239 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
240 | 240 | summary: z |
|
241 | 241 | |
|
242 | 242 | |
|
243 | 243 | clone bookmarks |
|
244 | 244 | |
|
245 | 245 | $ hg -R ../remote bookmark test |
|
246 | 246 | $ hg -R ../remote bookmarks |
|
247 | 247 | * test 2:6c0482d977a3 |
|
248 | 248 | $ hg clone -e "python $TESTDIR/dummyssh" ssh://user@dummy/remote local-bookmarks |
|
249 | 249 | requesting all changes |
|
250 | 250 | adding changesets |
|
251 | 251 | adding manifests |
|
252 | 252 | adding file changes |
|
253 | 253 | added 4 changesets with 5 changes to 4 files (+1 heads) |
|
254 | 254 | updating to branch default |
|
255 | 255 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
256 | 256 | $ hg -R local-bookmarks bookmarks |
|
257 | 257 | test 2:6c0482d977a3 |
|
258 | 258 | |
|
259 | 259 | passwords in ssh urls are not supported |
|
260 | 260 | (we use a glob here because different Python versions give different |
|
261 | 261 | results here) |
|
262 | 262 | |
|
263 | 263 | $ hg push ssh://user:erroneouspwd@dummy/remote |
|
264 | 264 | pushing to ssh://user:*@dummy/remote (glob) |
|
265 | 265 | abort: password in URL not supported! |
|
266 | 266 | [255] |
|
267 | 267 | |
|
268 | 268 | $ cd .. |
|
269 | ||
|
270 | Test remote paths with spaces (issue2983): | |
|
271 | ||
|
272 | $ hg init --ssh "python $TESTDIR/dummyssh" "ssh://user@dummy/a repo" | |
|
273 | $ hg -R 'a repo' tag tag | |
|
274 | $ hg id --ssh "python $TESTDIR/dummyssh" "ssh://user@dummy/a repo" | |
|
275 | 3fb238f49e8c | |
|
276 | ||
|
269 | 277 | $ cat dummylog |
|
270 | Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio | |
|
271 | Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio | |
|
272 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
273 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
274 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
275 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
276 | Got arguments 1:user@dummy 2:hg -R local serve --stdio | |
|
277 | Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio | |
|
278 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
278 | Got arguments 1:user@dummy 2:'hg' -R 'nonexistent' serve --stdio | |
|
279 | Got arguments 1:user@dummy 2:'hg' -R '/$TESTTMP/nonexistent' serve --stdio | |
|
280 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
281 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
282 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
283 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
284 | Got arguments 1:user@dummy 2:'hg' -R 'local' serve --stdio | |
|
285 | Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/local' serve --stdio | |
|
286 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
279 | 287 | changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 |
|
280 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
281 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
282 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
283 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
284 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
285 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
286 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
287 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
288 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
288 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
289 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
290 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
291 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
292 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
293 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
294 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
295 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
296 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
289 | 297 | changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 |
|
290 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio | |
|
298 | Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio | |
|
299 | Got arguments 1:user@dummy 2:'hg' init 'a repo' | |
|
300 | Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio | |
|
301 | Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio |
@@ -1,105 +1,105 b'' | |||
|
1 | 1 | $ "$TESTDIR/hghave" serve || exit 80 |
|
2 | 2 | |
|
3 | 3 | Preparing the subrepository 'sub' |
|
4 | 4 | |
|
5 | 5 | $ hg init sub |
|
6 | 6 | $ echo sub > sub/sub |
|
7 | 7 | $ hg add -R sub |
|
8 | 8 | adding sub/sub (glob) |
|
9 | 9 | $ hg commit -R sub -m "sub import" |
|
10 | 10 | |
|
11 | 11 | Preparing the 'main' repo which depends on the subrepo 'sub' |
|
12 | 12 | |
|
13 | 13 | $ hg init main |
|
14 | 14 | $ echo main > main/main |
|
15 | 15 | $ echo "sub = ../sub" > main/.hgsub |
|
16 | 16 | $ hg clone sub main/sub |
|
17 | 17 | updating to branch default |
|
18 | 18 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
19 | 19 | $ hg add -R main |
|
20 | 20 | adding main/.hgsub (glob) |
|
21 | 21 | adding main/main (glob) |
|
22 | 22 | $ hg commit -R main -m "main import" |
|
23 | 23 | committing subrepository sub |
|
24 | 24 | |
|
25 | 25 | Cleaning both repositories, just as a clone -U |
|
26 | 26 | |
|
27 | 27 | $ hg up -C -R sub null |
|
28 | 28 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
29 | 29 | $ hg up -C -R main null |
|
30 | 30 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
31 | 31 | $ rm -rf main/sub |
|
32 | 32 | |
|
33 | 33 | Serving them both using hgweb |
|
34 | 34 | |
|
35 | 35 | $ printf '[paths]\n/main = main\nsub = sub\n' > webdir.conf |
|
36 | 36 | $ hg serve --webdir-conf webdir.conf -a localhost -p $HGPORT \ |
|
37 | 37 | > -A /dev/null -E /dev/null --pid-file hg.pid -d |
|
38 | 38 | $ cat hg.pid >> $DAEMON_PIDS |
|
39 | 39 | |
|
40 | 40 | Clone main from hgweb |
|
41 | 41 | |
|
42 | 42 | $ hg clone "http://localhost:$HGPORT/main" cloned |
|
43 | 43 | requesting all changes |
|
44 | 44 | adding changesets |
|
45 | 45 | adding manifests |
|
46 | 46 | adding file changes |
|
47 | 47 | added 1 changesets with 3 changes to 3 files |
|
48 | 48 | updating to branch default |
|
49 | 49 | cloning subrepo sub from http://localhost:$HGPORT/sub |
|
50 | 50 | requesting all changes |
|
51 | 51 | adding changesets |
|
52 | 52 | adding manifests |
|
53 | 53 | adding file changes |
|
54 | 54 | added 1 changesets with 1 changes to 1 files |
|
55 | 55 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
56 | 56 | |
|
57 | 57 | Checking cloned repo ids |
|
58 | 58 | |
|
59 | 59 | $ hg id -R cloned |
|
60 | 60 | fdfeeb3e979e tip |
|
61 | 61 | $ hg id -R cloned/sub |
|
62 | 62 | 863c1745b441 tip |
|
63 | 63 | |
|
64 | 64 | subrepo debug for 'main' clone |
|
65 | 65 | |
|
66 | 66 | $ hg debugsub -R cloned |
|
67 | 67 | path sub |
|
68 | 68 | source ../sub |
|
69 | 69 | revision 863c1745b441bd97a8c4a096e87793073f4fb215 |
|
70 | 70 | |
|
71 | 71 | $ "$TESTDIR/killdaemons.py" |
|
72 | 72 | |
|
73 | 73 | subrepo paths with ssh urls |
|
74 | 74 | |
|
75 | 75 | $ cp $TESTDIR/dummyssh $BINDIR/ssh |
|
76 | 76 | |
|
77 | 77 | $ hg clone ssh://user@dummy/cloned sshclone |
|
78 | 78 | requesting all changes |
|
79 | 79 | adding changesets |
|
80 | 80 | adding manifests |
|
81 | 81 | adding file changes |
|
82 | 82 | added 1 changesets with 3 changes to 3 files |
|
83 | 83 | updating to branch default |
|
84 | 84 | cloning subrepo sub from ssh://user@dummy/sub |
|
85 | 85 | requesting all changes |
|
86 | 86 | adding changesets |
|
87 | 87 | adding manifests |
|
88 | 88 | adding file changes |
|
89 | 89 | added 1 changesets with 1 changes to 1 files |
|
90 | 90 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
91 | 91 | |
|
92 | 92 | $ hg -R sshclone push ssh://user@dummy/$TESTTMP/cloned |
|
93 | 93 | pushing to ssh://user@dummy/$TESTTMP/cloned |
|
94 | 94 | pushing subrepo sub to ssh://user@dummy/$TESTTMP/sub |
|
95 | 95 | searching for changes |
|
96 | 96 | no changes found |
|
97 | 97 | searching for changes |
|
98 | 98 | no changes found |
|
99 | 99 | |
|
100 | 100 | $ cat dummylog |
|
101 | Got arguments 1:user@dummy 2:hg -R cloned serve --stdio | |
|
102 | Got arguments 1:user@dummy 2:hg -R sub serve --stdio | |
|
103 | Got arguments 1:user@dummy 2:hg -R $TESTTMP/cloned serve --stdio | |
|
104 | Got arguments 1:user@dummy 2:hg -R $TESTTMP/sub serve --stdio | |
|
101 | Got arguments 1:user@dummy 2:'hg' -R 'cloned' serve --stdio | |
|
102 | Got arguments 1:user@dummy 2:'hg' -R 'sub' serve --stdio | |
|
103 | Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/cloned' serve --stdio | |
|
104 | Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/sub' serve --stdio | |
|
105 | 105 | $ rm $BINDIR/ssh |
General Comments 0
You need to be logged in to leave comments.
Login now