Show More
@@ -1,5476 +1,5491 b'' | |||
|
1 | 1 | # commands.py - command processing for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 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 __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import difflib |
|
11 | 11 | import errno |
|
12 | 12 | import os |
|
13 | 13 | import re |
|
14 | 14 | import sys |
|
15 | 15 | |
|
16 | 16 | from .i18n import _ |
|
17 | 17 | from .node import ( |
|
18 | 18 | hex, |
|
19 | 19 | nullid, |
|
20 | 20 | nullrev, |
|
21 | 21 | short, |
|
22 | 22 | ) |
|
23 | 23 | from . import ( |
|
24 | 24 | archival, |
|
25 | 25 | bookmarks, |
|
26 | 26 | bundle2, |
|
27 | 27 | changegroup, |
|
28 | 28 | cmdutil, |
|
29 | 29 | copies, |
|
30 | 30 | debugcommands as debugcommandsmod, |
|
31 | 31 | destutil, |
|
32 | 32 | dirstateguard, |
|
33 | 33 | discovery, |
|
34 | 34 | encoding, |
|
35 | 35 | error, |
|
36 | 36 | exchange, |
|
37 | 37 | extensions, |
|
38 | 38 | formatter, |
|
39 | 39 | graphmod, |
|
40 | 40 | hbisect, |
|
41 | 41 | help, |
|
42 | 42 | hg, |
|
43 | 43 | lock as lockmod, |
|
44 | 44 | merge as mergemod, |
|
45 | 45 | obsolete, |
|
46 | 46 | patch, |
|
47 | 47 | phases, |
|
48 | 48 | pycompat, |
|
49 | 49 | rcutil, |
|
50 | 50 | registrar, |
|
51 | 51 | revsetlang, |
|
52 | 52 | scmutil, |
|
53 | 53 | server, |
|
54 | 54 | sshserver, |
|
55 | 55 | streamclone, |
|
56 | 56 | tags as tagsmod, |
|
57 | 57 | templatekw, |
|
58 | 58 | ui as uimod, |
|
59 | 59 | util, |
|
60 | 60 | ) |
|
61 | 61 | |
|
62 | 62 | release = lockmod.release |
|
63 | 63 | |
|
64 | 64 | table = {} |
|
65 | 65 | table.update(debugcommandsmod.command._table) |
|
66 | 66 | |
|
67 | 67 | command = registrar.command(table) |
|
68 | 68 | |
|
69 | 69 | # common command options |
|
70 | 70 | |
|
71 | 71 | globalopts = [ |
|
72 | 72 | ('R', 'repository', '', |
|
73 | 73 | _('repository root directory or name of overlay bundle file'), |
|
74 | 74 | _('REPO')), |
|
75 | 75 | ('', 'cwd', '', |
|
76 | 76 | _('change working directory'), _('DIR')), |
|
77 | 77 | ('y', 'noninteractive', None, |
|
78 | 78 | _('do not prompt, automatically pick the first choice for all prompts')), |
|
79 | 79 | ('q', 'quiet', None, _('suppress output')), |
|
80 | 80 | ('v', 'verbose', None, _('enable additional output')), |
|
81 | 81 | ('', 'color', '', |
|
82 | 82 | # i18n: 'always', 'auto', 'never', and 'debug' are keywords |
|
83 | 83 | # and should not be translated |
|
84 | 84 | _("when to colorize (boolean, always, auto, never, or debug)"), |
|
85 | 85 | _('TYPE')), |
|
86 | 86 | ('', 'config', [], |
|
87 | 87 | _('set/override config option (use \'section.name=value\')'), |
|
88 | 88 | _('CONFIG')), |
|
89 | 89 | ('', 'debug', None, _('enable debugging output')), |
|
90 | 90 | ('', 'debugger', None, _('start debugger')), |
|
91 | 91 | ('', 'encoding', encoding.encoding, _('set the charset encoding'), |
|
92 | 92 | _('ENCODE')), |
|
93 | 93 | ('', 'encodingmode', encoding.encodingmode, |
|
94 | 94 | _('set the charset encoding mode'), _('MODE')), |
|
95 | 95 | ('', 'traceback', None, _('always print a traceback on exception')), |
|
96 | 96 | ('', 'time', None, _('time how long the command takes')), |
|
97 | 97 | ('', 'profile', None, _('print command execution profile')), |
|
98 | 98 | ('', 'version', None, _('output version information and exit')), |
|
99 | 99 | ('h', 'help', None, _('display help and exit')), |
|
100 | 100 | ('', 'hidden', False, _('consider hidden changesets')), |
|
101 | 101 | ('', 'pager', 'auto', |
|
102 | 102 | _("when to paginate (boolean, always, auto, or never)"), _('TYPE')), |
|
103 | 103 | ] |
|
104 | 104 | |
|
105 | 105 | dryrunopts = cmdutil.dryrunopts |
|
106 | 106 | remoteopts = cmdutil.remoteopts |
|
107 | 107 | walkopts = cmdutil.walkopts |
|
108 | 108 | commitopts = cmdutil.commitopts |
|
109 | 109 | commitopts2 = cmdutil.commitopts2 |
|
110 | 110 | formatteropts = cmdutil.formatteropts |
|
111 | 111 | templateopts = cmdutil.templateopts |
|
112 | 112 | logopts = cmdutil.logopts |
|
113 | 113 | diffopts = cmdutil.diffopts |
|
114 | 114 | diffwsopts = cmdutil.diffwsopts |
|
115 | 115 | diffopts2 = cmdutil.diffopts2 |
|
116 | 116 | mergetoolopts = cmdutil.mergetoolopts |
|
117 | 117 | similarityopts = cmdutil.similarityopts |
|
118 | 118 | subrepoopts = cmdutil.subrepoopts |
|
119 | 119 | debugrevlogopts = cmdutil.debugrevlogopts |
|
120 | 120 | |
|
121 | 121 | # Commands start here, listed alphabetically |
|
122 | 122 | |
|
123 | 123 | @command('^add', |
|
124 | 124 | walkopts + subrepoopts + dryrunopts, |
|
125 | 125 | _('[OPTION]... [FILE]...'), |
|
126 | 126 | inferrepo=True) |
|
127 | 127 | def add(ui, repo, *pats, **opts): |
|
128 | 128 | """add the specified files on the next commit |
|
129 | 129 | |
|
130 | 130 | Schedule files to be version controlled and added to the |
|
131 | 131 | repository. |
|
132 | 132 | |
|
133 | 133 | The files will be added to the repository at the next commit. To |
|
134 | 134 | undo an add before that, see :hg:`forget`. |
|
135 | 135 | |
|
136 | 136 | If no names are given, add all files to the repository (except |
|
137 | 137 | files matching ``.hgignore``). |
|
138 | 138 | |
|
139 | 139 | .. container:: verbose |
|
140 | 140 | |
|
141 | 141 | Examples: |
|
142 | 142 | |
|
143 | 143 | - New (unknown) files are added |
|
144 | 144 | automatically by :hg:`add`:: |
|
145 | 145 | |
|
146 | 146 | $ ls |
|
147 | 147 | foo.c |
|
148 | 148 | $ hg status |
|
149 | 149 | ? foo.c |
|
150 | 150 | $ hg add |
|
151 | 151 | adding foo.c |
|
152 | 152 | $ hg status |
|
153 | 153 | A foo.c |
|
154 | 154 | |
|
155 | 155 | - Specific files to be added can be specified:: |
|
156 | 156 | |
|
157 | 157 | $ ls |
|
158 | 158 | bar.c foo.c |
|
159 | 159 | $ hg status |
|
160 | 160 | ? bar.c |
|
161 | 161 | ? foo.c |
|
162 | 162 | $ hg add bar.c |
|
163 | 163 | $ hg status |
|
164 | 164 | A bar.c |
|
165 | 165 | ? foo.c |
|
166 | 166 | |
|
167 | 167 | Returns 0 if all files are successfully added. |
|
168 | 168 | """ |
|
169 | 169 | |
|
170 | 170 | m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts)) |
|
171 | 171 | rejected = cmdutil.add(ui, repo, m, "", False, **opts) |
|
172 | 172 | return rejected and 1 or 0 |
|
173 | 173 | |
|
174 | 174 | @command('addremove', |
|
175 | 175 | similarityopts + subrepoopts + walkopts + dryrunopts, |
|
176 | 176 | _('[OPTION]... [FILE]...'), |
|
177 | 177 | inferrepo=True) |
|
178 | 178 | def addremove(ui, repo, *pats, **opts): |
|
179 | 179 | """add all new files, delete all missing files |
|
180 | 180 | |
|
181 | 181 | Add all new files and remove all missing files from the |
|
182 | 182 | repository. |
|
183 | 183 | |
|
184 | 184 | Unless names are given, new files are ignored if they match any of |
|
185 | 185 | the patterns in ``.hgignore``. As with add, these changes take |
|
186 | 186 | effect at the next commit. |
|
187 | 187 | |
|
188 | 188 | Use the -s/--similarity option to detect renamed files. This |
|
189 | 189 | option takes a percentage between 0 (disabled) and 100 (files must |
|
190 | 190 | be identical) as its parameter. With a parameter greater than 0, |
|
191 | 191 | this compares every removed file with every added file and records |
|
192 | 192 | those similar enough as renames. Detecting renamed files this way |
|
193 | 193 | can be expensive. After using this option, :hg:`status -C` can be |
|
194 | 194 | used to check which files were identified as moved or renamed. If |
|
195 | 195 | not specified, -s/--similarity defaults to 100 and only renames of |
|
196 | 196 | identical files are detected. |
|
197 | 197 | |
|
198 | 198 | .. container:: verbose |
|
199 | 199 | |
|
200 | 200 | Examples: |
|
201 | 201 | |
|
202 | 202 | - A number of files (bar.c and foo.c) are new, |
|
203 | 203 | while foobar.c has been removed (without using :hg:`remove`) |
|
204 | 204 | from the repository:: |
|
205 | 205 | |
|
206 | 206 | $ ls |
|
207 | 207 | bar.c foo.c |
|
208 | 208 | $ hg status |
|
209 | 209 | ! foobar.c |
|
210 | 210 | ? bar.c |
|
211 | 211 | ? foo.c |
|
212 | 212 | $ hg addremove |
|
213 | 213 | adding bar.c |
|
214 | 214 | adding foo.c |
|
215 | 215 | removing foobar.c |
|
216 | 216 | $ hg status |
|
217 | 217 | A bar.c |
|
218 | 218 | A foo.c |
|
219 | 219 | R foobar.c |
|
220 | 220 | |
|
221 | 221 | - A file foobar.c was moved to foo.c without using :hg:`rename`. |
|
222 | 222 | Afterwards, it was edited slightly:: |
|
223 | 223 | |
|
224 | 224 | $ ls |
|
225 | 225 | foo.c |
|
226 | 226 | $ hg status |
|
227 | 227 | ! foobar.c |
|
228 | 228 | ? foo.c |
|
229 | 229 | $ hg addremove --similarity 90 |
|
230 | 230 | removing foobar.c |
|
231 | 231 | adding foo.c |
|
232 | 232 | recording removal of foobar.c as rename to foo.c (94% similar) |
|
233 | 233 | $ hg status -C |
|
234 | 234 | A foo.c |
|
235 | 235 | foobar.c |
|
236 | 236 | R foobar.c |
|
237 | 237 | |
|
238 | 238 | Returns 0 if all files are successfully added. |
|
239 | 239 | """ |
|
240 | 240 | opts = pycompat.byteskwargs(opts) |
|
241 | 241 | try: |
|
242 | 242 | sim = float(opts.get('similarity') or 100) |
|
243 | 243 | except ValueError: |
|
244 | 244 | raise error.Abort(_('similarity must be a number')) |
|
245 | 245 | if sim < 0 or sim > 100: |
|
246 | 246 | raise error.Abort(_('similarity must be between 0 and 100')) |
|
247 | 247 | matcher = scmutil.match(repo[None], pats, opts) |
|
248 | 248 | return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0) |
|
249 | 249 | |
|
250 | 250 | @command('^annotate|blame', |
|
251 | 251 | [('r', 'rev', '', _('annotate the specified revision'), _('REV')), |
|
252 | 252 | ('', 'follow', None, |
|
253 | 253 | _('follow copies/renames and list the filename (DEPRECATED)')), |
|
254 | 254 | ('', 'no-follow', None, _("don't follow copies and renames")), |
|
255 | 255 | ('a', 'text', None, _('treat all files as text')), |
|
256 | 256 | ('u', 'user', None, _('list the author (long with -v)')), |
|
257 | 257 | ('f', 'file', None, _('list the filename')), |
|
258 | 258 | ('d', 'date', None, _('list the date (short with -q)')), |
|
259 | 259 | ('n', 'number', None, _('list the revision number (default)')), |
|
260 | 260 | ('c', 'changeset', None, _('list the changeset')), |
|
261 | 261 | ('l', 'line-number', None, _('show line number at the first appearance')), |
|
262 | 262 | ('', 'skip', [], _('revision to not display (EXPERIMENTAL)'), _('REV')), |
|
263 | 263 | ] + diffwsopts + walkopts + formatteropts, |
|
264 | 264 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'), |
|
265 | 265 | inferrepo=True) |
|
266 | 266 | def annotate(ui, repo, *pats, **opts): |
|
267 | 267 | """show changeset information by line for each file |
|
268 | 268 | |
|
269 | 269 | List changes in files, showing the revision id responsible for |
|
270 | 270 | each line. |
|
271 | 271 | |
|
272 | 272 | This command is useful for discovering when a change was made and |
|
273 | 273 | by whom. |
|
274 | 274 | |
|
275 | 275 | If you include --file, --user, or --date, the revision number is |
|
276 | 276 | suppressed unless you also include --number. |
|
277 | 277 | |
|
278 | 278 | Without the -a/--text option, annotate will avoid processing files |
|
279 | 279 | it detects as binary. With -a, annotate will annotate the file |
|
280 | 280 | anyway, although the results will probably be neither useful |
|
281 | 281 | nor desirable. |
|
282 | 282 | |
|
283 | 283 | Returns 0 on success. |
|
284 | 284 | """ |
|
285 | 285 | opts = pycompat.byteskwargs(opts) |
|
286 | 286 | if not pats: |
|
287 | 287 | raise error.Abort(_('at least one filename or pattern is required')) |
|
288 | 288 | |
|
289 | 289 | if opts.get('follow'): |
|
290 | 290 | # --follow is deprecated and now just an alias for -f/--file |
|
291 | 291 | # to mimic the behavior of Mercurial before version 1.5 |
|
292 | 292 | opts['file'] = True |
|
293 | 293 | |
|
294 | 294 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
295 | 295 | |
|
296 | 296 | rootfm = ui.formatter('annotate', opts) |
|
297 | 297 | if ui.quiet: |
|
298 | 298 | datefunc = util.shortdate |
|
299 | 299 | else: |
|
300 | 300 | datefunc = util.datestr |
|
301 | 301 | if ctx.rev() is None: |
|
302 | 302 | def hexfn(node): |
|
303 | 303 | if node is None: |
|
304 | 304 | return None |
|
305 | 305 | else: |
|
306 | 306 | return rootfm.hexfunc(node) |
|
307 | 307 | if opts.get('changeset'): |
|
308 | 308 | # omit "+" suffix which is appended to node hex |
|
309 | 309 | def formatrev(rev): |
|
310 | 310 | if rev is None: |
|
311 | 311 | return '%d' % ctx.p1().rev() |
|
312 | 312 | else: |
|
313 | 313 | return '%d' % rev |
|
314 | 314 | else: |
|
315 | 315 | def formatrev(rev): |
|
316 | 316 | if rev is None: |
|
317 | 317 | return '%d+' % ctx.p1().rev() |
|
318 | 318 | else: |
|
319 | 319 | return '%d ' % rev |
|
320 | 320 | def formathex(hex): |
|
321 | 321 | if hex is None: |
|
322 | 322 | return '%s+' % rootfm.hexfunc(ctx.p1().node()) |
|
323 | 323 | else: |
|
324 | 324 | return '%s ' % hex |
|
325 | 325 | else: |
|
326 | 326 | hexfn = rootfm.hexfunc |
|
327 | 327 | formatrev = formathex = pycompat.bytestr |
|
328 | 328 | |
|
329 | 329 | opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), |
|
330 | 330 | ('number', ' ', lambda x: x[0].rev(), formatrev), |
|
331 | 331 | ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex), |
|
332 | 332 | ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)), |
|
333 | 333 | ('file', ' ', lambda x: x[0].path(), str), |
|
334 | 334 | ('line_number', ':', lambda x: x[1], str), |
|
335 | 335 | ] |
|
336 | 336 | fieldnamemap = {'number': 'rev', 'changeset': 'node'} |
|
337 | 337 | |
|
338 | 338 | if (not opts.get('user') and not opts.get('changeset') |
|
339 | 339 | and not opts.get('date') and not opts.get('file')): |
|
340 | 340 | opts['number'] = True |
|
341 | 341 | |
|
342 | 342 | linenumber = opts.get('line_number') is not None |
|
343 | 343 | if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
|
344 | 344 | raise error.Abort(_('at least one of -n/-c is required for -l')) |
|
345 | 345 | |
|
346 | 346 | ui.pager('annotate') |
|
347 | 347 | |
|
348 | 348 | if rootfm.isplain(): |
|
349 | 349 | def makefunc(get, fmt): |
|
350 | 350 | return lambda x: fmt(get(x)) |
|
351 | 351 | else: |
|
352 | 352 | def makefunc(get, fmt): |
|
353 | 353 | return get |
|
354 | 354 | funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap |
|
355 | 355 | if opts.get(op)] |
|
356 | 356 | funcmap[0] = (funcmap[0][0], '') # no separator in front of first column |
|
357 | 357 | fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap |
|
358 | 358 | if opts.get(op)) |
|
359 | 359 | |
|
360 | 360 | def bad(x, y): |
|
361 | 361 | raise error.Abort("%s: %s" % (x, y)) |
|
362 | 362 | |
|
363 | 363 | m = scmutil.match(ctx, pats, opts, badfn=bad) |
|
364 | 364 | |
|
365 | 365 | follow = not opts.get('no_follow') |
|
366 | 366 | diffopts = patch.difffeatureopts(ui, opts, section='annotate', |
|
367 | 367 | whitespace=True) |
|
368 | 368 | skiprevs = opts.get('skip') |
|
369 | 369 | if skiprevs: |
|
370 | 370 | skiprevs = scmutil.revrange(repo, skiprevs) |
|
371 | 371 | |
|
372 | 372 | for abs in ctx.walk(m): |
|
373 | 373 | fctx = ctx[abs] |
|
374 | 374 | rootfm.startitem() |
|
375 | 375 | rootfm.data(abspath=abs, path=m.rel(abs)) |
|
376 | 376 | if not opts.get('text') and fctx.isbinary(): |
|
377 | 377 | rootfm.plain(_("%s: binary file\n") |
|
378 | 378 | % ((pats and m.rel(abs)) or abs)) |
|
379 | 379 | continue |
|
380 | 380 | |
|
381 | 381 | fm = rootfm.nested('lines') |
|
382 | 382 | lines = fctx.annotate(follow=follow, linenumber=linenumber, |
|
383 | 383 | skiprevs=skiprevs, diffopts=diffopts) |
|
384 | 384 | if not lines: |
|
385 | 385 | fm.end() |
|
386 | 386 | continue |
|
387 | 387 | formats = [] |
|
388 | 388 | pieces = [] |
|
389 | 389 | |
|
390 | 390 | for f, sep in funcmap: |
|
391 | 391 | l = [f(n) for n, dummy in lines] |
|
392 | 392 | if fm.isplain(): |
|
393 | 393 | sizes = [encoding.colwidth(x) for x in l] |
|
394 | 394 | ml = max(sizes) |
|
395 | 395 | formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes]) |
|
396 | 396 | else: |
|
397 | 397 | formats.append(['%s' for x in l]) |
|
398 | 398 | pieces.append(l) |
|
399 | 399 | |
|
400 | 400 | for f, p, l in zip(zip(*formats), zip(*pieces), lines): |
|
401 | 401 | fm.startitem() |
|
402 | 402 | fm.write(fields, "".join(f), *p) |
|
403 | 403 | fm.write('line', ": %s", l[1]) |
|
404 | 404 | |
|
405 | 405 | if not lines[-1][1].endswith('\n'): |
|
406 | 406 | fm.plain('\n') |
|
407 | 407 | fm.end() |
|
408 | 408 | |
|
409 | 409 | rootfm.end() |
|
410 | 410 | |
|
411 | 411 | @command('archive', |
|
412 | 412 | [('', 'no-decode', None, _('do not pass files through decoders')), |
|
413 | 413 | ('p', 'prefix', '', _('directory prefix for files in archive'), |
|
414 | 414 | _('PREFIX')), |
|
415 | 415 | ('r', 'rev', '', _('revision to distribute'), _('REV')), |
|
416 | 416 | ('t', 'type', '', _('type of distribution to create'), _('TYPE')), |
|
417 | 417 | ] + subrepoopts + walkopts, |
|
418 | 418 | _('[OPTION]... DEST')) |
|
419 | 419 | def archive(ui, repo, dest, **opts): |
|
420 | 420 | '''create an unversioned archive of a repository revision |
|
421 | 421 | |
|
422 | 422 | By default, the revision used is the parent of the working |
|
423 | 423 | directory; use -r/--rev to specify a different revision. |
|
424 | 424 | |
|
425 | 425 | The archive type is automatically detected based on file |
|
426 | 426 | extension (to override, use -t/--type). |
|
427 | 427 | |
|
428 | 428 | .. container:: verbose |
|
429 | 429 | |
|
430 | 430 | Examples: |
|
431 | 431 | |
|
432 | 432 | - create a zip file containing the 1.0 release:: |
|
433 | 433 | |
|
434 | 434 | hg archive -r 1.0 project-1.0.zip |
|
435 | 435 | |
|
436 | 436 | - create a tarball excluding .hg files:: |
|
437 | 437 | |
|
438 | 438 | hg archive project.tar.gz -X ".hg*" |
|
439 | 439 | |
|
440 | 440 | Valid types are: |
|
441 | 441 | |
|
442 | 442 | :``files``: a directory full of files (default) |
|
443 | 443 | :``tar``: tar archive, uncompressed |
|
444 | 444 | :``tbz2``: tar archive, compressed using bzip2 |
|
445 | 445 | :``tgz``: tar archive, compressed using gzip |
|
446 | 446 | :``uzip``: zip archive, uncompressed |
|
447 | 447 | :``zip``: zip archive, compressed using deflate |
|
448 | 448 | |
|
449 | 449 | The exact name of the destination archive or directory is given |
|
450 | 450 | using a format string; see :hg:`help export` for details. |
|
451 | 451 | |
|
452 | 452 | Each member added to an archive file has a directory prefix |
|
453 | 453 | prepended. Use -p/--prefix to specify a format string for the |
|
454 | 454 | prefix. The default is the basename of the archive, with suffixes |
|
455 | 455 | removed. |
|
456 | 456 | |
|
457 | 457 | Returns 0 on success. |
|
458 | 458 | ''' |
|
459 | 459 | |
|
460 | 460 | opts = pycompat.byteskwargs(opts) |
|
461 | 461 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
462 | 462 | if not ctx: |
|
463 | 463 | raise error.Abort(_('no working directory: please specify a revision')) |
|
464 | 464 | node = ctx.node() |
|
465 | 465 | dest = cmdutil.makefilename(repo, dest, node) |
|
466 | 466 | if os.path.realpath(dest) == repo.root: |
|
467 | 467 | raise error.Abort(_('repository root cannot be destination')) |
|
468 | 468 | |
|
469 | 469 | kind = opts.get('type') or archival.guesskind(dest) or 'files' |
|
470 | 470 | prefix = opts.get('prefix') |
|
471 | 471 | |
|
472 | 472 | if dest == '-': |
|
473 | 473 | if kind == 'files': |
|
474 | 474 | raise error.Abort(_('cannot archive plain files to stdout')) |
|
475 | 475 | dest = cmdutil.makefileobj(repo, dest) |
|
476 | 476 | if not prefix: |
|
477 | 477 | prefix = os.path.basename(repo.root) + '-%h' |
|
478 | 478 | |
|
479 | 479 | prefix = cmdutil.makefilename(repo, prefix, node) |
|
480 | 480 | match = scmutil.match(ctx, [], opts) |
|
481 | 481 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
|
482 | 482 | match, prefix, subrepos=opts.get('subrepos')) |
|
483 | 483 | |
|
484 | 484 | @command('backout', |
|
485 | 485 | [('', 'merge', None, _('merge with old dirstate parent after backout')), |
|
486 | 486 | ('', 'commit', None, |
|
487 | 487 | _('commit if no conflicts were encountered (DEPRECATED)')), |
|
488 | 488 | ('', 'no-commit', None, _('do not commit')), |
|
489 | 489 | ('', 'parent', '', |
|
490 | 490 | _('parent to choose when backing out merge (DEPRECATED)'), _('REV')), |
|
491 | 491 | ('r', 'rev', '', _('revision to backout'), _('REV')), |
|
492 | 492 | ('e', 'edit', False, _('invoke editor on commit messages')), |
|
493 | 493 | ] + mergetoolopts + walkopts + commitopts + commitopts2, |
|
494 | 494 | _('[OPTION]... [-r] REV')) |
|
495 | 495 | def backout(ui, repo, node=None, rev=None, **opts): |
|
496 | 496 | '''reverse effect of earlier changeset |
|
497 | 497 | |
|
498 | 498 | Prepare a new changeset with the effect of REV undone in the |
|
499 | 499 | current working directory. If no conflicts were encountered, |
|
500 | 500 | it will be committed immediately. |
|
501 | 501 | |
|
502 | 502 | If REV is the parent of the working directory, then this new changeset |
|
503 | 503 | is committed automatically (unless --no-commit is specified). |
|
504 | 504 | |
|
505 | 505 | .. note:: |
|
506 | 506 | |
|
507 | 507 | :hg:`backout` cannot be used to fix either an unwanted or |
|
508 | 508 | incorrect merge. |
|
509 | 509 | |
|
510 | 510 | .. container:: verbose |
|
511 | 511 | |
|
512 | 512 | Examples: |
|
513 | 513 | |
|
514 | 514 | - Reverse the effect of the parent of the working directory. |
|
515 | 515 | This backout will be committed immediately:: |
|
516 | 516 | |
|
517 | 517 | hg backout -r . |
|
518 | 518 | |
|
519 | 519 | - Reverse the effect of previous bad revision 23:: |
|
520 | 520 | |
|
521 | 521 | hg backout -r 23 |
|
522 | 522 | |
|
523 | 523 | - Reverse the effect of previous bad revision 23 and |
|
524 | 524 | leave changes uncommitted:: |
|
525 | 525 | |
|
526 | 526 | hg backout -r 23 --no-commit |
|
527 | 527 | hg commit -m "Backout revision 23" |
|
528 | 528 | |
|
529 | 529 | By default, the pending changeset will have one parent, |
|
530 | 530 | maintaining a linear history. With --merge, the pending |
|
531 | 531 | changeset will instead have two parents: the old parent of the |
|
532 | 532 | working directory and a new child of REV that simply undoes REV. |
|
533 | 533 | |
|
534 | 534 | Before version 1.7, the behavior without --merge was equivalent |
|
535 | 535 | to specifying --merge followed by :hg:`update --clean .` to |
|
536 | 536 | cancel the merge and leave the child of REV as a head to be |
|
537 | 537 | merged separately. |
|
538 | 538 | |
|
539 | 539 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
540 | 540 | |
|
541 | 541 | See :hg:`help revert` for a way to restore files to the state |
|
542 | 542 | of another revision. |
|
543 | 543 | |
|
544 | 544 | Returns 0 on success, 1 if nothing to backout or there are unresolved |
|
545 | 545 | files. |
|
546 | 546 | ''' |
|
547 | 547 | wlock = lock = None |
|
548 | 548 | try: |
|
549 | 549 | wlock = repo.wlock() |
|
550 | 550 | lock = repo.lock() |
|
551 | 551 | return _dobackout(ui, repo, node, rev, **opts) |
|
552 | 552 | finally: |
|
553 | 553 | release(lock, wlock) |
|
554 | 554 | |
|
555 | 555 | def _dobackout(ui, repo, node=None, rev=None, **opts): |
|
556 | 556 | opts = pycompat.byteskwargs(opts) |
|
557 | 557 | if opts.get('commit') and opts.get('no_commit'): |
|
558 | 558 | raise error.Abort(_("cannot use --commit with --no-commit")) |
|
559 | 559 | if opts.get('merge') and opts.get('no_commit'): |
|
560 | 560 | raise error.Abort(_("cannot use --merge with --no-commit")) |
|
561 | 561 | |
|
562 | 562 | if rev and node: |
|
563 | 563 | raise error.Abort(_("please specify just one revision")) |
|
564 | 564 | |
|
565 | 565 | if not rev: |
|
566 | 566 | rev = node |
|
567 | 567 | |
|
568 | 568 | if not rev: |
|
569 | 569 | raise error.Abort(_("please specify a revision to backout")) |
|
570 | 570 | |
|
571 | 571 | date = opts.get('date') |
|
572 | 572 | if date: |
|
573 | 573 | opts['date'] = util.parsedate(date) |
|
574 | 574 | |
|
575 | 575 | cmdutil.checkunfinished(repo) |
|
576 | 576 | cmdutil.bailifchanged(repo) |
|
577 | 577 | node = scmutil.revsingle(repo, rev).node() |
|
578 | 578 | |
|
579 | 579 | op1, op2 = repo.dirstate.parents() |
|
580 | 580 | if not repo.changelog.isancestor(node, op1): |
|
581 | 581 | raise error.Abort(_('cannot backout change that is not an ancestor')) |
|
582 | 582 | |
|
583 | 583 | p1, p2 = repo.changelog.parents(node) |
|
584 | 584 | if p1 == nullid: |
|
585 | 585 | raise error.Abort(_('cannot backout a change with no parents')) |
|
586 | 586 | if p2 != nullid: |
|
587 | 587 | if not opts.get('parent'): |
|
588 | 588 | raise error.Abort(_('cannot backout a merge changeset')) |
|
589 | 589 | p = repo.lookup(opts['parent']) |
|
590 | 590 | if p not in (p1, p2): |
|
591 | 591 | raise error.Abort(_('%s is not a parent of %s') % |
|
592 | 592 | (short(p), short(node))) |
|
593 | 593 | parent = p |
|
594 | 594 | else: |
|
595 | 595 | if opts.get('parent'): |
|
596 | 596 | raise error.Abort(_('cannot use --parent on non-merge changeset')) |
|
597 | 597 | parent = p1 |
|
598 | 598 | |
|
599 | 599 | # the backout should appear on the same branch |
|
600 | 600 | branch = repo.dirstate.branch() |
|
601 | 601 | bheads = repo.branchheads(branch) |
|
602 | 602 | rctx = scmutil.revsingle(repo, hex(parent)) |
|
603 | 603 | if not opts.get('merge') and op1 != node: |
|
604 | 604 | dsguard = dirstateguard.dirstateguard(repo, 'backout') |
|
605 | 605 | try: |
|
606 | 606 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
607 | 607 | 'backout') |
|
608 | 608 | stats = mergemod.update(repo, parent, True, True, node, False) |
|
609 | 609 | repo.setparents(op1, op2) |
|
610 | 610 | dsguard.close() |
|
611 | 611 | hg._showstats(repo, stats) |
|
612 | 612 | if stats[3]: |
|
613 | 613 | repo.ui.status(_("use 'hg resolve' to retry unresolved " |
|
614 | 614 | "file merges\n")) |
|
615 | 615 | return 1 |
|
616 | 616 | finally: |
|
617 | 617 | ui.setconfig('ui', 'forcemerge', '', '') |
|
618 | 618 | lockmod.release(dsguard) |
|
619 | 619 | else: |
|
620 | 620 | hg.clean(repo, node, show_stats=False) |
|
621 | 621 | repo.dirstate.setbranch(branch) |
|
622 | 622 | cmdutil.revert(ui, repo, rctx, repo.dirstate.parents()) |
|
623 | 623 | |
|
624 | 624 | if opts.get('no_commit'): |
|
625 | 625 | msg = _("changeset %s backed out, " |
|
626 | 626 | "don't forget to commit.\n") |
|
627 | 627 | ui.status(msg % short(node)) |
|
628 | 628 | return 0 |
|
629 | 629 | |
|
630 | 630 | def commitfunc(ui, repo, message, match, opts): |
|
631 | 631 | editform = 'backout' |
|
632 | 632 | e = cmdutil.getcommiteditor(editform=editform, |
|
633 | 633 | **pycompat.strkwargs(opts)) |
|
634 | 634 | if not message: |
|
635 | 635 | # we don't translate commit messages |
|
636 | 636 | message = "Backed out changeset %s" % short(node) |
|
637 | 637 | e = cmdutil.getcommiteditor(edit=True, editform=editform) |
|
638 | 638 | return repo.commit(message, opts.get('user'), opts.get('date'), |
|
639 | 639 | match, editor=e) |
|
640 | 640 | newnode = cmdutil.commit(ui, repo, commitfunc, [], opts) |
|
641 | 641 | if not newnode: |
|
642 | 642 | ui.status(_("nothing changed\n")) |
|
643 | 643 | return 1 |
|
644 | 644 | cmdutil.commitstatus(repo, newnode, branch, bheads) |
|
645 | 645 | |
|
646 | 646 | def nice(node): |
|
647 | 647 | return '%d:%s' % (repo.changelog.rev(node), short(node)) |
|
648 | 648 | ui.status(_('changeset %s backs out changeset %s\n') % |
|
649 | 649 | (nice(repo.changelog.tip()), nice(node))) |
|
650 | 650 | if opts.get('merge') and op1 != node: |
|
651 | 651 | hg.clean(repo, op1, show_stats=False) |
|
652 | 652 | ui.status(_('merging with changeset %s\n') |
|
653 | 653 | % nice(repo.changelog.tip())) |
|
654 | 654 | try: |
|
655 | 655 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
656 | 656 | 'backout') |
|
657 | 657 | return hg.merge(repo, hex(repo.changelog.tip())) |
|
658 | 658 | finally: |
|
659 | 659 | ui.setconfig('ui', 'forcemerge', '', '') |
|
660 | 660 | return 0 |
|
661 | 661 | |
|
662 | 662 | @command('bisect', |
|
663 | 663 | [('r', 'reset', False, _('reset bisect state')), |
|
664 | 664 | ('g', 'good', False, _('mark changeset good')), |
|
665 | 665 | ('b', 'bad', False, _('mark changeset bad')), |
|
666 | 666 | ('s', 'skip', False, _('skip testing changeset')), |
|
667 | 667 | ('e', 'extend', False, _('extend the bisect range')), |
|
668 | 668 | ('c', 'command', '', _('use command to check changeset state'), _('CMD')), |
|
669 | 669 | ('U', 'noupdate', False, _('do not update to target'))], |
|
670 | 670 | _("[-gbsr] [-U] [-c CMD] [REV]")) |
|
671 | 671 | def bisect(ui, repo, rev=None, extra=None, command=None, |
|
672 | 672 | reset=None, good=None, bad=None, skip=None, extend=None, |
|
673 | 673 | noupdate=None): |
|
674 | 674 | """subdivision search of changesets |
|
675 | 675 | |
|
676 | 676 | This command helps to find changesets which introduce problems. To |
|
677 | 677 | use, mark the earliest changeset you know exhibits the problem as |
|
678 | 678 | bad, then mark the latest changeset which is free from the problem |
|
679 | 679 | as good. Bisect will update your working directory to a revision |
|
680 | 680 | for testing (unless the -U/--noupdate option is specified). Once |
|
681 | 681 | you have performed tests, mark the working directory as good or |
|
682 | 682 | bad, and bisect will either update to another candidate changeset |
|
683 | 683 | or announce that it has found the bad revision. |
|
684 | 684 | |
|
685 | 685 | As a shortcut, you can also use the revision argument to mark a |
|
686 | 686 | revision as good or bad without checking it out first. |
|
687 | 687 | |
|
688 | 688 | If you supply a command, it will be used for automatic bisection. |
|
689 | 689 | The environment variable HG_NODE will contain the ID of the |
|
690 | 690 | changeset being tested. The exit status of the command will be |
|
691 | 691 | used to mark revisions as good or bad: status 0 means good, 125 |
|
692 | 692 | means to skip the revision, 127 (command not found) will abort the |
|
693 | 693 | bisection, and any other non-zero exit status means the revision |
|
694 | 694 | is bad. |
|
695 | 695 | |
|
696 | 696 | .. container:: verbose |
|
697 | 697 | |
|
698 | 698 | Some examples: |
|
699 | 699 | |
|
700 | 700 | - start a bisection with known bad revision 34, and good revision 12:: |
|
701 | 701 | |
|
702 | 702 | hg bisect --bad 34 |
|
703 | 703 | hg bisect --good 12 |
|
704 | 704 | |
|
705 | 705 | - advance the current bisection by marking current revision as good or |
|
706 | 706 | bad:: |
|
707 | 707 | |
|
708 | 708 | hg bisect --good |
|
709 | 709 | hg bisect --bad |
|
710 | 710 | |
|
711 | 711 | - mark the current revision, or a known revision, to be skipped (e.g. if |
|
712 | 712 | that revision is not usable because of another issue):: |
|
713 | 713 | |
|
714 | 714 | hg bisect --skip |
|
715 | 715 | hg bisect --skip 23 |
|
716 | 716 | |
|
717 | 717 | - skip all revisions that do not touch directories ``foo`` or ``bar``:: |
|
718 | 718 | |
|
719 | 719 | hg bisect --skip "!( file('path:foo') & file('path:bar') )" |
|
720 | 720 | |
|
721 | 721 | - forget the current bisection:: |
|
722 | 722 | |
|
723 | 723 | hg bisect --reset |
|
724 | 724 | |
|
725 | 725 | - use 'make && make tests' to automatically find the first broken |
|
726 | 726 | revision:: |
|
727 | 727 | |
|
728 | 728 | hg bisect --reset |
|
729 | 729 | hg bisect --bad 34 |
|
730 | 730 | hg bisect --good 12 |
|
731 | 731 | hg bisect --command "make && make tests" |
|
732 | 732 | |
|
733 | 733 | - see all changesets whose states are already known in the current |
|
734 | 734 | bisection:: |
|
735 | 735 | |
|
736 | 736 | hg log -r "bisect(pruned)" |
|
737 | 737 | |
|
738 | 738 | - see the changeset currently being bisected (especially useful |
|
739 | 739 | if running with -U/--noupdate):: |
|
740 | 740 | |
|
741 | 741 | hg log -r "bisect(current)" |
|
742 | 742 | |
|
743 | 743 | - see all changesets that took part in the current bisection:: |
|
744 | 744 | |
|
745 | 745 | hg log -r "bisect(range)" |
|
746 | 746 | |
|
747 | 747 | - you can even get a nice graph:: |
|
748 | 748 | |
|
749 | 749 | hg log --graph -r "bisect(range)" |
|
750 | 750 | |
|
751 | 751 | See :hg:`help revisions.bisect` for more about the `bisect()` predicate. |
|
752 | 752 | |
|
753 | 753 | Returns 0 on success. |
|
754 | 754 | """ |
|
755 | 755 | # backward compatibility |
|
756 | 756 | if rev in "good bad reset init".split(): |
|
757 | 757 | ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) |
|
758 | 758 | cmd, rev, extra = rev, extra, None |
|
759 | 759 | if cmd == "good": |
|
760 | 760 | good = True |
|
761 | 761 | elif cmd == "bad": |
|
762 | 762 | bad = True |
|
763 | 763 | else: |
|
764 | 764 | reset = True |
|
765 | 765 | elif extra: |
|
766 | 766 | raise error.Abort(_('incompatible arguments')) |
|
767 | 767 | |
|
768 | 768 | incompatibles = { |
|
769 | 769 | '--bad': bad, |
|
770 | 770 | '--command': bool(command), |
|
771 | 771 | '--extend': extend, |
|
772 | 772 | '--good': good, |
|
773 | 773 | '--reset': reset, |
|
774 | 774 | '--skip': skip, |
|
775 | 775 | } |
|
776 | 776 | |
|
777 | 777 | enabled = [x for x in incompatibles if incompatibles[x]] |
|
778 | 778 | |
|
779 | 779 | if len(enabled) > 1: |
|
780 | 780 | raise error.Abort(_('%s and %s are incompatible') % |
|
781 | 781 | tuple(sorted(enabled)[0:2])) |
|
782 | 782 | |
|
783 | 783 | if reset: |
|
784 | 784 | hbisect.resetstate(repo) |
|
785 | 785 | return |
|
786 | 786 | |
|
787 | 787 | state = hbisect.load_state(repo) |
|
788 | 788 | |
|
789 | 789 | # update state |
|
790 | 790 | if good or bad or skip: |
|
791 | 791 | if rev: |
|
792 | 792 | nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])] |
|
793 | 793 | else: |
|
794 | 794 | nodes = [repo.lookup('.')] |
|
795 | 795 | if good: |
|
796 | 796 | state['good'] += nodes |
|
797 | 797 | elif bad: |
|
798 | 798 | state['bad'] += nodes |
|
799 | 799 | elif skip: |
|
800 | 800 | state['skip'] += nodes |
|
801 | 801 | hbisect.save_state(repo, state) |
|
802 | 802 | if not (state['good'] and state['bad']): |
|
803 | 803 | return |
|
804 | 804 | |
|
805 | 805 | def mayupdate(repo, node, show_stats=True): |
|
806 | 806 | """common used update sequence""" |
|
807 | 807 | if noupdate: |
|
808 | 808 | return |
|
809 | 809 | cmdutil.checkunfinished(repo) |
|
810 | 810 | cmdutil.bailifchanged(repo) |
|
811 | 811 | return hg.clean(repo, node, show_stats=show_stats) |
|
812 | 812 | |
|
813 | 813 | displayer = cmdutil.show_changeset(ui, repo, {}) |
|
814 | 814 | |
|
815 | 815 | if command: |
|
816 | 816 | changesets = 1 |
|
817 | 817 | if noupdate: |
|
818 | 818 | try: |
|
819 | 819 | node = state['current'][0] |
|
820 | 820 | except LookupError: |
|
821 | 821 | raise error.Abort(_('current bisect revision is unknown - ' |
|
822 | 822 | 'start a new bisect to fix')) |
|
823 | 823 | else: |
|
824 | 824 | node, p2 = repo.dirstate.parents() |
|
825 | 825 | if p2 != nullid: |
|
826 | 826 | raise error.Abort(_('current bisect revision is a merge')) |
|
827 | 827 | if rev: |
|
828 | 828 | node = repo[scmutil.revsingle(repo, rev, node)].node() |
|
829 | 829 | try: |
|
830 | 830 | while changesets: |
|
831 | 831 | # update state |
|
832 | 832 | state['current'] = [node] |
|
833 | 833 | hbisect.save_state(repo, state) |
|
834 | 834 | status = ui.system(command, environ={'HG_NODE': hex(node)}, |
|
835 | 835 | blockedtag='bisect_check') |
|
836 | 836 | if status == 125: |
|
837 | 837 | transition = "skip" |
|
838 | 838 | elif status == 0: |
|
839 | 839 | transition = "good" |
|
840 | 840 | # status < 0 means process was killed |
|
841 | 841 | elif status == 127: |
|
842 | 842 | raise error.Abort(_("failed to execute %s") % command) |
|
843 | 843 | elif status < 0: |
|
844 | 844 | raise error.Abort(_("%s killed") % command) |
|
845 | 845 | else: |
|
846 | 846 | transition = "bad" |
|
847 | 847 | state[transition].append(node) |
|
848 | 848 | ctx = repo[node] |
|
849 | 849 | ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition)) |
|
850 | 850 | hbisect.checkstate(state) |
|
851 | 851 | # bisect |
|
852 | 852 | nodes, changesets, bgood = hbisect.bisect(repo.changelog, state) |
|
853 | 853 | # update to next check |
|
854 | 854 | node = nodes[0] |
|
855 | 855 | mayupdate(repo, node, show_stats=False) |
|
856 | 856 | finally: |
|
857 | 857 | state['current'] = [node] |
|
858 | 858 | hbisect.save_state(repo, state) |
|
859 | 859 | hbisect.printresult(ui, repo, state, displayer, nodes, bgood) |
|
860 | 860 | return |
|
861 | 861 | |
|
862 | 862 | hbisect.checkstate(state) |
|
863 | 863 | |
|
864 | 864 | # actually bisect |
|
865 | 865 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
|
866 | 866 | if extend: |
|
867 | 867 | if not changesets: |
|
868 | 868 | extendnode = hbisect.extendrange(repo, state, nodes, good) |
|
869 | 869 | if extendnode is not None: |
|
870 | 870 | ui.write(_("Extending search to changeset %d:%s\n") |
|
871 | 871 | % (extendnode.rev(), extendnode)) |
|
872 | 872 | state['current'] = [extendnode.node()] |
|
873 | 873 | hbisect.save_state(repo, state) |
|
874 | 874 | return mayupdate(repo, extendnode.node()) |
|
875 | 875 | raise error.Abort(_("nothing to extend")) |
|
876 | 876 | |
|
877 | 877 | if changesets == 0: |
|
878 | 878 | hbisect.printresult(ui, repo, state, displayer, nodes, good) |
|
879 | 879 | else: |
|
880 | 880 | assert len(nodes) == 1 # only a single node can be tested next |
|
881 | 881 | node = nodes[0] |
|
882 | 882 | # compute the approximate number of remaining tests |
|
883 | 883 | tests, size = 0, 2 |
|
884 | 884 | while size <= changesets: |
|
885 | 885 | tests, size = tests + 1, size * 2 |
|
886 | 886 | rev = repo.changelog.rev(node) |
|
887 | 887 | ui.write(_("Testing changeset %d:%s " |
|
888 | 888 | "(%d changesets remaining, ~%d tests)\n") |
|
889 | 889 | % (rev, short(node), changesets, tests)) |
|
890 | 890 | state['current'] = [node] |
|
891 | 891 | hbisect.save_state(repo, state) |
|
892 | 892 | return mayupdate(repo, node) |
|
893 | 893 | |
|
894 | 894 | @command('bookmarks|bookmark', |
|
895 | 895 | [('f', 'force', False, _('force')), |
|
896 | 896 | ('r', 'rev', '', _('revision for bookmark action'), _('REV')), |
|
897 | 897 | ('d', 'delete', False, _('delete a given bookmark')), |
|
898 | 898 | ('m', 'rename', '', _('rename a given bookmark'), _('OLD')), |
|
899 | 899 | ('i', 'inactive', False, _('mark a bookmark inactive')), |
|
900 | 900 | ] + formatteropts, |
|
901 | 901 | _('hg bookmarks [OPTIONS]... [NAME]...')) |
|
902 | 902 | def bookmark(ui, repo, *names, **opts): |
|
903 | 903 | '''create a new bookmark or list existing bookmarks |
|
904 | 904 | |
|
905 | 905 | Bookmarks are labels on changesets to help track lines of development. |
|
906 | 906 | Bookmarks are unversioned and can be moved, renamed and deleted. |
|
907 | 907 | Deleting or moving a bookmark has no effect on the associated changesets. |
|
908 | 908 | |
|
909 | 909 | Creating or updating to a bookmark causes it to be marked as 'active'. |
|
910 | 910 | The active bookmark is indicated with a '*'. |
|
911 | 911 | When a commit is made, the active bookmark will advance to the new commit. |
|
912 | 912 | A plain :hg:`update` will also advance an active bookmark, if possible. |
|
913 | 913 | Updating away from a bookmark will cause it to be deactivated. |
|
914 | 914 | |
|
915 | 915 | Bookmarks can be pushed and pulled between repositories (see |
|
916 | 916 | :hg:`help push` and :hg:`help pull`). If a shared bookmark has |
|
917 | 917 | diverged, a new 'divergent bookmark' of the form 'name@path' will |
|
918 | 918 | be created. Using :hg:`merge` will resolve the divergence. |
|
919 | 919 | |
|
920 | 920 | Specifying bookmark as '.' to -m or -d options is equivalent to specifying |
|
921 | 921 | the active bookmark's name. |
|
922 | 922 | |
|
923 | 923 | A bookmark named '@' has the special property that :hg:`clone` will |
|
924 | 924 | check it out by default if it exists. |
|
925 | 925 | |
|
926 | 926 | .. container:: verbose |
|
927 | 927 | |
|
928 | 928 | Examples: |
|
929 | 929 | |
|
930 | 930 | - create an active bookmark for a new line of development:: |
|
931 | 931 | |
|
932 | 932 | hg book new-feature |
|
933 | 933 | |
|
934 | 934 | - create an inactive bookmark as a place marker:: |
|
935 | 935 | |
|
936 | 936 | hg book -i reviewed |
|
937 | 937 | |
|
938 | 938 | - create an inactive bookmark on another changeset:: |
|
939 | 939 | |
|
940 | 940 | hg book -r .^ tested |
|
941 | 941 | |
|
942 | 942 | - rename bookmark turkey to dinner:: |
|
943 | 943 | |
|
944 | 944 | hg book -m turkey dinner |
|
945 | 945 | |
|
946 | 946 | - move the '@' bookmark from another branch:: |
|
947 | 947 | |
|
948 | 948 | hg book -f @ |
|
949 | 949 | ''' |
|
950 | 950 | force = opts.get(r'force') |
|
951 | 951 | rev = opts.get(r'rev') |
|
952 | 952 | delete = opts.get(r'delete') |
|
953 | 953 | rename = opts.get(r'rename') |
|
954 | 954 | inactive = opts.get(r'inactive') |
|
955 | 955 | |
|
956 | 956 | if delete and rename: |
|
957 | 957 | raise error.Abort(_("--delete and --rename are incompatible")) |
|
958 | 958 | if delete and rev: |
|
959 | 959 | raise error.Abort(_("--rev is incompatible with --delete")) |
|
960 | 960 | if rename and rev: |
|
961 | 961 | raise error.Abort(_("--rev is incompatible with --rename")) |
|
962 | 962 | if not names and (delete or rev): |
|
963 | 963 | raise error.Abort(_("bookmark name required")) |
|
964 | 964 | |
|
965 | 965 | if delete or rename or names or inactive: |
|
966 | 966 | with repo.wlock(), repo.lock(), repo.transaction('bookmark') as tr: |
|
967 | 967 | if delete: |
|
968 | 968 | names = pycompat.maplist(repo._bookmarks.expandname, names) |
|
969 | 969 | bookmarks.delete(repo, tr, names) |
|
970 | 970 | elif rename: |
|
971 | 971 | if not names: |
|
972 | 972 | raise error.Abort(_("new bookmark name required")) |
|
973 | 973 | elif len(names) > 1: |
|
974 | 974 | raise error.Abort(_("only one new bookmark name allowed")) |
|
975 | 975 | rename = repo._bookmarks.expandname(rename) |
|
976 | 976 | bookmarks.rename(repo, tr, rename, names[0], force, inactive) |
|
977 | 977 | elif names: |
|
978 | 978 | bookmarks.addbookmarks(repo, tr, names, rev, force, inactive) |
|
979 | 979 | elif inactive: |
|
980 | 980 | if len(repo._bookmarks) == 0: |
|
981 | 981 | ui.status(_("no bookmarks set\n")) |
|
982 | 982 | elif not repo._activebookmark: |
|
983 | 983 | ui.status(_("no active bookmark\n")) |
|
984 | 984 | else: |
|
985 | 985 | bookmarks.deactivate(repo) |
|
986 | 986 | else: # show bookmarks |
|
987 | 987 | bookmarks.printbookmarks(ui, repo, **opts) |
|
988 | 988 | |
|
989 | 989 | @command('branch', |
|
990 | 990 | [('f', 'force', None, |
|
991 | 991 | _('set branch name even if it shadows an existing branch')), |
|
992 | 992 | ('C', 'clean', None, _('reset branch name to parent branch name'))], |
|
993 | 993 | _('[-fC] [NAME]')) |
|
994 | 994 | def branch(ui, repo, label=None, **opts): |
|
995 | 995 | """set or show the current branch name |
|
996 | 996 | |
|
997 | 997 | .. note:: |
|
998 | 998 | |
|
999 | 999 | Branch names are permanent and global. Use :hg:`bookmark` to create a |
|
1000 | 1000 | light-weight bookmark instead. See :hg:`help glossary` for more |
|
1001 | 1001 | information about named branches and bookmarks. |
|
1002 | 1002 | |
|
1003 | 1003 | With no argument, show the current branch name. With one argument, |
|
1004 | 1004 | set the working directory branch name (the branch will not exist |
|
1005 | 1005 | in the repository until the next commit). Standard practice |
|
1006 | 1006 | recommends that primary development take place on the 'default' |
|
1007 | 1007 | branch. |
|
1008 | 1008 | |
|
1009 | 1009 | Unless -f/--force is specified, branch will not let you set a |
|
1010 | 1010 | branch name that already exists. |
|
1011 | 1011 | |
|
1012 | 1012 | Use -C/--clean to reset the working directory branch to that of |
|
1013 | 1013 | the parent of the working directory, negating a previous branch |
|
1014 | 1014 | change. |
|
1015 | 1015 | |
|
1016 | 1016 | Use the command :hg:`update` to switch to an existing branch. Use |
|
1017 | 1017 | :hg:`commit --close-branch` to mark this branch head as closed. |
|
1018 | 1018 | When all heads of a branch are closed, the branch will be |
|
1019 | 1019 | considered closed. |
|
1020 | 1020 | |
|
1021 | 1021 | Returns 0 on success. |
|
1022 | 1022 | """ |
|
1023 | 1023 | opts = pycompat.byteskwargs(opts) |
|
1024 | 1024 | if label: |
|
1025 | 1025 | label = label.strip() |
|
1026 | 1026 | |
|
1027 | 1027 | if not opts.get('clean') and not label: |
|
1028 | 1028 | ui.write("%s\n" % repo.dirstate.branch()) |
|
1029 | 1029 | return |
|
1030 | 1030 | |
|
1031 | 1031 | with repo.wlock(): |
|
1032 | 1032 | if opts.get('clean'): |
|
1033 | 1033 | label = repo[None].p1().branch() |
|
1034 | 1034 | repo.dirstate.setbranch(label) |
|
1035 | 1035 | ui.status(_('reset working directory to branch %s\n') % label) |
|
1036 | 1036 | elif label: |
|
1037 | 1037 | if not opts.get('force') and label in repo.branchmap(): |
|
1038 | 1038 | if label not in [p.branch() for p in repo[None].parents()]: |
|
1039 | 1039 | raise error.Abort(_('a branch of the same name already' |
|
1040 | 1040 | ' exists'), |
|
1041 | 1041 | # i18n: "it" refers to an existing branch |
|
1042 | 1042 | hint=_("use 'hg update' to switch to it")) |
|
1043 | 1043 | scmutil.checknewlabel(repo, label, 'branch') |
|
1044 | 1044 | repo.dirstate.setbranch(label) |
|
1045 | 1045 | ui.status(_('marked working directory as branch %s\n') % label) |
|
1046 | 1046 | |
|
1047 | 1047 | # find any open named branches aside from default |
|
1048 | 1048 | others = [n for n, h, t, c in repo.branchmap().iterbranches() |
|
1049 | 1049 | if n != "default" and not c] |
|
1050 | 1050 | if not others: |
|
1051 | 1051 | ui.status(_('(branches are permanent and global, ' |
|
1052 | 1052 | 'did you want a bookmark?)\n')) |
|
1053 | 1053 | |
|
1054 | 1054 | @command('branches', |
|
1055 | 1055 | [('a', 'active', False, |
|
1056 | 1056 | _('show only branches that have unmerged heads (DEPRECATED)')), |
|
1057 | 1057 | ('c', 'closed', False, _('show normal and closed branches')), |
|
1058 | 1058 | ] + formatteropts, |
|
1059 | 1059 | _('[-c]')) |
|
1060 | 1060 | def branches(ui, repo, active=False, closed=False, **opts): |
|
1061 | 1061 | """list repository named branches |
|
1062 | 1062 | |
|
1063 | 1063 | List the repository's named branches, indicating which ones are |
|
1064 | 1064 | inactive. If -c/--closed is specified, also list branches which have |
|
1065 | 1065 | been marked closed (see :hg:`commit --close-branch`). |
|
1066 | 1066 | |
|
1067 | 1067 | Use the command :hg:`update` to switch to an existing branch. |
|
1068 | 1068 | |
|
1069 | 1069 | Returns 0. |
|
1070 | 1070 | """ |
|
1071 | 1071 | |
|
1072 | 1072 | opts = pycompat.byteskwargs(opts) |
|
1073 | 1073 | ui.pager('branches') |
|
1074 | 1074 | fm = ui.formatter('branches', opts) |
|
1075 | 1075 | hexfunc = fm.hexfunc |
|
1076 | 1076 | |
|
1077 | 1077 | allheads = set(repo.heads()) |
|
1078 | 1078 | branches = [] |
|
1079 | 1079 | for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): |
|
1080 | 1080 | isactive = False |
|
1081 | 1081 | if not isclosed: |
|
1082 | 1082 | openheads = set(repo.branchmap().iteropen(heads)) |
|
1083 | 1083 | isactive = bool(openheads & allheads) |
|
1084 | 1084 | branches.append((tag, repo[tip], isactive, not isclosed)) |
|
1085 | 1085 | branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), |
|
1086 | 1086 | reverse=True) |
|
1087 | 1087 | |
|
1088 | 1088 | for tag, ctx, isactive, isopen in branches: |
|
1089 | 1089 | if active and not isactive: |
|
1090 | 1090 | continue |
|
1091 | 1091 | if isactive: |
|
1092 | 1092 | label = 'branches.active' |
|
1093 | 1093 | notice = '' |
|
1094 | 1094 | elif not isopen: |
|
1095 | 1095 | if not closed: |
|
1096 | 1096 | continue |
|
1097 | 1097 | label = 'branches.closed' |
|
1098 | 1098 | notice = _(' (closed)') |
|
1099 | 1099 | else: |
|
1100 | 1100 | label = 'branches.inactive' |
|
1101 | 1101 | notice = _(' (inactive)') |
|
1102 | 1102 | current = (tag == repo.dirstate.branch()) |
|
1103 | 1103 | if current: |
|
1104 | 1104 | label = 'branches.current' |
|
1105 | 1105 | |
|
1106 | 1106 | fm.startitem() |
|
1107 | 1107 | fm.write('branch', '%s', tag, label=label) |
|
1108 | 1108 | rev = ctx.rev() |
|
1109 | 1109 | padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0) |
|
1110 | 1110 | fmt = ' ' * padsize + ' %d:%s' |
|
1111 | 1111 | fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()), |
|
1112 | 1112 | label='log.changeset changeset.%s' % ctx.phasestr()) |
|
1113 | 1113 | fm.context(ctx=ctx) |
|
1114 | 1114 | fm.data(active=isactive, closed=not isopen, current=current) |
|
1115 | 1115 | if not ui.quiet: |
|
1116 | 1116 | fm.plain(notice) |
|
1117 | 1117 | fm.plain('\n') |
|
1118 | 1118 | fm.end() |
|
1119 | 1119 | |
|
1120 | 1120 | @command('bundle', |
|
1121 | 1121 | [('f', 'force', None, _('run even when the destination is unrelated')), |
|
1122 | 1122 | ('r', 'rev', [], _('a changeset intended to be added to the destination'), |
|
1123 | 1123 | _('REV')), |
|
1124 | 1124 | ('b', 'branch', [], _('a specific branch you would like to bundle'), |
|
1125 | 1125 | _('BRANCH')), |
|
1126 | 1126 | ('', 'base', [], |
|
1127 | 1127 | _('a base changeset assumed to be available at the destination'), |
|
1128 | 1128 | _('REV')), |
|
1129 | 1129 | ('a', 'all', None, _('bundle all changesets in the repository')), |
|
1130 | 1130 | ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')), |
|
1131 | 1131 | ] + remoteopts, |
|
1132 | 1132 | _('[-f] [-t BUNDLESPEC] [-a] [-r REV]... [--base REV]... FILE [DEST]')) |
|
1133 | 1133 | def bundle(ui, repo, fname, dest=None, **opts): |
|
1134 | 1134 | """create a bundle file |
|
1135 | 1135 | |
|
1136 | 1136 | Generate a bundle file containing data to be added to a repository. |
|
1137 | 1137 | |
|
1138 | 1138 | To create a bundle containing all changesets, use -a/--all |
|
1139 | 1139 | (or --base null). Otherwise, hg assumes the destination will have |
|
1140 | 1140 | all the nodes you specify with --base parameters. Otherwise, hg |
|
1141 | 1141 | will assume the repository has all the nodes in destination, or |
|
1142 | 1142 | default-push/default if no destination is specified. |
|
1143 | 1143 | |
|
1144 | 1144 | You can change bundle format with the -t/--type option. See |
|
1145 | 1145 | :hg:`help bundlespec` for documentation on this format. By default, |
|
1146 | 1146 | the most appropriate format is used and compression defaults to |
|
1147 | 1147 | bzip2. |
|
1148 | 1148 | |
|
1149 | 1149 | The bundle file can then be transferred using conventional means |
|
1150 | 1150 | and applied to another repository with the unbundle or pull |
|
1151 | 1151 | command. This is useful when direct push and pull are not |
|
1152 | 1152 | available or when exporting an entire repository is undesirable. |
|
1153 | 1153 | |
|
1154 | 1154 | Applying bundles preserves all changeset contents including |
|
1155 | 1155 | permissions, copy/rename information, and revision history. |
|
1156 | 1156 | |
|
1157 | 1157 | Returns 0 on success, 1 if no changes found. |
|
1158 | 1158 | """ |
|
1159 | 1159 | opts = pycompat.byteskwargs(opts) |
|
1160 | 1160 | revs = None |
|
1161 | 1161 | if 'rev' in opts: |
|
1162 | 1162 | revstrings = opts['rev'] |
|
1163 | 1163 | revs = scmutil.revrange(repo, revstrings) |
|
1164 | 1164 | if revstrings and not revs: |
|
1165 | 1165 | raise error.Abort(_('no commits to bundle')) |
|
1166 | 1166 | |
|
1167 | 1167 | bundletype = opts.get('type', 'bzip2').lower() |
|
1168 | 1168 | try: |
|
1169 | 1169 | bcompression, cgversion, params = exchange.parsebundlespec( |
|
1170 | 1170 | repo, bundletype, strict=False) |
|
1171 | 1171 | except error.UnsupportedBundleSpecification as e: |
|
1172 | 1172 | raise error.Abort(str(e), |
|
1173 | 1173 | hint=_("see 'hg help bundlespec' for supported " |
|
1174 | 1174 | "values for --type")) |
|
1175 | 1175 | |
|
1176 | 1176 | # Packed bundles are a pseudo bundle format for now. |
|
1177 | 1177 | if cgversion == 's1': |
|
1178 | 1178 | raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'), |
|
1179 | 1179 | hint=_("use 'hg debugcreatestreamclonebundle'")) |
|
1180 | 1180 | |
|
1181 | 1181 | if opts.get('all'): |
|
1182 | 1182 | if dest: |
|
1183 | 1183 | raise error.Abort(_("--all is incompatible with specifying " |
|
1184 | 1184 | "a destination")) |
|
1185 | 1185 | if opts.get('base'): |
|
1186 | 1186 | ui.warn(_("ignoring --base because --all was specified\n")) |
|
1187 | 1187 | base = ['null'] |
|
1188 | 1188 | else: |
|
1189 | 1189 | base = scmutil.revrange(repo, opts.get('base')) |
|
1190 | 1190 | if cgversion not in changegroup.supportedoutgoingversions(repo): |
|
1191 | 1191 | raise error.Abort(_("repository does not support bundle version %s") % |
|
1192 | 1192 | cgversion) |
|
1193 | 1193 | |
|
1194 | 1194 | if base: |
|
1195 | 1195 | if dest: |
|
1196 | 1196 | raise error.Abort(_("--base is incompatible with specifying " |
|
1197 | 1197 | "a destination")) |
|
1198 | 1198 | common = [repo.lookup(rev) for rev in base] |
|
1199 | 1199 | heads = revs and map(repo.lookup, revs) or None |
|
1200 | 1200 | outgoing = discovery.outgoing(repo, common, heads) |
|
1201 | 1201 | else: |
|
1202 | 1202 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
1203 | 1203 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
1204 | 1204 | other = hg.peer(repo, opts, dest) |
|
1205 | 1205 | revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) |
|
1206 | 1206 | heads = revs and map(repo.lookup, revs) or revs |
|
1207 | 1207 | outgoing = discovery.findcommonoutgoing(repo, other, |
|
1208 | 1208 | onlyheads=heads, |
|
1209 | 1209 | force=opts.get('force'), |
|
1210 | 1210 | portable=True) |
|
1211 | 1211 | |
|
1212 | 1212 | if not outgoing.missing: |
|
1213 | 1213 | scmutil.nochangesfound(ui, repo, not base and outgoing.excluded) |
|
1214 | 1214 | return 1 |
|
1215 | 1215 | |
|
1216 | 1216 | if cgversion == '01': #bundle1 |
|
1217 | 1217 | if bcompression is None: |
|
1218 | 1218 | bcompression = 'UN' |
|
1219 | 1219 | bversion = 'HG10' + bcompression |
|
1220 | 1220 | bcompression = None |
|
1221 | 1221 | elif cgversion in ('02', '03'): |
|
1222 | 1222 | bversion = 'HG20' |
|
1223 | 1223 | else: |
|
1224 | 1224 | raise error.ProgrammingError( |
|
1225 | 1225 | 'bundle: unexpected changegroup version %s' % cgversion) |
|
1226 | 1226 | |
|
1227 | 1227 | # TODO compression options should be derived from bundlespec parsing. |
|
1228 | 1228 | # This is a temporary hack to allow adjusting bundle compression |
|
1229 | 1229 | # level without a) formalizing the bundlespec changes to declare it |
|
1230 | 1230 | # b) introducing a command flag. |
|
1231 | 1231 | compopts = {} |
|
1232 | 1232 | complevel = ui.configint('experimental', 'bundlecomplevel') |
|
1233 | 1233 | if complevel is not None: |
|
1234 | 1234 | compopts['level'] = complevel |
|
1235 | 1235 | |
|
1236 | 1236 | |
|
1237 | 1237 | contentopts = {'cg.version': cgversion} |
|
1238 | 1238 | if repo.ui.configbool('experimental', 'stabilization.bundle-obsmarker'): |
|
1239 | 1239 | contentopts['obsolescence'] = True |
|
1240 | 1240 | if repo.ui.configbool('experimental', 'bundle-phases'): |
|
1241 | 1241 | contentopts['phases'] = True |
|
1242 | 1242 | bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing, |
|
1243 | 1243 | contentopts, compression=bcompression, |
|
1244 | 1244 | compopts=compopts) |
|
1245 | 1245 | |
|
1246 | 1246 | @command('cat', |
|
1247 | 1247 | [('o', 'output', '', |
|
1248 | 1248 | _('print output to file with formatted name'), _('FORMAT')), |
|
1249 | 1249 | ('r', 'rev', '', _('print the given revision'), _('REV')), |
|
1250 | 1250 | ('', 'decode', None, _('apply any matching decode filter')), |
|
1251 | 1251 | ] + walkopts + formatteropts, |
|
1252 | 1252 | _('[OPTION]... FILE...'), |
|
1253 | 1253 | inferrepo=True) |
|
1254 | 1254 | def cat(ui, repo, file1, *pats, **opts): |
|
1255 | 1255 | """output the current or given revision of files |
|
1256 | 1256 | |
|
1257 | 1257 | Print the specified files as they were at the given revision. If |
|
1258 | 1258 | no revision is given, the parent of the working directory is used. |
|
1259 | 1259 | |
|
1260 | 1260 | Output may be to a file, in which case the name of the file is |
|
1261 | 1261 | given using a format string. The formatting rules as follows: |
|
1262 | 1262 | |
|
1263 | 1263 | :``%%``: literal "%" character |
|
1264 | 1264 | :``%s``: basename of file being printed |
|
1265 | 1265 | :``%d``: dirname of file being printed, or '.' if in repository root |
|
1266 | 1266 | :``%p``: root-relative path name of file being printed |
|
1267 | 1267 | :``%H``: changeset hash (40 hexadecimal digits) |
|
1268 | 1268 | :``%R``: changeset revision number |
|
1269 | 1269 | :``%h``: short-form changeset hash (12 hexadecimal digits) |
|
1270 | 1270 | :``%r``: zero-padded changeset revision number |
|
1271 | 1271 | :``%b``: basename of the exporting repository |
|
1272 | 1272 | |
|
1273 | 1273 | Returns 0 on success. |
|
1274 | 1274 | """ |
|
1275 | 1275 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
1276 | 1276 | m = scmutil.match(ctx, (file1,) + pats, opts) |
|
1277 | 1277 | fntemplate = opts.pop('output', '') |
|
1278 | 1278 | if cmdutil.isstdiofilename(fntemplate): |
|
1279 | 1279 | fntemplate = '' |
|
1280 | 1280 | |
|
1281 | 1281 | if fntemplate: |
|
1282 | 1282 | fm = formatter.nullformatter(ui, 'cat') |
|
1283 | 1283 | else: |
|
1284 | 1284 | ui.pager('cat') |
|
1285 | 1285 | fm = ui.formatter('cat', opts) |
|
1286 | 1286 | with fm: |
|
1287 | 1287 | return cmdutil.cat(ui, repo, ctx, m, fm, fntemplate, '', **opts) |
|
1288 | 1288 | |
|
1289 | 1289 | @command('^clone', |
|
1290 | 1290 | [('U', 'noupdate', None, _('the clone will include an empty working ' |
|
1291 | 1291 | 'directory (only a repository)')), |
|
1292 | 1292 | ('u', 'updaterev', '', _('revision, tag, or branch to check out'), |
|
1293 | 1293 | _('REV')), |
|
1294 | 1294 | ('r', 'rev', [], _('include the specified changeset'), _('REV')), |
|
1295 | 1295 | ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')), |
|
1296 | 1296 | ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
1297 | ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')), | |
|
1297 | ('', 'uncompressed', None, | |
|
1298 | _('an alias to --stream (DEPRECATED)')), | |
|
1299 | ('', 'stream', None, | |
|
1300 | _('clone with minimal data processing')), | |
|
1298 | 1301 | ] + remoteopts, |
|
1299 | 1302 | _('[OPTION]... SOURCE [DEST]'), |
|
1300 | 1303 | norepo=True) |
|
1301 | 1304 | def clone(ui, source, dest=None, **opts): |
|
1302 | 1305 | """make a copy of an existing repository |
|
1303 | 1306 | |
|
1304 | 1307 | Create a copy of an existing repository in a new directory. |
|
1305 | 1308 | |
|
1306 | 1309 | If no destination directory name is specified, it defaults to the |
|
1307 | 1310 | basename of the source. |
|
1308 | 1311 | |
|
1309 | 1312 | The location of the source is added to the new repository's |
|
1310 | 1313 | ``.hg/hgrc`` file, as the default to be used for future pulls. |
|
1311 | 1314 | |
|
1312 | 1315 | Only local paths and ``ssh://`` URLs are supported as |
|
1313 | 1316 | destinations. For ``ssh://`` destinations, no working directory or |
|
1314 | 1317 | ``.hg/hgrc`` will be created on the remote side. |
|
1315 | 1318 | |
|
1316 | 1319 | If the source repository has a bookmark called '@' set, that |
|
1317 | 1320 | revision will be checked out in the new repository by default. |
|
1318 | 1321 | |
|
1319 | 1322 | To check out a particular version, use -u/--update, or |
|
1320 | 1323 | -U/--noupdate to create a clone with no working directory. |
|
1321 | 1324 | |
|
1322 | 1325 | To pull only a subset of changesets, specify one or more revisions |
|
1323 | 1326 | identifiers with -r/--rev or branches with -b/--branch. The |
|
1324 | 1327 | resulting clone will contain only the specified changesets and |
|
1325 | 1328 | their ancestors. These options (or 'clone src#rev dest') imply |
|
1326 | 1329 | --pull, even for local source repositories. |
|
1327 | 1330 | |
|
1331 | In normal clone mode, the remote normalizes repository data into a common | |
|
1332 | exchange format and the receiving end translates this data into its local | |
|
1333 | storage format. --stream activates a different clone mode that essentially | |
|
1334 | copies repository files from the remote with minimal data processing. This | |
|
1335 | significantly reduces the CPU cost of a clone both remotely and locally. | |
|
1336 | However, it often increases the transferred data size by 30-40%. This can | |
|
1337 | result in substantially faster clones where I/O throughput is plentiful, | |
|
1338 | especially for larger repositories. A side-effect of --stream clones is | |
|
1339 | that storage settings and requirements on the remote are applied locally: | |
|
1340 | a modern client may inherit legacy or inefficient storage used by the | |
|
1341 | remote or a legacy Mercurial client may not be able to clone from a | |
|
1342 | modern Mercurial remote. | |
|
1343 | ||
|
1328 | 1344 | .. note:: |
|
1329 | 1345 | |
|
1330 | 1346 | Specifying a tag will include the tagged changeset but not the |
|
1331 | 1347 | changeset containing the tag. |
|
1332 | 1348 | |
|
1333 | 1349 | .. container:: verbose |
|
1334 | 1350 | |
|
1335 | 1351 | For efficiency, hardlinks are used for cloning whenever the |
|
1336 | 1352 | source and destination are on the same filesystem (note this |
|
1337 | 1353 | applies only to the repository data, not to the working |
|
1338 | 1354 | directory). Some filesystems, such as AFS, implement hardlinking |
|
1339 | 1355 | incorrectly, but do not report errors. In these cases, use the |
|
1340 | 1356 | --pull option to avoid hardlinking. |
|
1341 | 1357 | |
|
1342 | 1358 | Mercurial will update the working directory to the first applicable |
|
1343 | 1359 | revision from this list: |
|
1344 | 1360 | |
|
1345 | 1361 | a) null if -U or the source repository has no changesets |
|
1346 | 1362 | b) if -u . and the source repository is local, the first parent of |
|
1347 | 1363 | the source repository's working directory |
|
1348 | 1364 | c) the changeset specified with -u (if a branch name, this means the |
|
1349 | 1365 | latest head of that branch) |
|
1350 | 1366 | d) the changeset specified with -r |
|
1351 | 1367 | e) the tipmost head specified with -b |
|
1352 | 1368 | f) the tipmost head specified with the url#branch source syntax |
|
1353 | 1369 | g) the revision marked with the '@' bookmark, if present |
|
1354 | 1370 | h) the tipmost head of the default branch |
|
1355 | 1371 | i) tip |
|
1356 | 1372 | |
|
1357 | 1373 | When cloning from servers that support it, Mercurial may fetch |
|
1358 | 1374 | pre-generated data from a server-advertised URL. When this is done, |
|
1359 | 1375 | hooks operating on incoming changesets and changegroups may fire twice, |
|
1360 | 1376 | once for the bundle fetched from the URL and another for any additional |
|
1361 | 1377 | data not fetched from this URL. In addition, if an error occurs, the |
|
1362 | 1378 | repository may be rolled back to a partial clone. This behavior may |
|
1363 | 1379 | change in future releases. See :hg:`help -e clonebundles` for more. |
|
1364 | 1380 | |
|
1365 | 1381 | Examples: |
|
1366 | 1382 | |
|
1367 | 1383 | - clone a remote repository to a new directory named hg/:: |
|
1368 | 1384 | |
|
1369 | 1385 | hg clone https://www.mercurial-scm.org/repo/hg/ |
|
1370 | 1386 | |
|
1371 | 1387 | - create a lightweight local clone:: |
|
1372 | 1388 | |
|
1373 | 1389 | hg clone project/ project-feature/ |
|
1374 | 1390 | |
|
1375 | 1391 | - clone from an absolute path on an ssh server (note double-slash):: |
|
1376 | 1392 | |
|
1377 | 1393 | hg clone ssh://user@server//home/projects/alpha/ |
|
1378 | 1394 | |
|
1379 |
- do a |
|
|
1380 | specified version:: | |
|
1381 | ||
|
1382 | hg clone --uncompressed http://server/repo -u 1.5 | |
|
1395 | - do a streaming clone while checking out a specified version:: | |
|
1396 | ||
|
1397 | hg clone --stream http://server/repo -u 1.5 | |
|
1383 | 1398 | |
|
1384 | 1399 | - create a repository without changesets after a particular revision:: |
|
1385 | 1400 | |
|
1386 | 1401 | hg clone -r 04e544 experimental/ good/ |
|
1387 | 1402 | |
|
1388 | 1403 | - clone (and track) a particular named branch:: |
|
1389 | 1404 | |
|
1390 | 1405 | hg clone https://www.mercurial-scm.org/repo/hg/#stable |
|
1391 | 1406 | |
|
1392 | 1407 | See :hg:`help urls` for details on specifying URLs. |
|
1393 | 1408 | |
|
1394 | 1409 | Returns 0 on success. |
|
1395 | 1410 | """ |
|
1396 | 1411 | opts = pycompat.byteskwargs(opts) |
|
1397 | 1412 | if opts.get('noupdate') and opts.get('updaterev'): |
|
1398 | 1413 | raise error.Abort(_("cannot specify both --noupdate and --updaterev")) |
|
1399 | 1414 | |
|
1400 | 1415 | r = hg.clone(ui, opts, source, dest, |
|
1401 | 1416 | pull=opts.get('pull'), |
|
1402 | stream=opts.get('uncompressed'), | |
|
1417 | stream=opts.get('stream') or opts.get('uncompressed'), | |
|
1403 | 1418 | rev=opts.get('rev'), |
|
1404 | 1419 | update=opts.get('updaterev') or not opts.get('noupdate'), |
|
1405 | 1420 | branch=opts.get('branch'), |
|
1406 | 1421 | shareopts=opts.get('shareopts')) |
|
1407 | 1422 | |
|
1408 | 1423 | return r is None |
|
1409 | 1424 | |
|
1410 | 1425 | @command('^commit|ci', |
|
1411 | 1426 | [('A', 'addremove', None, |
|
1412 | 1427 | _('mark new/missing files as added/removed before committing')), |
|
1413 | 1428 | ('', 'close-branch', None, |
|
1414 | 1429 | _('mark a branch head as closed')), |
|
1415 | 1430 | ('', 'amend', None, _('amend the parent of the working directory')), |
|
1416 | 1431 | ('s', 'secret', None, _('use the secret phase for committing')), |
|
1417 | 1432 | ('e', 'edit', None, _('invoke editor on commit messages')), |
|
1418 | 1433 | ('i', 'interactive', None, _('use interactive mode')), |
|
1419 | 1434 | ] + walkopts + commitopts + commitopts2 + subrepoopts, |
|
1420 | 1435 | _('[OPTION]... [FILE]...'), |
|
1421 | 1436 | inferrepo=True) |
|
1422 | 1437 | def commit(ui, repo, *pats, **opts): |
|
1423 | 1438 | """commit the specified files or all outstanding changes |
|
1424 | 1439 | |
|
1425 | 1440 | Commit changes to the given files into the repository. Unlike a |
|
1426 | 1441 | centralized SCM, this operation is a local operation. See |
|
1427 | 1442 | :hg:`push` for a way to actively distribute your changes. |
|
1428 | 1443 | |
|
1429 | 1444 | If a list of files is omitted, all changes reported by :hg:`status` |
|
1430 | 1445 | will be committed. |
|
1431 | 1446 | |
|
1432 | 1447 | If you are committing the result of a merge, do not provide any |
|
1433 | 1448 | filenames or -I/-X filters. |
|
1434 | 1449 | |
|
1435 | 1450 | If no commit message is specified, Mercurial starts your |
|
1436 | 1451 | configured editor where you can enter a message. In case your |
|
1437 | 1452 | commit fails, you will find a backup of your message in |
|
1438 | 1453 | ``.hg/last-message.txt``. |
|
1439 | 1454 | |
|
1440 | 1455 | The --close-branch flag can be used to mark the current branch |
|
1441 | 1456 | head closed. When all heads of a branch are closed, the branch |
|
1442 | 1457 | will be considered closed and no longer listed. |
|
1443 | 1458 | |
|
1444 | 1459 | The --amend flag can be used to amend the parent of the |
|
1445 | 1460 | working directory with a new commit that contains the changes |
|
1446 | 1461 | in the parent in addition to those currently reported by :hg:`status`, |
|
1447 | 1462 | if there are any. The old commit is stored in a backup bundle in |
|
1448 | 1463 | ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle` |
|
1449 | 1464 | on how to restore it). |
|
1450 | 1465 | |
|
1451 | 1466 | Message, user and date are taken from the amended commit unless |
|
1452 | 1467 | specified. When a message isn't specified on the command line, |
|
1453 | 1468 | the editor will open with the message of the amended commit. |
|
1454 | 1469 | |
|
1455 | 1470 | It is not possible to amend public changesets (see :hg:`help phases`) |
|
1456 | 1471 | or changesets that have children. |
|
1457 | 1472 | |
|
1458 | 1473 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
1459 | 1474 | |
|
1460 | 1475 | Returns 0 on success, 1 if nothing changed. |
|
1461 | 1476 | |
|
1462 | 1477 | .. container:: verbose |
|
1463 | 1478 | |
|
1464 | 1479 | Examples: |
|
1465 | 1480 | |
|
1466 | 1481 | - commit all files ending in .py:: |
|
1467 | 1482 | |
|
1468 | 1483 | hg commit --include "set:**.py" |
|
1469 | 1484 | |
|
1470 | 1485 | - commit all non-binary files:: |
|
1471 | 1486 | |
|
1472 | 1487 | hg commit --exclude "set:binary()" |
|
1473 | 1488 | |
|
1474 | 1489 | - amend the current commit and set the date to now:: |
|
1475 | 1490 | |
|
1476 | 1491 | hg commit --amend --date now |
|
1477 | 1492 | """ |
|
1478 | 1493 | wlock = lock = None |
|
1479 | 1494 | try: |
|
1480 | 1495 | wlock = repo.wlock() |
|
1481 | 1496 | lock = repo.lock() |
|
1482 | 1497 | return _docommit(ui, repo, *pats, **opts) |
|
1483 | 1498 | finally: |
|
1484 | 1499 | release(lock, wlock) |
|
1485 | 1500 | |
|
1486 | 1501 | def _docommit(ui, repo, *pats, **opts): |
|
1487 | 1502 | if opts.get(r'interactive'): |
|
1488 | 1503 | opts.pop(r'interactive') |
|
1489 | 1504 | ret = cmdutil.dorecord(ui, repo, commit, None, False, |
|
1490 | 1505 | cmdutil.recordfilter, *pats, |
|
1491 | 1506 | **opts) |
|
1492 | 1507 | # ret can be 0 (no changes to record) or the value returned by |
|
1493 | 1508 | # commit(), 1 if nothing changed or None on success. |
|
1494 | 1509 | return 1 if ret == 0 else ret |
|
1495 | 1510 | |
|
1496 | 1511 | opts = pycompat.byteskwargs(opts) |
|
1497 | 1512 | if opts.get('subrepos'): |
|
1498 | 1513 | if opts.get('amend'): |
|
1499 | 1514 | raise error.Abort(_('cannot amend with --subrepos')) |
|
1500 | 1515 | # Let --subrepos on the command line override config setting. |
|
1501 | 1516 | ui.setconfig('ui', 'commitsubrepos', True, 'commit') |
|
1502 | 1517 | |
|
1503 | 1518 | cmdutil.checkunfinished(repo, commit=True) |
|
1504 | 1519 | |
|
1505 | 1520 | branch = repo[None].branch() |
|
1506 | 1521 | bheads = repo.branchheads(branch) |
|
1507 | 1522 | |
|
1508 | 1523 | extra = {} |
|
1509 | 1524 | if opts.get('close_branch'): |
|
1510 | 1525 | extra['close'] = 1 |
|
1511 | 1526 | |
|
1512 | 1527 | if not bheads: |
|
1513 | 1528 | raise error.Abort(_('can only close branch heads')) |
|
1514 | 1529 | elif opts.get('amend'): |
|
1515 | 1530 | if repo[None].parents()[0].p1().branch() != branch and \ |
|
1516 | 1531 | repo[None].parents()[0].p2().branch() != branch: |
|
1517 | 1532 | raise error.Abort(_('can only close branch heads')) |
|
1518 | 1533 | |
|
1519 | 1534 | if opts.get('amend'): |
|
1520 | 1535 | if ui.configbool('ui', 'commitsubrepos'): |
|
1521 | 1536 | raise error.Abort(_('cannot amend with ui.commitsubrepos enabled')) |
|
1522 | 1537 | |
|
1523 | 1538 | old = repo['.'] |
|
1524 | 1539 | if not old.mutable(): |
|
1525 | 1540 | raise error.Abort(_('cannot amend public changesets')) |
|
1526 | 1541 | if len(repo[None].parents()) > 1: |
|
1527 | 1542 | raise error.Abort(_('cannot amend while merging')) |
|
1528 | 1543 | allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
|
1529 | 1544 | if not allowunstable and old.children(): |
|
1530 | 1545 | raise error.Abort(_('cannot amend changeset with children')) |
|
1531 | 1546 | |
|
1532 | 1547 | # Currently histedit gets confused if an amend happens while histedit |
|
1533 | 1548 | # is in progress. Since we have a checkunfinished command, we are |
|
1534 | 1549 | # temporarily honoring it. |
|
1535 | 1550 | # |
|
1536 | 1551 | # Note: eventually this guard will be removed. Please do not expect |
|
1537 | 1552 | # this behavior to remain. |
|
1538 | 1553 | if not obsolete.isenabled(repo, obsolete.createmarkersopt): |
|
1539 | 1554 | cmdutil.checkunfinished(repo) |
|
1540 | 1555 | |
|
1541 | 1556 | node = cmdutil.amend(ui, repo, old, extra, pats, opts) |
|
1542 | 1557 | if node == old.node(): |
|
1543 | 1558 | ui.status(_("nothing changed\n")) |
|
1544 | 1559 | return 1 |
|
1545 | 1560 | else: |
|
1546 | 1561 | def commitfunc(ui, repo, message, match, opts): |
|
1547 | 1562 | overrides = {} |
|
1548 | 1563 | if opts.get('secret'): |
|
1549 | 1564 | overrides[('phases', 'new-commit')] = 'secret' |
|
1550 | 1565 | |
|
1551 | 1566 | baseui = repo.baseui |
|
1552 | 1567 | with baseui.configoverride(overrides, 'commit'): |
|
1553 | 1568 | with ui.configoverride(overrides, 'commit'): |
|
1554 | 1569 | editform = cmdutil.mergeeditform(repo[None], |
|
1555 | 1570 | 'commit.normal') |
|
1556 | 1571 | editor = cmdutil.getcommiteditor( |
|
1557 | 1572 | editform=editform, **pycompat.strkwargs(opts)) |
|
1558 | 1573 | return repo.commit(message, |
|
1559 | 1574 | opts.get('user'), |
|
1560 | 1575 | opts.get('date'), |
|
1561 | 1576 | match, |
|
1562 | 1577 | editor=editor, |
|
1563 | 1578 | extra=extra) |
|
1564 | 1579 | |
|
1565 | 1580 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
|
1566 | 1581 | |
|
1567 | 1582 | if not node: |
|
1568 | 1583 | stat = cmdutil.postcommitstatus(repo, pats, opts) |
|
1569 | 1584 | if stat[3]: |
|
1570 | 1585 | ui.status(_("nothing changed (%d missing files, see " |
|
1571 | 1586 | "'hg status')\n") % len(stat[3])) |
|
1572 | 1587 | else: |
|
1573 | 1588 | ui.status(_("nothing changed\n")) |
|
1574 | 1589 | return 1 |
|
1575 | 1590 | |
|
1576 | 1591 | cmdutil.commitstatus(repo, node, branch, bheads, opts) |
|
1577 | 1592 | |
|
1578 | 1593 | @command('config|showconfig|debugconfig', |
|
1579 | 1594 | [('u', 'untrusted', None, _('show untrusted configuration options')), |
|
1580 | 1595 | ('e', 'edit', None, _('edit user config')), |
|
1581 | 1596 | ('l', 'local', None, _('edit repository config')), |
|
1582 | 1597 | ('g', 'global', None, _('edit global config'))] + formatteropts, |
|
1583 | 1598 | _('[-u] [NAME]...'), |
|
1584 | 1599 | optionalrepo=True) |
|
1585 | 1600 | def config(ui, repo, *values, **opts): |
|
1586 | 1601 | """show combined config settings from all hgrc files |
|
1587 | 1602 | |
|
1588 | 1603 | With no arguments, print names and values of all config items. |
|
1589 | 1604 | |
|
1590 | 1605 | With one argument of the form section.name, print just the value |
|
1591 | 1606 | of that config item. |
|
1592 | 1607 | |
|
1593 | 1608 | With multiple arguments, print names and values of all config |
|
1594 | 1609 | items with matching section names. |
|
1595 | 1610 | |
|
1596 | 1611 | With --edit, start an editor on the user-level config file. With |
|
1597 | 1612 | --global, edit the system-wide config file. With --local, edit the |
|
1598 | 1613 | repository-level config file. |
|
1599 | 1614 | |
|
1600 | 1615 | With --debug, the source (filename and line number) is printed |
|
1601 | 1616 | for each config item. |
|
1602 | 1617 | |
|
1603 | 1618 | See :hg:`help config` for more information about config files. |
|
1604 | 1619 | |
|
1605 | 1620 | Returns 0 on success, 1 if NAME does not exist. |
|
1606 | 1621 | |
|
1607 | 1622 | """ |
|
1608 | 1623 | |
|
1609 | 1624 | opts = pycompat.byteskwargs(opts) |
|
1610 | 1625 | if opts.get('edit') or opts.get('local') or opts.get('global'): |
|
1611 | 1626 | if opts.get('local') and opts.get('global'): |
|
1612 | 1627 | raise error.Abort(_("can't use --local and --global together")) |
|
1613 | 1628 | |
|
1614 | 1629 | if opts.get('local'): |
|
1615 | 1630 | if not repo: |
|
1616 | 1631 | raise error.Abort(_("can't use --local outside a repository")) |
|
1617 | 1632 | paths = [repo.vfs.join('hgrc')] |
|
1618 | 1633 | elif opts.get('global'): |
|
1619 | 1634 | paths = rcutil.systemrcpath() |
|
1620 | 1635 | else: |
|
1621 | 1636 | paths = rcutil.userrcpath() |
|
1622 | 1637 | |
|
1623 | 1638 | for f in paths: |
|
1624 | 1639 | if os.path.exists(f): |
|
1625 | 1640 | break |
|
1626 | 1641 | else: |
|
1627 | 1642 | if opts.get('global'): |
|
1628 | 1643 | samplehgrc = uimod.samplehgrcs['global'] |
|
1629 | 1644 | elif opts.get('local'): |
|
1630 | 1645 | samplehgrc = uimod.samplehgrcs['local'] |
|
1631 | 1646 | else: |
|
1632 | 1647 | samplehgrc = uimod.samplehgrcs['user'] |
|
1633 | 1648 | |
|
1634 | 1649 | f = paths[0] |
|
1635 | 1650 | fp = open(f, "wb") |
|
1636 | 1651 | fp.write(util.tonativeeol(samplehgrc)) |
|
1637 | 1652 | fp.close() |
|
1638 | 1653 | |
|
1639 | 1654 | editor = ui.geteditor() |
|
1640 | 1655 | ui.system("%s \"%s\"" % (editor, f), |
|
1641 | 1656 | onerr=error.Abort, errprefix=_("edit failed"), |
|
1642 | 1657 | blockedtag='config_edit') |
|
1643 | 1658 | return |
|
1644 | 1659 | ui.pager('config') |
|
1645 | 1660 | fm = ui.formatter('config', opts) |
|
1646 | 1661 | for t, f in rcutil.rccomponents(): |
|
1647 | 1662 | if t == 'path': |
|
1648 | 1663 | ui.debug('read config from: %s\n' % f) |
|
1649 | 1664 | elif t == 'items': |
|
1650 | 1665 | for section, name, value, source in f: |
|
1651 | 1666 | ui.debug('set config by: %s\n' % source) |
|
1652 | 1667 | else: |
|
1653 | 1668 | raise error.ProgrammingError('unknown rctype: %s' % t) |
|
1654 | 1669 | untrusted = bool(opts.get('untrusted')) |
|
1655 | 1670 | if values: |
|
1656 | 1671 | sections = [v for v in values if '.' not in v] |
|
1657 | 1672 | items = [v for v in values if '.' in v] |
|
1658 | 1673 | if len(items) > 1 or items and sections: |
|
1659 | 1674 | raise error.Abort(_('only one config item permitted')) |
|
1660 | 1675 | matched = False |
|
1661 | 1676 | for section, name, value in ui.walkconfig(untrusted=untrusted): |
|
1662 | 1677 | source = ui.configsource(section, name, untrusted) |
|
1663 | 1678 | value = pycompat.bytestr(value) |
|
1664 | 1679 | if fm.isplain(): |
|
1665 | 1680 | source = source or 'none' |
|
1666 | 1681 | value = value.replace('\n', '\\n') |
|
1667 | 1682 | entryname = section + '.' + name |
|
1668 | 1683 | if values: |
|
1669 | 1684 | for v in values: |
|
1670 | 1685 | if v == section: |
|
1671 | 1686 | fm.startitem() |
|
1672 | 1687 | fm.condwrite(ui.debugflag, 'source', '%s: ', source) |
|
1673 | 1688 | fm.write('name value', '%s=%s\n', entryname, value) |
|
1674 | 1689 | matched = True |
|
1675 | 1690 | elif v == entryname: |
|
1676 | 1691 | fm.startitem() |
|
1677 | 1692 | fm.condwrite(ui.debugflag, 'source', '%s: ', source) |
|
1678 | 1693 | fm.write('value', '%s\n', value) |
|
1679 | 1694 | fm.data(name=entryname) |
|
1680 | 1695 | matched = True |
|
1681 | 1696 | else: |
|
1682 | 1697 | fm.startitem() |
|
1683 | 1698 | fm.condwrite(ui.debugflag, 'source', '%s: ', source) |
|
1684 | 1699 | fm.write('name value', '%s=%s\n', entryname, value) |
|
1685 | 1700 | matched = True |
|
1686 | 1701 | fm.end() |
|
1687 | 1702 | if matched: |
|
1688 | 1703 | return 0 |
|
1689 | 1704 | return 1 |
|
1690 | 1705 | |
|
1691 | 1706 | @command('copy|cp', |
|
1692 | 1707 | [('A', 'after', None, _('record a copy that has already occurred')), |
|
1693 | 1708 | ('f', 'force', None, _('forcibly copy over an existing managed file')), |
|
1694 | 1709 | ] + walkopts + dryrunopts, |
|
1695 | 1710 | _('[OPTION]... [SOURCE]... DEST')) |
|
1696 | 1711 | def copy(ui, repo, *pats, **opts): |
|
1697 | 1712 | """mark files as copied for the next commit |
|
1698 | 1713 | |
|
1699 | 1714 | Mark dest as having copies of source files. If dest is a |
|
1700 | 1715 | directory, copies are put in that directory. If dest is a file, |
|
1701 | 1716 | the source must be a single file. |
|
1702 | 1717 | |
|
1703 | 1718 | By default, this command copies the contents of files as they |
|
1704 | 1719 | exist in the working directory. If invoked with -A/--after, the |
|
1705 | 1720 | operation is recorded, but no copying is performed. |
|
1706 | 1721 | |
|
1707 | 1722 | This command takes effect with the next commit. To undo a copy |
|
1708 | 1723 | before that, see :hg:`revert`. |
|
1709 | 1724 | |
|
1710 | 1725 | Returns 0 on success, 1 if errors are encountered. |
|
1711 | 1726 | """ |
|
1712 | 1727 | opts = pycompat.byteskwargs(opts) |
|
1713 | 1728 | with repo.wlock(False): |
|
1714 | 1729 | return cmdutil.copy(ui, repo, pats, opts) |
|
1715 | 1730 | |
|
1716 | 1731 | @command('debugcommands', [], _('[COMMAND]'), norepo=True) |
|
1717 | 1732 | def debugcommands(ui, cmd='', *args): |
|
1718 | 1733 | """list all available commands and options""" |
|
1719 | 1734 | for cmd, vals in sorted(table.iteritems()): |
|
1720 | 1735 | cmd = cmd.split('|')[0].strip('^') |
|
1721 | 1736 | opts = ', '.join([i[1] for i in vals[1]]) |
|
1722 | 1737 | ui.write('%s: %s\n' % (cmd, opts)) |
|
1723 | 1738 | |
|
1724 | 1739 | @command('debugcomplete', |
|
1725 | 1740 | [('o', 'options', None, _('show the command options'))], |
|
1726 | 1741 | _('[-o] CMD'), |
|
1727 | 1742 | norepo=True) |
|
1728 | 1743 | def debugcomplete(ui, cmd='', **opts): |
|
1729 | 1744 | """returns the completion list associated with the given command""" |
|
1730 | 1745 | |
|
1731 | 1746 | if opts.get('options'): |
|
1732 | 1747 | options = [] |
|
1733 | 1748 | otables = [globalopts] |
|
1734 | 1749 | if cmd: |
|
1735 | 1750 | aliases, entry = cmdutil.findcmd(cmd, table, False) |
|
1736 | 1751 | otables.append(entry[1]) |
|
1737 | 1752 | for t in otables: |
|
1738 | 1753 | for o in t: |
|
1739 | 1754 | if "(DEPRECATED)" in o[3]: |
|
1740 | 1755 | continue |
|
1741 | 1756 | if o[0]: |
|
1742 | 1757 | options.append('-%s' % o[0]) |
|
1743 | 1758 | options.append('--%s' % o[1]) |
|
1744 | 1759 | ui.write("%s\n" % "\n".join(options)) |
|
1745 | 1760 | return |
|
1746 | 1761 | |
|
1747 | 1762 | cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table) |
|
1748 | 1763 | if ui.verbose: |
|
1749 | 1764 | cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
|
1750 | 1765 | ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
|
1751 | 1766 | |
|
1752 | 1767 | @command('^diff', |
|
1753 | 1768 | [('r', 'rev', [], _('revision'), _('REV')), |
|
1754 | 1769 | ('c', 'change', '', _('change made by revision'), _('REV')) |
|
1755 | 1770 | ] + diffopts + diffopts2 + walkopts + subrepoopts, |
|
1756 | 1771 | _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'), |
|
1757 | 1772 | inferrepo=True) |
|
1758 | 1773 | def diff(ui, repo, *pats, **opts): |
|
1759 | 1774 | """diff repository (or selected files) |
|
1760 | 1775 | |
|
1761 | 1776 | Show differences between revisions for the specified files. |
|
1762 | 1777 | |
|
1763 | 1778 | Differences between files are shown using the unified diff format. |
|
1764 | 1779 | |
|
1765 | 1780 | .. note:: |
|
1766 | 1781 | |
|
1767 | 1782 | :hg:`diff` may generate unexpected results for merges, as it will |
|
1768 | 1783 | default to comparing against the working directory's first |
|
1769 | 1784 | parent changeset if no revisions are specified. |
|
1770 | 1785 | |
|
1771 | 1786 | When two revision arguments are given, then changes are shown |
|
1772 | 1787 | between those revisions. If only one revision is specified then |
|
1773 | 1788 | that revision is compared to the working directory, and, when no |
|
1774 | 1789 | revisions are specified, the working directory files are compared |
|
1775 | 1790 | to its first parent. |
|
1776 | 1791 | |
|
1777 | 1792 | Alternatively you can specify -c/--change with a revision to see |
|
1778 | 1793 | the changes in that changeset relative to its first parent. |
|
1779 | 1794 | |
|
1780 | 1795 | Without the -a/--text option, diff will avoid generating diffs of |
|
1781 | 1796 | files it detects as binary. With -a, diff will generate a diff |
|
1782 | 1797 | anyway, probably with undesirable results. |
|
1783 | 1798 | |
|
1784 | 1799 | Use the -g/--git option to generate diffs in the git extended diff |
|
1785 | 1800 | format. For more information, read :hg:`help diffs`. |
|
1786 | 1801 | |
|
1787 | 1802 | .. container:: verbose |
|
1788 | 1803 | |
|
1789 | 1804 | Examples: |
|
1790 | 1805 | |
|
1791 | 1806 | - compare a file in the current working directory to its parent:: |
|
1792 | 1807 | |
|
1793 | 1808 | hg diff foo.c |
|
1794 | 1809 | |
|
1795 | 1810 | - compare two historical versions of a directory, with rename info:: |
|
1796 | 1811 | |
|
1797 | 1812 | hg diff --git -r 1.0:1.2 lib/ |
|
1798 | 1813 | |
|
1799 | 1814 | - get change stats relative to the last change on some date:: |
|
1800 | 1815 | |
|
1801 | 1816 | hg diff --stat -r "date('may 2')" |
|
1802 | 1817 | |
|
1803 | 1818 | - diff all newly-added files that contain a keyword:: |
|
1804 | 1819 | |
|
1805 | 1820 | hg diff "set:added() and grep(GNU)" |
|
1806 | 1821 | |
|
1807 | 1822 | - compare a revision and its parents:: |
|
1808 | 1823 | |
|
1809 | 1824 | hg diff -c 9353 # compare against first parent |
|
1810 | 1825 | hg diff -r 9353^:9353 # same using revset syntax |
|
1811 | 1826 | hg diff -r 9353^2:9353 # compare against the second parent |
|
1812 | 1827 | |
|
1813 | 1828 | Returns 0 on success. |
|
1814 | 1829 | """ |
|
1815 | 1830 | |
|
1816 | 1831 | opts = pycompat.byteskwargs(opts) |
|
1817 | 1832 | revs = opts.get('rev') |
|
1818 | 1833 | change = opts.get('change') |
|
1819 | 1834 | stat = opts.get('stat') |
|
1820 | 1835 | reverse = opts.get('reverse') |
|
1821 | 1836 | |
|
1822 | 1837 | if revs and change: |
|
1823 | 1838 | msg = _('cannot specify --rev and --change at the same time') |
|
1824 | 1839 | raise error.Abort(msg) |
|
1825 | 1840 | elif change: |
|
1826 | 1841 | node2 = scmutil.revsingle(repo, change, None).node() |
|
1827 | 1842 | node1 = repo[node2].p1().node() |
|
1828 | 1843 | else: |
|
1829 | 1844 | node1, node2 = scmutil.revpair(repo, revs) |
|
1830 | 1845 | |
|
1831 | 1846 | if reverse: |
|
1832 | 1847 | node1, node2 = node2, node1 |
|
1833 | 1848 | |
|
1834 | 1849 | diffopts = patch.diffallopts(ui, opts) |
|
1835 | 1850 | m = scmutil.match(repo[node2], pats, opts) |
|
1836 | 1851 | ui.pager('diff') |
|
1837 | 1852 | cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, |
|
1838 | 1853 | listsubrepos=opts.get('subrepos'), |
|
1839 | 1854 | root=opts.get('root')) |
|
1840 | 1855 | |
|
1841 | 1856 | @command('^export', |
|
1842 | 1857 | [('o', 'output', '', |
|
1843 | 1858 | _('print output to file with formatted name'), _('FORMAT')), |
|
1844 | 1859 | ('', 'switch-parent', None, _('diff against the second parent')), |
|
1845 | 1860 | ('r', 'rev', [], _('revisions to export'), _('REV')), |
|
1846 | 1861 | ] + diffopts, |
|
1847 | 1862 | _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...')) |
|
1848 | 1863 | def export(ui, repo, *changesets, **opts): |
|
1849 | 1864 | """dump the header and diffs for one or more changesets |
|
1850 | 1865 | |
|
1851 | 1866 | Print the changeset header and diffs for one or more revisions. |
|
1852 | 1867 | If no revision is given, the parent of the working directory is used. |
|
1853 | 1868 | |
|
1854 | 1869 | The information shown in the changeset header is: author, date, |
|
1855 | 1870 | branch name (if non-default), changeset hash, parent(s) and commit |
|
1856 | 1871 | comment. |
|
1857 | 1872 | |
|
1858 | 1873 | .. note:: |
|
1859 | 1874 | |
|
1860 | 1875 | :hg:`export` may generate unexpected diff output for merge |
|
1861 | 1876 | changesets, as it will compare the merge changeset against its |
|
1862 | 1877 | first parent only. |
|
1863 | 1878 | |
|
1864 | 1879 | Output may be to a file, in which case the name of the file is |
|
1865 | 1880 | given using a format string. The formatting rules are as follows: |
|
1866 | 1881 | |
|
1867 | 1882 | :``%%``: literal "%" character |
|
1868 | 1883 | :``%H``: changeset hash (40 hexadecimal digits) |
|
1869 | 1884 | :``%N``: number of patches being generated |
|
1870 | 1885 | :``%R``: changeset revision number |
|
1871 | 1886 | :``%b``: basename of the exporting repository |
|
1872 | 1887 | :``%h``: short-form changeset hash (12 hexadecimal digits) |
|
1873 | 1888 | :``%m``: first line of the commit message (only alphanumeric characters) |
|
1874 | 1889 | :``%n``: zero-padded sequence number, starting at 1 |
|
1875 | 1890 | :``%r``: zero-padded changeset revision number |
|
1876 | 1891 | |
|
1877 | 1892 | Without the -a/--text option, export will avoid generating diffs |
|
1878 | 1893 | of files it detects as binary. With -a, export will generate a |
|
1879 | 1894 | diff anyway, probably with undesirable results. |
|
1880 | 1895 | |
|
1881 | 1896 | Use the -g/--git option to generate diffs in the git extended diff |
|
1882 | 1897 | format. See :hg:`help diffs` for more information. |
|
1883 | 1898 | |
|
1884 | 1899 | With the --switch-parent option, the diff will be against the |
|
1885 | 1900 | second parent. It can be useful to review a merge. |
|
1886 | 1901 | |
|
1887 | 1902 | .. container:: verbose |
|
1888 | 1903 | |
|
1889 | 1904 | Examples: |
|
1890 | 1905 | |
|
1891 | 1906 | - use export and import to transplant a bugfix to the current |
|
1892 | 1907 | branch:: |
|
1893 | 1908 | |
|
1894 | 1909 | hg export -r 9353 | hg import - |
|
1895 | 1910 | |
|
1896 | 1911 | - export all the changesets between two revisions to a file with |
|
1897 | 1912 | rename information:: |
|
1898 | 1913 | |
|
1899 | 1914 | hg export --git -r 123:150 > changes.txt |
|
1900 | 1915 | |
|
1901 | 1916 | - split outgoing changes into a series of patches with |
|
1902 | 1917 | descriptive names:: |
|
1903 | 1918 | |
|
1904 | 1919 | hg export -r "outgoing()" -o "%n-%m.patch" |
|
1905 | 1920 | |
|
1906 | 1921 | Returns 0 on success. |
|
1907 | 1922 | """ |
|
1908 | 1923 | opts = pycompat.byteskwargs(opts) |
|
1909 | 1924 | changesets += tuple(opts.get('rev', [])) |
|
1910 | 1925 | if not changesets: |
|
1911 | 1926 | changesets = ['.'] |
|
1912 | 1927 | revs = scmutil.revrange(repo, changesets) |
|
1913 | 1928 | if not revs: |
|
1914 | 1929 | raise error.Abort(_("export requires at least one changeset")) |
|
1915 | 1930 | if len(revs) > 1: |
|
1916 | 1931 | ui.note(_('exporting patches:\n')) |
|
1917 | 1932 | else: |
|
1918 | 1933 | ui.note(_('exporting patch:\n')) |
|
1919 | 1934 | ui.pager('export') |
|
1920 | 1935 | cmdutil.export(repo, revs, fntemplate=opts.get('output'), |
|
1921 | 1936 | switch_parent=opts.get('switch_parent'), |
|
1922 | 1937 | opts=patch.diffallopts(ui, opts)) |
|
1923 | 1938 | |
|
1924 | 1939 | @command('files', |
|
1925 | 1940 | [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), |
|
1926 | 1941 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
|
1927 | 1942 | ] + walkopts + formatteropts + subrepoopts, |
|
1928 | 1943 | _('[OPTION]... [FILE]...')) |
|
1929 | 1944 | def files(ui, repo, *pats, **opts): |
|
1930 | 1945 | """list tracked files |
|
1931 | 1946 | |
|
1932 | 1947 | Print files under Mercurial control in the working directory or |
|
1933 | 1948 | specified revision for given files (excluding removed files). |
|
1934 | 1949 | Files can be specified as filenames or filesets. |
|
1935 | 1950 | |
|
1936 | 1951 | If no files are given to match, this command prints the names |
|
1937 | 1952 | of all files under Mercurial control. |
|
1938 | 1953 | |
|
1939 | 1954 | .. container:: verbose |
|
1940 | 1955 | |
|
1941 | 1956 | Examples: |
|
1942 | 1957 | |
|
1943 | 1958 | - list all files under the current directory:: |
|
1944 | 1959 | |
|
1945 | 1960 | hg files . |
|
1946 | 1961 | |
|
1947 | 1962 | - shows sizes and flags for current revision:: |
|
1948 | 1963 | |
|
1949 | 1964 | hg files -vr . |
|
1950 | 1965 | |
|
1951 | 1966 | - list all files named README:: |
|
1952 | 1967 | |
|
1953 | 1968 | hg files -I "**/README" |
|
1954 | 1969 | |
|
1955 | 1970 | - list all binary files:: |
|
1956 | 1971 | |
|
1957 | 1972 | hg files "set:binary()" |
|
1958 | 1973 | |
|
1959 | 1974 | - find files containing a regular expression:: |
|
1960 | 1975 | |
|
1961 | 1976 | hg files "set:grep('bob')" |
|
1962 | 1977 | |
|
1963 | 1978 | - search tracked file contents with xargs and grep:: |
|
1964 | 1979 | |
|
1965 | 1980 | hg files -0 | xargs -0 grep foo |
|
1966 | 1981 | |
|
1967 | 1982 | See :hg:`help patterns` and :hg:`help filesets` for more information |
|
1968 | 1983 | on specifying file patterns. |
|
1969 | 1984 | |
|
1970 | 1985 | Returns 0 if a match is found, 1 otherwise. |
|
1971 | 1986 | |
|
1972 | 1987 | """ |
|
1973 | 1988 | |
|
1974 | 1989 | opts = pycompat.byteskwargs(opts) |
|
1975 | 1990 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
1976 | 1991 | |
|
1977 | 1992 | end = '\n' |
|
1978 | 1993 | if opts.get('print0'): |
|
1979 | 1994 | end = '\0' |
|
1980 | 1995 | fmt = '%s' + end |
|
1981 | 1996 | |
|
1982 | 1997 | m = scmutil.match(ctx, pats, opts) |
|
1983 | 1998 | ui.pager('files') |
|
1984 | 1999 | with ui.formatter('files', opts) as fm: |
|
1985 | 2000 | return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) |
|
1986 | 2001 | |
|
1987 | 2002 | @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True) |
|
1988 | 2003 | def forget(ui, repo, *pats, **opts): |
|
1989 | 2004 | """forget the specified files on the next commit |
|
1990 | 2005 | |
|
1991 | 2006 | Mark the specified files so they will no longer be tracked |
|
1992 | 2007 | after the next commit. |
|
1993 | 2008 | |
|
1994 | 2009 | This only removes files from the current branch, not from the |
|
1995 | 2010 | entire project history, and it does not delete them from the |
|
1996 | 2011 | working directory. |
|
1997 | 2012 | |
|
1998 | 2013 | To delete the file from the working directory, see :hg:`remove`. |
|
1999 | 2014 | |
|
2000 | 2015 | To undo a forget before the next commit, see :hg:`add`. |
|
2001 | 2016 | |
|
2002 | 2017 | .. container:: verbose |
|
2003 | 2018 | |
|
2004 | 2019 | Examples: |
|
2005 | 2020 | |
|
2006 | 2021 | - forget newly-added binary files:: |
|
2007 | 2022 | |
|
2008 | 2023 | hg forget "set:added() and binary()" |
|
2009 | 2024 | |
|
2010 | 2025 | - forget files that would be excluded by .hgignore:: |
|
2011 | 2026 | |
|
2012 | 2027 | hg forget "set:hgignore()" |
|
2013 | 2028 | |
|
2014 | 2029 | Returns 0 on success. |
|
2015 | 2030 | """ |
|
2016 | 2031 | |
|
2017 | 2032 | opts = pycompat.byteskwargs(opts) |
|
2018 | 2033 | if not pats: |
|
2019 | 2034 | raise error.Abort(_('no files specified')) |
|
2020 | 2035 | |
|
2021 | 2036 | m = scmutil.match(repo[None], pats, opts) |
|
2022 | 2037 | rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0] |
|
2023 | 2038 | return rejected and 1 or 0 |
|
2024 | 2039 | |
|
2025 | 2040 | @command( |
|
2026 | 2041 | 'graft', |
|
2027 | 2042 | [('r', 'rev', [], _('revisions to graft'), _('REV')), |
|
2028 | 2043 | ('c', 'continue', False, _('resume interrupted graft')), |
|
2029 | 2044 | ('e', 'edit', False, _('invoke editor on commit messages')), |
|
2030 | 2045 | ('', 'log', None, _('append graft info to log message')), |
|
2031 | 2046 | ('f', 'force', False, _('force graft')), |
|
2032 | 2047 | ('D', 'currentdate', False, |
|
2033 | 2048 | _('record the current date as commit date')), |
|
2034 | 2049 | ('U', 'currentuser', False, |
|
2035 | 2050 | _('record the current user as committer'), _('DATE'))] |
|
2036 | 2051 | + commitopts2 + mergetoolopts + dryrunopts, |
|
2037 | 2052 | _('[OPTION]... [-r REV]... REV...')) |
|
2038 | 2053 | def graft(ui, repo, *revs, **opts): |
|
2039 | 2054 | '''copy changes from other branches onto the current branch |
|
2040 | 2055 | |
|
2041 | 2056 | This command uses Mercurial's merge logic to copy individual |
|
2042 | 2057 | changes from other branches without merging branches in the |
|
2043 | 2058 | history graph. This is sometimes known as 'backporting' or |
|
2044 | 2059 | 'cherry-picking'. By default, graft will copy user, date, and |
|
2045 | 2060 | description from the source changesets. |
|
2046 | 2061 | |
|
2047 | 2062 | Changesets that are ancestors of the current revision, that have |
|
2048 | 2063 | already been grafted, or that are merges will be skipped. |
|
2049 | 2064 | |
|
2050 | 2065 | If --log is specified, log messages will have a comment appended |
|
2051 | 2066 | of the form:: |
|
2052 | 2067 | |
|
2053 | 2068 | (grafted from CHANGESETHASH) |
|
2054 | 2069 | |
|
2055 | 2070 | If --force is specified, revisions will be grafted even if they |
|
2056 | 2071 | are already ancestors of or have been grafted to the destination. |
|
2057 | 2072 | This is useful when the revisions have since been backed out. |
|
2058 | 2073 | |
|
2059 | 2074 | If a graft merge results in conflicts, the graft process is |
|
2060 | 2075 | interrupted so that the current merge can be manually resolved. |
|
2061 | 2076 | Once all conflicts are addressed, the graft process can be |
|
2062 | 2077 | continued with the -c/--continue option. |
|
2063 | 2078 | |
|
2064 | 2079 | .. note:: |
|
2065 | 2080 | |
|
2066 | 2081 | The -c/--continue option does not reapply earlier options, except |
|
2067 | 2082 | for --force. |
|
2068 | 2083 | |
|
2069 | 2084 | .. container:: verbose |
|
2070 | 2085 | |
|
2071 | 2086 | Examples: |
|
2072 | 2087 | |
|
2073 | 2088 | - copy a single change to the stable branch and edit its description:: |
|
2074 | 2089 | |
|
2075 | 2090 | hg update stable |
|
2076 | 2091 | hg graft --edit 9393 |
|
2077 | 2092 | |
|
2078 | 2093 | - graft a range of changesets with one exception, updating dates:: |
|
2079 | 2094 | |
|
2080 | 2095 | hg graft -D "2085::2093 and not 2091" |
|
2081 | 2096 | |
|
2082 | 2097 | - continue a graft after resolving conflicts:: |
|
2083 | 2098 | |
|
2084 | 2099 | hg graft -c |
|
2085 | 2100 | |
|
2086 | 2101 | - show the source of a grafted changeset:: |
|
2087 | 2102 | |
|
2088 | 2103 | hg log --debug -r . |
|
2089 | 2104 | |
|
2090 | 2105 | - show revisions sorted by date:: |
|
2091 | 2106 | |
|
2092 | 2107 | hg log -r "sort(all(), date)" |
|
2093 | 2108 | |
|
2094 | 2109 | See :hg:`help revisions` for more about specifying revisions. |
|
2095 | 2110 | |
|
2096 | 2111 | Returns 0 on successful completion. |
|
2097 | 2112 | ''' |
|
2098 | 2113 | with repo.wlock(): |
|
2099 | 2114 | return _dograft(ui, repo, *revs, **opts) |
|
2100 | 2115 | |
|
2101 | 2116 | def _dograft(ui, repo, *revs, **opts): |
|
2102 | 2117 | opts = pycompat.byteskwargs(opts) |
|
2103 | 2118 | if revs and opts.get('rev'): |
|
2104 | 2119 | ui.warn(_('warning: inconsistent use of --rev might give unexpected ' |
|
2105 | 2120 | 'revision ordering!\n')) |
|
2106 | 2121 | |
|
2107 | 2122 | revs = list(revs) |
|
2108 | 2123 | revs.extend(opts.get('rev')) |
|
2109 | 2124 | |
|
2110 | 2125 | if not opts.get('user') and opts.get('currentuser'): |
|
2111 | 2126 | opts['user'] = ui.username() |
|
2112 | 2127 | if not opts.get('date') and opts.get('currentdate'): |
|
2113 | 2128 | opts['date'] = "%d %d" % util.makedate() |
|
2114 | 2129 | |
|
2115 | 2130 | editor = cmdutil.getcommiteditor(editform='graft', |
|
2116 | 2131 | **pycompat.strkwargs(opts)) |
|
2117 | 2132 | |
|
2118 | 2133 | cont = False |
|
2119 | 2134 | if opts.get('continue'): |
|
2120 | 2135 | cont = True |
|
2121 | 2136 | if revs: |
|
2122 | 2137 | raise error.Abort(_("can't specify --continue and revisions")) |
|
2123 | 2138 | # read in unfinished revisions |
|
2124 | 2139 | try: |
|
2125 | 2140 | nodes = repo.vfs.read('graftstate').splitlines() |
|
2126 | 2141 | revs = [repo[node].rev() for node in nodes] |
|
2127 | 2142 | except IOError as inst: |
|
2128 | 2143 | if inst.errno != errno.ENOENT: |
|
2129 | 2144 | raise |
|
2130 | 2145 | cmdutil.wrongtooltocontinue(repo, _('graft')) |
|
2131 | 2146 | else: |
|
2132 | 2147 | cmdutil.checkunfinished(repo) |
|
2133 | 2148 | cmdutil.bailifchanged(repo) |
|
2134 | 2149 | if not revs: |
|
2135 | 2150 | raise error.Abort(_('no revisions specified')) |
|
2136 | 2151 | revs = scmutil.revrange(repo, revs) |
|
2137 | 2152 | |
|
2138 | 2153 | skipped = set() |
|
2139 | 2154 | # check for merges |
|
2140 | 2155 | for rev in repo.revs('%ld and merge()', revs): |
|
2141 | 2156 | ui.warn(_('skipping ungraftable merge revision %d\n') % rev) |
|
2142 | 2157 | skipped.add(rev) |
|
2143 | 2158 | revs = [r for r in revs if r not in skipped] |
|
2144 | 2159 | if not revs: |
|
2145 | 2160 | return -1 |
|
2146 | 2161 | |
|
2147 | 2162 | # Don't check in the --continue case, in effect retaining --force across |
|
2148 | 2163 | # --continues. That's because without --force, any revisions we decided to |
|
2149 | 2164 | # skip would have been filtered out here, so they wouldn't have made their |
|
2150 | 2165 | # way to the graftstate. With --force, any revisions we would have otherwise |
|
2151 | 2166 | # skipped would not have been filtered out, and if they hadn't been applied |
|
2152 | 2167 | # already, they'd have been in the graftstate. |
|
2153 | 2168 | if not (cont or opts.get('force')): |
|
2154 | 2169 | # check for ancestors of dest branch |
|
2155 | 2170 | crev = repo['.'].rev() |
|
2156 | 2171 | ancestors = repo.changelog.ancestors([crev], inclusive=True) |
|
2157 | 2172 | # XXX make this lazy in the future |
|
2158 | 2173 | # don't mutate while iterating, create a copy |
|
2159 | 2174 | for rev in list(revs): |
|
2160 | 2175 | if rev in ancestors: |
|
2161 | 2176 | ui.warn(_('skipping ancestor revision %d:%s\n') % |
|
2162 | 2177 | (rev, repo[rev])) |
|
2163 | 2178 | # XXX remove on list is slow |
|
2164 | 2179 | revs.remove(rev) |
|
2165 | 2180 | if not revs: |
|
2166 | 2181 | return -1 |
|
2167 | 2182 | |
|
2168 | 2183 | # analyze revs for earlier grafts |
|
2169 | 2184 | ids = {} |
|
2170 | 2185 | for ctx in repo.set("%ld", revs): |
|
2171 | 2186 | ids[ctx.hex()] = ctx.rev() |
|
2172 | 2187 | n = ctx.extra().get('source') |
|
2173 | 2188 | if n: |
|
2174 | 2189 | ids[n] = ctx.rev() |
|
2175 | 2190 | |
|
2176 | 2191 | # check ancestors for earlier grafts |
|
2177 | 2192 | ui.debug('scanning for duplicate grafts\n') |
|
2178 | 2193 | |
|
2179 | 2194 | # The only changesets we can be sure doesn't contain grafts of any |
|
2180 | 2195 | # revs, are the ones that are common ancestors of *all* revs: |
|
2181 | 2196 | for rev in repo.revs('only(%d,ancestor(%ld))', crev, revs): |
|
2182 | 2197 | ctx = repo[rev] |
|
2183 | 2198 | n = ctx.extra().get('source') |
|
2184 | 2199 | if n in ids: |
|
2185 | 2200 | try: |
|
2186 | 2201 | r = repo[n].rev() |
|
2187 | 2202 | except error.RepoLookupError: |
|
2188 | 2203 | r = None |
|
2189 | 2204 | if r in revs: |
|
2190 | 2205 | ui.warn(_('skipping revision %d:%s ' |
|
2191 | 2206 | '(already grafted to %d:%s)\n') |
|
2192 | 2207 | % (r, repo[r], rev, ctx)) |
|
2193 | 2208 | revs.remove(r) |
|
2194 | 2209 | elif ids[n] in revs: |
|
2195 | 2210 | if r is None: |
|
2196 | 2211 | ui.warn(_('skipping already grafted revision %d:%s ' |
|
2197 | 2212 | '(%d:%s also has unknown origin %s)\n') |
|
2198 | 2213 | % (ids[n], repo[ids[n]], rev, ctx, n[:12])) |
|
2199 | 2214 | else: |
|
2200 | 2215 | ui.warn(_('skipping already grafted revision %d:%s ' |
|
2201 | 2216 | '(%d:%s also has origin %d:%s)\n') |
|
2202 | 2217 | % (ids[n], repo[ids[n]], rev, ctx, r, n[:12])) |
|
2203 | 2218 | revs.remove(ids[n]) |
|
2204 | 2219 | elif ctx.hex() in ids: |
|
2205 | 2220 | r = ids[ctx.hex()] |
|
2206 | 2221 | ui.warn(_('skipping already grafted revision %d:%s ' |
|
2207 | 2222 | '(was grafted from %d:%s)\n') % |
|
2208 | 2223 | (r, repo[r], rev, ctx)) |
|
2209 | 2224 | revs.remove(r) |
|
2210 | 2225 | if not revs: |
|
2211 | 2226 | return -1 |
|
2212 | 2227 | |
|
2213 | 2228 | for pos, ctx in enumerate(repo.set("%ld", revs)): |
|
2214 | 2229 | desc = '%d:%s "%s"' % (ctx.rev(), ctx, |
|
2215 | 2230 | ctx.description().split('\n', 1)[0]) |
|
2216 | 2231 | names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
|
2217 | 2232 | if names: |
|
2218 | 2233 | desc += ' (%s)' % ' '.join(names) |
|
2219 | 2234 | ui.status(_('grafting %s\n') % desc) |
|
2220 | 2235 | if opts.get('dry_run'): |
|
2221 | 2236 | continue |
|
2222 | 2237 | |
|
2223 | 2238 | source = ctx.extra().get('source') |
|
2224 | 2239 | extra = {} |
|
2225 | 2240 | if source: |
|
2226 | 2241 | extra['source'] = source |
|
2227 | 2242 | extra['intermediate-source'] = ctx.hex() |
|
2228 | 2243 | else: |
|
2229 | 2244 | extra['source'] = ctx.hex() |
|
2230 | 2245 | user = ctx.user() |
|
2231 | 2246 | if opts.get('user'): |
|
2232 | 2247 | user = opts['user'] |
|
2233 | 2248 | date = ctx.date() |
|
2234 | 2249 | if opts.get('date'): |
|
2235 | 2250 | date = opts['date'] |
|
2236 | 2251 | message = ctx.description() |
|
2237 | 2252 | if opts.get('log'): |
|
2238 | 2253 | message += '\n(grafted from %s)' % ctx.hex() |
|
2239 | 2254 | |
|
2240 | 2255 | # we don't merge the first commit when continuing |
|
2241 | 2256 | if not cont: |
|
2242 | 2257 | # perform the graft merge with p1(rev) as 'ancestor' |
|
2243 | 2258 | try: |
|
2244 | 2259 | # ui.forcemerge is an internal variable, do not document |
|
2245 | 2260 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
2246 | 2261 | 'graft') |
|
2247 | 2262 | stats = mergemod.graft(repo, ctx, ctx.p1(), |
|
2248 | 2263 | ['local', 'graft']) |
|
2249 | 2264 | finally: |
|
2250 | 2265 | repo.ui.setconfig('ui', 'forcemerge', '', 'graft') |
|
2251 | 2266 | # report any conflicts |
|
2252 | 2267 | if stats and stats[3] > 0: |
|
2253 | 2268 | # write out state for --continue |
|
2254 | 2269 | nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] |
|
2255 | 2270 | repo.vfs.write('graftstate', ''.join(nodelines)) |
|
2256 | 2271 | extra = '' |
|
2257 | 2272 | if opts.get('user'): |
|
2258 | 2273 | extra += ' --user %s' % util.shellquote(opts['user']) |
|
2259 | 2274 | if opts.get('date'): |
|
2260 | 2275 | extra += ' --date %s' % util.shellquote(opts['date']) |
|
2261 | 2276 | if opts.get('log'): |
|
2262 | 2277 | extra += ' --log' |
|
2263 | 2278 | hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra |
|
2264 | 2279 | raise error.Abort( |
|
2265 | 2280 | _("unresolved conflicts, can't continue"), |
|
2266 | 2281 | hint=hint) |
|
2267 | 2282 | else: |
|
2268 | 2283 | cont = False |
|
2269 | 2284 | |
|
2270 | 2285 | # commit |
|
2271 | 2286 | node = repo.commit(text=message, user=user, |
|
2272 | 2287 | date=date, extra=extra, editor=editor) |
|
2273 | 2288 | if node is None: |
|
2274 | 2289 | ui.warn( |
|
2275 | 2290 | _('note: graft of %d:%s created no changes to commit\n') % |
|
2276 | 2291 | (ctx.rev(), ctx)) |
|
2277 | 2292 | |
|
2278 | 2293 | # remove state when we complete successfully |
|
2279 | 2294 | if not opts.get('dry_run'): |
|
2280 | 2295 | repo.vfs.unlinkpath('graftstate', ignoremissing=True) |
|
2281 | 2296 | |
|
2282 | 2297 | return 0 |
|
2283 | 2298 | |
|
2284 | 2299 | @command('grep', |
|
2285 | 2300 | [('0', 'print0', None, _('end fields with NUL')), |
|
2286 | 2301 | ('', 'all', None, _('print all revisions that match')), |
|
2287 | 2302 | ('a', 'text', None, _('treat all files as text')), |
|
2288 | 2303 | ('f', 'follow', None, |
|
2289 | 2304 | _('follow changeset history,' |
|
2290 | 2305 | ' or file history across copies and renames')), |
|
2291 | 2306 | ('i', 'ignore-case', None, _('ignore case when matching')), |
|
2292 | 2307 | ('l', 'files-with-matches', None, |
|
2293 | 2308 | _('print only filenames and revisions that match')), |
|
2294 | 2309 | ('n', 'line-number', None, _('print matching line numbers')), |
|
2295 | 2310 | ('r', 'rev', [], |
|
2296 | 2311 | _('only search files changed within revision range'), _('REV')), |
|
2297 | 2312 | ('u', 'user', None, _('list the author (long with -v)')), |
|
2298 | 2313 | ('d', 'date', None, _('list the date (short with -q)')), |
|
2299 | 2314 | ] + formatteropts + walkopts, |
|
2300 | 2315 | _('[OPTION]... PATTERN [FILE]...'), |
|
2301 | 2316 | inferrepo=True) |
|
2302 | 2317 | def grep(ui, repo, pattern, *pats, **opts): |
|
2303 | 2318 | """search revision history for a pattern in specified files |
|
2304 | 2319 | |
|
2305 | 2320 | Search revision history for a regular expression in the specified |
|
2306 | 2321 | files or the entire project. |
|
2307 | 2322 | |
|
2308 | 2323 | By default, grep prints the most recent revision number for each |
|
2309 | 2324 | file in which it finds a match. To get it to print every revision |
|
2310 | 2325 | that contains a change in match status ("-" for a match that becomes |
|
2311 | 2326 | a non-match, or "+" for a non-match that becomes a match), use the |
|
2312 | 2327 | --all flag. |
|
2313 | 2328 | |
|
2314 | 2329 | PATTERN can be any Python (roughly Perl-compatible) regular |
|
2315 | 2330 | expression. |
|
2316 | 2331 | |
|
2317 | 2332 | If no FILEs are specified (and -f/--follow isn't set), all files in |
|
2318 | 2333 | the repository are searched, including those that don't exist in the |
|
2319 | 2334 | current branch or have been deleted in a prior changeset. |
|
2320 | 2335 | |
|
2321 | 2336 | Returns 0 if a match is found, 1 otherwise. |
|
2322 | 2337 | """ |
|
2323 | 2338 | opts = pycompat.byteskwargs(opts) |
|
2324 | 2339 | reflags = re.M |
|
2325 | 2340 | if opts.get('ignore_case'): |
|
2326 | 2341 | reflags |= re.I |
|
2327 | 2342 | try: |
|
2328 | 2343 | regexp = util.re.compile(pattern, reflags) |
|
2329 | 2344 | except re.error as inst: |
|
2330 | 2345 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
|
2331 | 2346 | return 1 |
|
2332 | 2347 | sep, eol = ':', '\n' |
|
2333 | 2348 | if opts.get('print0'): |
|
2334 | 2349 | sep = eol = '\0' |
|
2335 | 2350 | |
|
2336 | 2351 | getfile = util.lrucachefunc(repo.file) |
|
2337 | 2352 | |
|
2338 | 2353 | def matchlines(body): |
|
2339 | 2354 | begin = 0 |
|
2340 | 2355 | linenum = 0 |
|
2341 | 2356 | while begin < len(body): |
|
2342 | 2357 | match = regexp.search(body, begin) |
|
2343 | 2358 | if not match: |
|
2344 | 2359 | break |
|
2345 | 2360 | mstart, mend = match.span() |
|
2346 | 2361 | linenum += body.count('\n', begin, mstart) + 1 |
|
2347 | 2362 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
2348 | 2363 | begin = body.find('\n', mend) + 1 or len(body) + 1 |
|
2349 | 2364 | lend = begin - 1 |
|
2350 | 2365 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
|
2351 | 2366 | |
|
2352 | 2367 | class linestate(object): |
|
2353 | 2368 | def __init__(self, line, linenum, colstart, colend): |
|
2354 | 2369 | self.line = line |
|
2355 | 2370 | self.linenum = linenum |
|
2356 | 2371 | self.colstart = colstart |
|
2357 | 2372 | self.colend = colend |
|
2358 | 2373 | |
|
2359 | 2374 | def __hash__(self): |
|
2360 | 2375 | return hash((self.linenum, self.line)) |
|
2361 | 2376 | |
|
2362 | 2377 | def __eq__(self, other): |
|
2363 | 2378 | return self.line == other.line |
|
2364 | 2379 | |
|
2365 | 2380 | def findpos(self): |
|
2366 | 2381 | """Iterate all (start, end) indices of matches""" |
|
2367 | 2382 | yield self.colstart, self.colend |
|
2368 | 2383 | p = self.colend |
|
2369 | 2384 | while p < len(self.line): |
|
2370 | 2385 | m = regexp.search(self.line, p) |
|
2371 | 2386 | if not m: |
|
2372 | 2387 | break |
|
2373 | 2388 | yield m.span() |
|
2374 | 2389 | p = m.end() |
|
2375 | 2390 | |
|
2376 | 2391 | matches = {} |
|
2377 | 2392 | copies = {} |
|
2378 | 2393 | def grepbody(fn, rev, body): |
|
2379 | 2394 | matches[rev].setdefault(fn, []) |
|
2380 | 2395 | m = matches[rev][fn] |
|
2381 | 2396 | for lnum, cstart, cend, line in matchlines(body): |
|
2382 | 2397 | s = linestate(line, lnum, cstart, cend) |
|
2383 | 2398 | m.append(s) |
|
2384 | 2399 | |
|
2385 | 2400 | def difflinestates(a, b): |
|
2386 | 2401 | sm = difflib.SequenceMatcher(None, a, b) |
|
2387 | 2402 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
2388 | 2403 | if tag == 'insert': |
|
2389 | 2404 | for i in xrange(blo, bhi): |
|
2390 | 2405 | yield ('+', b[i]) |
|
2391 | 2406 | elif tag == 'delete': |
|
2392 | 2407 | for i in xrange(alo, ahi): |
|
2393 | 2408 | yield ('-', a[i]) |
|
2394 | 2409 | elif tag == 'replace': |
|
2395 | 2410 | for i in xrange(alo, ahi): |
|
2396 | 2411 | yield ('-', a[i]) |
|
2397 | 2412 | for i in xrange(blo, bhi): |
|
2398 | 2413 | yield ('+', b[i]) |
|
2399 | 2414 | |
|
2400 | 2415 | def display(fm, fn, ctx, pstates, states): |
|
2401 | 2416 | rev = ctx.rev() |
|
2402 | 2417 | if fm.isplain(): |
|
2403 | 2418 | formatuser = ui.shortuser |
|
2404 | 2419 | else: |
|
2405 | 2420 | formatuser = str |
|
2406 | 2421 | if ui.quiet: |
|
2407 | 2422 | datefmt = '%Y-%m-%d' |
|
2408 | 2423 | else: |
|
2409 | 2424 | datefmt = '%a %b %d %H:%M:%S %Y %1%2' |
|
2410 | 2425 | found = False |
|
2411 | 2426 | @util.cachefunc |
|
2412 | 2427 | def binary(): |
|
2413 | 2428 | flog = getfile(fn) |
|
2414 | 2429 | return util.binary(flog.read(ctx.filenode(fn))) |
|
2415 | 2430 | |
|
2416 | 2431 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} |
|
2417 | 2432 | if opts.get('all'): |
|
2418 | 2433 | iter = difflinestates(pstates, states) |
|
2419 | 2434 | else: |
|
2420 | 2435 | iter = [('', l) for l in states] |
|
2421 | 2436 | for change, l in iter: |
|
2422 | 2437 | fm.startitem() |
|
2423 | 2438 | fm.data(node=fm.hexfunc(ctx.node())) |
|
2424 | 2439 | cols = [ |
|
2425 | 2440 | ('filename', fn, True), |
|
2426 | 2441 | ('rev', rev, True), |
|
2427 | 2442 | ('linenumber', l.linenum, opts.get('line_number')), |
|
2428 | 2443 | ] |
|
2429 | 2444 | if opts.get('all'): |
|
2430 | 2445 | cols.append(('change', change, True)) |
|
2431 | 2446 | cols.extend([ |
|
2432 | 2447 | ('user', formatuser(ctx.user()), opts.get('user')), |
|
2433 | 2448 | ('date', fm.formatdate(ctx.date(), datefmt), opts.get('date')), |
|
2434 | 2449 | ]) |
|
2435 | 2450 | lastcol = next(name for name, data, cond in reversed(cols) if cond) |
|
2436 | 2451 | for name, data, cond in cols: |
|
2437 | 2452 | field = fieldnamemap.get(name, name) |
|
2438 | 2453 | fm.condwrite(cond, field, '%s', data, label='grep.%s' % name) |
|
2439 | 2454 | if cond and name != lastcol: |
|
2440 | 2455 | fm.plain(sep, label='grep.sep') |
|
2441 | 2456 | if not opts.get('files_with_matches'): |
|
2442 | 2457 | fm.plain(sep, label='grep.sep') |
|
2443 | 2458 | if not opts.get('text') and binary(): |
|
2444 | 2459 | fm.plain(_(" Binary file matches")) |
|
2445 | 2460 | else: |
|
2446 | 2461 | displaymatches(fm.nested('texts'), l) |
|
2447 | 2462 | fm.plain(eol) |
|
2448 | 2463 | found = True |
|
2449 | 2464 | if opts.get('files_with_matches'): |
|
2450 | 2465 | break |
|
2451 | 2466 | return found |
|
2452 | 2467 | |
|
2453 | 2468 | def displaymatches(fm, l): |
|
2454 | 2469 | p = 0 |
|
2455 | 2470 | for s, e in l.findpos(): |
|
2456 | 2471 | if p < s: |
|
2457 | 2472 | fm.startitem() |
|
2458 | 2473 | fm.write('text', '%s', l.line[p:s]) |
|
2459 | 2474 | fm.data(matched=False) |
|
2460 | 2475 | fm.startitem() |
|
2461 | 2476 | fm.write('text', '%s', l.line[s:e], label='grep.match') |
|
2462 | 2477 | fm.data(matched=True) |
|
2463 | 2478 | p = e |
|
2464 | 2479 | if p < len(l.line): |
|
2465 | 2480 | fm.startitem() |
|
2466 | 2481 | fm.write('text', '%s', l.line[p:]) |
|
2467 | 2482 | fm.data(matched=False) |
|
2468 | 2483 | fm.end() |
|
2469 | 2484 | |
|
2470 | 2485 | skip = {} |
|
2471 | 2486 | revfiles = {} |
|
2472 | 2487 | match = scmutil.match(repo[None], pats, opts) |
|
2473 | 2488 | found = False |
|
2474 | 2489 | follow = opts.get('follow') |
|
2475 | 2490 | |
|
2476 | 2491 | def prep(ctx, fns): |
|
2477 | 2492 | rev = ctx.rev() |
|
2478 | 2493 | pctx = ctx.p1() |
|
2479 | 2494 | parent = pctx.rev() |
|
2480 | 2495 | matches.setdefault(rev, {}) |
|
2481 | 2496 | matches.setdefault(parent, {}) |
|
2482 | 2497 | files = revfiles.setdefault(rev, []) |
|
2483 | 2498 | for fn in fns: |
|
2484 | 2499 | flog = getfile(fn) |
|
2485 | 2500 | try: |
|
2486 | 2501 | fnode = ctx.filenode(fn) |
|
2487 | 2502 | except error.LookupError: |
|
2488 | 2503 | continue |
|
2489 | 2504 | |
|
2490 | 2505 | copied = flog.renamed(fnode) |
|
2491 | 2506 | copy = follow and copied and copied[0] |
|
2492 | 2507 | if copy: |
|
2493 | 2508 | copies.setdefault(rev, {})[fn] = copy |
|
2494 | 2509 | if fn in skip: |
|
2495 | 2510 | if copy: |
|
2496 | 2511 | skip[copy] = True |
|
2497 | 2512 | continue |
|
2498 | 2513 | files.append(fn) |
|
2499 | 2514 | |
|
2500 | 2515 | if fn not in matches[rev]: |
|
2501 | 2516 | grepbody(fn, rev, flog.read(fnode)) |
|
2502 | 2517 | |
|
2503 | 2518 | pfn = copy or fn |
|
2504 | 2519 | if pfn not in matches[parent]: |
|
2505 | 2520 | try: |
|
2506 | 2521 | fnode = pctx.filenode(pfn) |
|
2507 | 2522 | grepbody(pfn, parent, flog.read(fnode)) |
|
2508 | 2523 | except error.LookupError: |
|
2509 | 2524 | pass |
|
2510 | 2525 | |
|
2511 | 2526 | ui.pager('grep') |
|
2512 | 2527 | fm = ui.formatter('grep', opts) |
|
2513 | 2528 | for ctx in cmdutil.walkchangerevs(repo, match, opts, prep): |
|
2514 | 2529 | rev = ctx.rev() |
|
2515 | 2530 | parent = ctx.p1().rev() |
|
2516 | 2531 | for fn in sorted(revfiles.get(rev, [])): |
|
2517 | 2532 | states = matches[rev][fn] |
|
2518 | 2533 | copy = copies.get(rev, {}).get(fn) |
|
2519 | 2534 | if fn in skip: |
|
2520 | 2535 | if copy: |
|
2521 | 2536 | skip[copy] = True |
|
2522 | 2537 | continue |
|
2523 | 2538 | pstates = matches.get(parent, {}).get(copy or fn, []) |
|
2524 | 2539 | if pstates or states: |
|
2525 | 2540 | r = display(fm, fn, ctx, pstates, states) |
|
2526 | 2541 | found = found or r |
|
2527 | 2542 | if r and not opts.get('all'): |
|
2528 | 2543 | skip[fn] = True |
|
2529 | 2544 | if copy: |
|
2530 | 2545 | skip[copy] = True |
|
2531 | 2546 | del matches[rev] |
|
2532 | 2547 | del revfiles[rev] |
|
2533 | 2548 | fm.end() |
|
2534 | 2549 | |
|
2535 | 2550 | return not found |
|
2536 | 2551 | |
|
2537 | 2552 | @command('heads', |
|
2538 | 2553 | [('r', 'rev', '', |
|
2539 | 2554 | _('show only heads which are descendants of STARTREV'), _('STARTREV')), |
|
2540 | 2555 | ('t', 'topo', False, _('show topological heads only')), |
|
2541 | 2556 | ('a', 'active', False, _('show active branchheads only (DEPRECATED)')), |
|
2542 | 2557 | ('c', 'closed', False, _('show normal and closed branch heads')), |
|
2543 | 2558 | ] + templateopts, |
|
2544 | 2559 | _('[-ct] [-r STARTREV] [REV]...')) |
|
2545 | 2560 | def heads(ui, repo, *branchrevs, **opts): |
|
2546 | 2561 | """show branch heads |
|
2547 | 2562 | |
|
2548 | 2563 | With no arguments, show all open branch heads in the repository. |
|
2549 | 2564 | Branch heads are changesets that have no descendants on the |
|
2550 | 2565 | same branch. They are where development generally takes place and |
|
2551 | 2566 | are the usual targets for update and merge operations. |
|
2552 | 2567 | |
|
2553 | 2568 | If one or more REVs are given, only open branch heads on the |
|
2554 | 2569 | branches associated with the specified changesets are shown. This |
|
2555 | 2570 | means that you can use :hg:`heads .` to see the heads on the |
|
2556 | 2571 | currently checked-out branch. |
|
2557 | 2572 | |
|
2558 | 2573 | If -c/--closed is specified, also show branch heads marked closed |
|
2559 | 2574 | (see :hg:`commit --close-branch`). |
|
2560 | 2575 | |
|
2561 | 2576 | If STARTREV is specified, only those heads that are descendants of |
|
2562 | 2577 | STARTREV will be displayed. |
|
2563 | 2578 | |
|
2564 | 2579 | If -t/--topo is specified, named branch mechanics will be ignored and only |
|
2565 | 2580 | topological heads (changesets with no children) will be shown. |
|
2566 | 2581 | |
|
2567 | 2582 | Returns 0 if matching heads are found, 1 if not. |
|
2568 | 2583 | """ |
|
2569 | 2584 | |
|
2570 | 2585 | opts = pycompat.byteskwargs(opts) |
|
2571 | 2586 | start = None |
|
2572 | 2587 | if 'rev' in opts: |
|
2573 | 2588 | start = scmutil.revsingle(repo, opts['rev'], None).node() |
|
2574 | 2589 | |
|
2575 | 2590 | if opts.get('topo'): |
|
2576 | 2591 | heads = [repo[h] for h in repo.heads(start)] |
|
2577 | 2592 | else: |
|
2578 | 2593 | heads = [] |
|
2579 | 2594 | for branch in repo.branchmap(): |
|
2580 | 2595 | heads += repo.branchheads(branch, start, opts.get('closed')) |
|
2581 | 2596 | heads = [repo[h] for h in heads] |
|
2582 | 2597 | |
|
2583 | 2598 | if branchrevs: |
|
2584 | 2599 | branches = set(repo[br].branch() for br in branchrevs) |
|
2585 | 2600 | heads = [h for h in heads if h.branch() in branches] |
|
2586 | 2601 | |
|
2587 | 2602 | if opts.get('active') and branchrevs: |
|
2588 | 2603 | dagheads = repo.heads(start) |
|
2589 | 2604 | heads = [h for h in heads if h.node() in dagheads] |
|
2590 | 2605 | |
|
2591 | 2606 | if branchrevs: |
|
2592 | 2607 | haveheads = set(h.branch() for h in heads) |
|
2593 | 2608 | if branches - haveheads: |
|
2594 | 2609 | headless = ', '.join(b for b in branches - haveheads) |
|
2595 | 2610 | msg = _('no open branch heads found on branches %s') |
|
2596 | 2611 | if opts.get('rev'): |
|
2597 | 2612 | msg += _(' (started at %s)') % opts['rev'] |
|
2598 | 2613 | ui.warn((msg + '\n') % headless) |
|
2599 | 2614 | |
|
2600 | 2615 | if not heads: |
|
2601 | 2616 | return 1 |
|
2602 | 2617 | |
|
2603 | 2618 | ui.pager('heads') |
|
2604 | 2619 | heads = sorted(heads, key=lambda x: -x.rev()) |
|
2605 | 2620 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
2606 | 2621 | for ctx in heads: |
|
2607 | 2622 | displayer.show(ctx) |
|
2608 | 2623 | displayer.close() |
|
2609 | 2624 | |
|
2610 | 2625 | @command('help', |
|
2611 | 2626 | [('e', 'extension', None, _('show only help for extensions')), |
|
2612 | 2627 | ('c', 'command', None, _('show only help for commands')), |
|
2613 | 2628 | ('k', 'keyword', None, _('show topics matching keyword')), |
|
2614 | 2629 | ('s', 'system', [], _('show help for specific platform(s)')), |
|
2615 | 2630 | ], |
|
2616 | 2631 | _('[-ecks] [TOPIC]'), |
|
2617 | 2632 | norepo=True) |
|
2618 | 2633 | def help_(ui, name=None, **opts): |
|
2619 | 2634 | """show help for a given topic or a help overview |
|
2620 | 2635 | |
|
2621 | 2636 | With no arguments, print a list of commands with short help messages. |
|
2622 | 2637 | |
|
2623 | 2638 | Given a topic, extension, or command name, print help for that |
|
2624 | 2639 | topic. |
|
2625 | 2640 | |
|
2626 | 2641 | Returns 0 if successful. |
|
2627 | 2642 | """ |
|
2628 | 2643 | |
|
2629 | 2644 | keep = opts.get(r'system') or [] |
|
2630 | 2645 | if len(keep) == 0: |
|
2631 | 2646 | if pycompat.sysplatform.startswith('win'): |
|
2632 | 2647 | keep.append('windows') |
|
2633 | 2648 | elif pycompat.sysplatform == 'OpenVMS': |
|
2634 | 2649 | keep.append('vms') |
|
2635 | 2650 | elif pycompat.sysplatform == 'plan9': |
|
2636 | 2651 | keep.append('plan9') |
|
2637 | 2652 | else: |
|
2638 | 2653 | keep.append('unix') |
|
2639 | 2654 | keep.append(pycompat.sysplatform.lower()) |
|
2640 | 2655 | if ui.verbose: |
|
2641 | 2656 | keep.append('verbose') |
|
2642 | 2657 | |
|
2643 | 2658 | commands = sys.modules[__name__] |
|
2644 | 2659 | formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts) |
|
2645 | 2660 | ui.pager('help') |
|
2646 | 2661 | ui.write(formatted) |
|
2647 | 2662 | |
|
2648 | 2663 | |
|
2649 | 2664 | @command('identify|id', |
|
2650 | 2665 | [('r', 'rev', '', |
|
2651 | 2666 | _('identify the specified revision'), _('REV')), |
|
2652 | 2667 | ('n', 'num', None, _('show local revision number')), |
|
2653 | 2668 | ('i', 'id', None, _('show global revision id')), |
|
2654 | 2669 | ('b', 'branch', None, _('show branch')), |
|
2655 | 2670 | ('t', 'tags', None, _('show tags')), |
|
2656 | 2671 | ('B', 'bookmarks', None, _('show bookmarks')), |
|
2657 | 2672 | ] + remoteopts + formatteropts, |
|
2658 | 2673 | _('[-nibtB] [-r REV] [SOURCE]'), |
|
2659 | 2674 | optionalrepo=True) |
|
2660 | 2675 | def identify(ui, repo, source=None, rev=None, |
|
2661 | 2676 | num=None, id=None, branch=None, tags=None, bookmarks=None, **opts): |
|
2662 | 2677 | """identify the working directory or specified revision |
|
2663 | 2678 | |
|
2664 | 2679 | Print a summary identifying the repository state at REV using one or |
|
2665 | 2680 | two parent hash identifiers, followed by a "+" if the working |
|
2666 | 2681 | directory has uncommitted changes, the branch name (if not default), |
|
2667 | 2682 | a list of tags, and a list of bookmarks. |
|
2668 | 2683 | |
|
2669 | 2684 | When REV is not given, print a summary of the current state of the |
|
2670 | 2685 | repository. |
|
2671 | 2686 | |
|
2672 | 2687 | Specifying a path to a repository root or Mercurial bundle will |
|
2673 | 2688 | cause lookup to operate on that repository/bundle. |
|
2674 | 2689 | |
|
2675 | 2690 | .. container:: verbose |
|
2676 | 2691 | |
|
2677 | 2692 | Examples: |
|
2678 | 2693 | |
|
2679 | 2694 | - generate a build identifier for the working directory:: |
|
2680 | 2695 | |
|
2681 | 2696 | hg id --id > build-id.dat |
|
2682 | 2697 | |
|
2683 | 2698 | - find the revision corresponding to a tag:: |
|
2684 | 2699 | |
|
2685 | 2700 | hg id -n -r 1.3 |
|
2686 | 2701 | |
|
2687 | 2702 | - check the most recent revision of a remote repository:: |
|
2688 | 2703 | |
|
2689 | 2704 | hg id -r tip https://www.mercurial-scm.org/repo/hg/ |
|
2690 | 2705 | |
|
2691 | 2706 | See :hg:`log` for generating more information about specific revisions, |
|
2692 | 2707 | including full hash identifiers. |
|
2693 | 2708 | |
|
2694 | 2709 | Returns 0 if successful. |
|
2695 | 2710 | """ |
|
2696 | 2711 | |
|
2697 | 2712 | opts = pycompat.byteskwargs(opts) |
|
2698 | 2713 | if not repo and not source: |
|
2699 | 2714 | raise error.Abort(_("there is no Mercurial repository here " |
|
2700 | 2715 | "(.hg not found)")) |
|
2701 | 2716 | |
|
2702 | 2717 | if ui.debugflag: |
|
2703 | 2718 | hexfunc = hex |
|
2704 | 2719 | else: |
|
2705 | 2720 | hexfunc = short |
|
2706 | 2721 | default = not (num or id or branch or tags or bookmarks) |
|
2707 | 2722 | output = [] |
|
2708 | 2723 | revs = [] |
|
2709 | 2724 | |
|
2710 | 2725 | if source: |
|
2711 | 2726 | source, branches = hg.parseurl(ui.expandpath(source)) |
|
2712 | 2727 | peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo |
|
2713 | 2728 | repo = peer.local() |
|
2714 | 2729 | revs, checkout = hg.addbranchrevs(repo, peer, branches, None) |
|
2715 | 2730 | |
|
2716 | 2731 | fm = ui.formatter('identify', opts) |
|
2717 | 2732 | fm.startitem() |
|
2718 | 2733 | |
|
2719 | 2734 | if not repo: |
|
2720 | 2735 | if num or branch or tags: |
|
2721 | 2736 | raise error.Abort( |
|
2722 | 2737 | _("can't query remote revision number, branch, or tags")) |
|
2723 | 2738 | if not rev and revs: |
|
2724 | 2739 | rev = revs[0] |
|
2725 | 2740 | if not rev: |
|
2726 | 2741 | rev = "tip" |
|
2727 | 2742 | |
|
2728 | 2743 | remoterev = peer.lookup(rev) |
|
2729 | 2744 | hexrev = hexfunc(remoterev) |
|
2730 | 2745 | if default or id: |
|
2731 | 2746 | output = [hexrev] |
|
2732 | 2747 | fm.data(id=hexrev) |
|
2733 | 2748 | |
|
2734 | 2749 | def getbms(): |
|
2735 | 2750 | bms = [] |
|
2736 | 2751 | |
|
2737 | 2752 | if 'bookmarks' in peer.listkeys('namespaces'): |
|
2738 | 2753 | hexremoterev = hex(remoterev) |
|
2739 | 2754 | bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems() |
|
2740 | 2755 | if bmr == hexremoterev] |
|
2741 | 2756 | |
|
2742 | 2757 | return sorted(bms) |
|
2743 | 2758 | |
|
2744 | 2759 | bms = getbms() |
|
2745 | 2760 | if bookmarks: |
|
2746 | 2761 | output.extend(bms) |
|
2747 | 2762 | elif default and not ui.quiet: |
|
2748 | 2763 | # multiple bookmarks for a single parent separated by '/' |
|
2749 | 2764 | bm = '/'.join(bms) |
|
2750 | 2765 | if bm: |
|
2751 | 2766 | output.append(bm) |
|
2752 | 2767 | |
|
2753 | 2768 | fm.data(node=hex(remoterev)) |
|
2754 | 2769 | fm.data(bookmarks=fm.formatlist(bms, name='bookmark')) |
|
2755 | 2770 | else: |
|
2756 | 2771 | ctx = scmutil.revsingle(repo, rev, None) |
|
2757 | 2772 | |
|
2758 | 2773 | if ctx.rev() is None: |
|
2759 | 2774 | ctx = repo[None] |
|
2760 | 2775 | parents = ctx.parents() |
|
2761 | 2776 | taglist = [] |
|
2762 | 2777 | for p in parents: |
|
2763 | 2778 | taglist.extend(p.tags()) |
|
2764 | 2779 | |
|
2765 | 2780 | dirty = "" |
|
2766 | 2781 | if ctx.dirty(missing=True, merge=False, branch=False): |
|
2767 | 2782 | dirty = '+' |
|
2768 | 2783 | fm.data(dirty=dirty) |
|
2769 | 2784 | |
|
2770 | 2785 | hexoutput = [hexfunc(p.node()) for p in parents] |
|
2771 | 2786 | if default or id: |
|
2772 | 2787 | output = ["%s%s" % ('+'.join(hexoutput), dirty)] |
|
2773 | 2788 | fm.data(id="%s%s" % ('+'.join(hexoutput), dirty)) |
|
2774 | 2789 | |
|
2775 | 2790 | if num: |
|
2776 | 2791 | numoutput = ["%d" % p.rev() for p in parents] |
|
2777 | 2792 | output.append("%s%s" % ('+'.join(numoutput), dirty)) |
|
2778 | 2793 | |
|
2779 | 2794 | fn = fm.nested('parents') |
|
2780 | 2795 | for p in parents: |
|
2781 | 2796 | fn.startitem() |
|
2782 | 2797 | fn.data(rev=p.rev()) |
|
2783 | 2798 | fn.data(node=p.hex()) |
|
2784 | 2799 | fn.context(ctx=p) |
|
2785 | 2800 | fn.end() |
|
2786 | 2801 | else: |
|
2787 | 2802 | hexoutput = hexfunc(ctx.node()) |
|
2788 | 2803 | if default or id: |
|
2789 | 2804 | output = [hexoutput] |
|
2790 | 2805 | fm.data(id=hexoutput) |
|
2791 | 2806 | |
|
2792 | 2807 | if num: |
|
2793 | 2808 | output.append(pycompat.bytestr(ctx.rev())) |
|
2794 | 2809 | taglist = ctx.tags() |
|
2795 | 2810 | |
|
2796 | 2811 | if default and not ui.quiet: |
|
2797 | 2812 | b = ctx.branch() |
|
2798 | 2813 | if b != 'default': |
|
2799 | 2814 | output.append("(%s)" % b) |
|
2800 | 2815 | |
|
2801 | 2816 | # multiple tags for a single parent separated by '/' |
|
2802 | 2817 | t = '/'.join(taglist) |
|
2803 | 2818 | if t: |
|
2804 | 2819 | output.append(t) |
|
2805 | 2820 | |
|
2806 | 2821 | # multiple bookmarks for a single parent separated by '/' |
|
2807 | 2822 | bm = '/'.join(ctx.bookmarks()) |
|
2808 | 2823 | if bm: |
|
2809 | 2824 | output.append(bm) |
|
2810 | 2825 | else: |
|
2811 | 2826 | if branch: |
|
2812 | 2827 | output.append(ctx.branch()) |
|
2813 | 2828 | |
|
2814 | 2829 | if tags: |
|
2815 | 2830 | output.extend(taglist) |
|
2816 | 2831 | |
|
2817 | 2832 | if bookmarks: |
|
2818 | 2833 | output.extend(ctx.bookmarks()) |
|
2819 | 2834 | |
|
2820 | 2835 | fm.data(node=ctx.hex()) |
|
2821 | 2836 | fm.data(branch=ctx.branch()) |
|
2822 | 2837 | fm.data(tags=fm.formatlist(taglist, name='tag', sep=':')) |
|
2823 | 2838 | fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark')) |
|
2824 | 2839 | fm.context(ctx=ctx) |
|
2825 | 2840 | |
|
2826 | 2841 | fm.plain("%s\n" % ' '.join(output)) |
|
2827 | 2842 | fm.end() |
|
2828 | 2843 | |
|
2829 | 2844 | @command('import|patch', |
|
2830 | 2845 | [('p', 'strip', 1, |
|
2831 | 2846 | _('directory strip option for patch. This has the same ' |
|
2832 | 2847 | 'meaning as the corresponding patch option'), _('NUM')), |
|
2833 | 2848 | ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')), |
|
2834 | 2849 | ('e', 'edit', False, _('invoke editor on commit messages')), |
|
2835 | 2850 | ('f', 'force', None, |
|
2836 | 2851 | _('skip check for outstanding uncommitted changes (DEPRECATED)')), |
|
2837 | 2852 | ('', 'no-commit', None, |
|
2838 | 2853 | _("don't commit, just update the working directory")), |
|
2839 | 2854 | ('', 'bypass', None, |
|
2840 | 2855 | _("apply patch without touching the working directory")), |
|
2841 | 2856 | ('', 'partial', None, |
|
2842 | 2857 | _('commit even if some hunks fail')), |
|
2843 | 2858 | ('', 'exact', None, |
|
2844 | 2859 | _('abort if patch would apply lossily')), |
|
2845 | 2860 | ('', 'prefix', '', |
|
2846 | 2861 | _('apply patch to subdirectory'), _('DIR')), |
|
2847 | 2862 | ('', 'import-branch', None, |
|
2848 | 2863 | _('use any branch information in patch (implied by --exact)'))] + |
|
2849 | 2864 | commitopts + commitopts2 + similarityopts, |
|
2850 | 2865 | _('[OPTION]... PATCH...')) |
|
2851 | 2866 | def import_(ui, repo, patch1=None, *patches, **opts): |
|
2852 | 2867 | """import an ordered set of patches |
|
2853 | 2868 | |
|
2854 | 2869 | Import a list of patches and commit them individually (unless |
|
2855 | 2870 | --no-commit is specified). |
|
2856 | 2871 | |
|
2857 | 2872 | To read a patch from standard input (stdin), use "-" as the patch |
|
2858 | 2873 | name. If a URL is specified, the patch will be downloaded from |
|
2859 | 2874 | there. |
|
2860 | 2875 | |
|
2861 | 2876 | Import first applies changes to the working directory (unless |
|
2862 | 2877 | --bypass is specified), import will abort if there are outstanding |
|
2863 | 2878 | changes. |
|
2864 | 2879 | |
|
2865 | 2880 | Use --bypass to apply and commit patches directly to the |
|
2866 | 2881 | repository, without affecting the working directory. Without |
|
2867 | 2882 | --exact, patches will be applied on top of the working directory |
|
2868 | 2883 | parent revision. |
|
2869 | 2884 | |
|
2870 | 2885 | You can import a patch straight from a mail message. Even patches |
|
2871 | 2886 | as attachments work (to use the body part, it must have type |
|
2872 | 2887 | text/plain or text/x-patch). From and Subject headers of email |
|
2873 | 2888 | message are used as default committer and commit message. All |
|
2874 | 2889 | text/plain body parts before first diff are added to the commit |
|
2875 | 2890 | message. |
|
2876 | 2891 | |
|
2877 | 2892 | If the imported patch was generated by :hg:`export`, user and |
|
2878 | 2893 | description from patch override values from message headers and |
|
2879 | 2894 | body. Values given on command line with -m/--message and -u/--user |
|
2880 | 2895 | override these. |
|
2881 | 2896 | |
|
2882 | 2897 | If --exact is specified, import will set the working directory to |
|
2883 | 2898 | the parent of each patch before applying it, and will abort if the |
|
2884 | 2899 | resulting changeset has a different ID than the one recorded in |
|
2885 | 2900 | the patch. This will guard against various ways that portable |
|
2886 | 2901 | patch formats and mail systems might fail to transfer Mercurial |
|
2887 | 2902 | data or metadata. See :hg:`bundle` for lossless transmission. |
|
2888 | 2903 | |
|
2889 | 2904 | Use --partial to ensure a changeset will be created from the patch |
|
2890 | 2905 | even if some hunks fail to apply. Hunks that fail to apply will be |
|
2891 | 2906 | written to a <target-file>.rej file. Conflicts can then be resolved |
|
2892 | 2907 | by hand before :hg:`commit --amend` is run to update the created |
|
2893 | 2908 | changeset. This flag exists to let people import patches that |
|
2894 | 2909 | partially apply without losing the associated metadata (author, |
|
2895 | 2910 | date, description, ...). |
|
2896 | 2911 | |
|
2897 | 2912 | .. note:: |
|
2898 | 2913 | |
|
2899 | 2914 | When no hunks apply cleanly, :hg:`import --partial` will create |
|
2900 | 2915 | an empty changeset, importing only the patch metadata. |
|
2901 | 2916 | |
|
2902 | 2917 | With -s/--similarity, hg will attempt to discover renames and |
|
2903 | 2918 | copies in the patch in the same way as :hg:`addremove`. |
|
2904 | 2919 | |
|
2905 | 2920 | It is possible to use external patch programs to perform the patch |
|
2906 | 2921 | by setting the ``ui.patch`` configuration option. For the default |
|
2907 | 2922 | internal tool, the fuzz can also be configured via ``patch.fuzz``. |
|
2908 | 2923 | See :hg:`help config` for more information about configuration |
|
2909 | 2924 | files and how to use these options. |
|
2910 | 2925 | |
|
2911 | 2926 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
2912 | 2927 | |
|
2913 | 2928 | .. container:: verbose |
|
2914 | 2929 | |
|
2915 | 2930 | Examples: |
|
2916 | 2931 | |
|
2917 | 2932 | - import a traditional patch from a website and detect renames:: |
|
2918 | 2933 | |
|
2919 | 2934 | hg import -s 80 http://example.com/bugfix.patch |
|
2920 | 2935 | |
|
2921 | 2936 | - import a changeset from an hgweb server:: |
|
2922 | 2937 | |
|
2923 | 2938 | hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa |
|
2924 | 2939 | |
|
2925 | 2940 | - import all the patches in an Unix-style mbox:: |
|
2926 | 2941 | |
|
2927 | 2942 | hg import incoming-patches.mbox |
|
2928 | 2943 | |
|
2929 | 2944 | - import patches from stdin:: |
|
2930 | 2945 | |
|
2931 | 2946 | hg import - |
|
2932 | 2947 | |
|
2933 | 2948 | - attempt to exactly restore an exported changeset (not always |
|
2934 | 2949 | possible):: |
|
2935 | 2950 | |
|
2936 | 2951 | hg import --exact proposed-fix.patch |
|
2937 | 2952 | |
|
2938 | 2953 | - use an external tool to apply a patch which is too fuzzy for |
|
2939 | 2954 | the default internal tool. |
|
2940 | 2955 | |
|
2941 | 2956 | hg import --config ui.patch="patch --merge" fuzzy.patch |
|
2942 | 2957 | |
|
2943 | 2958 | - change the default fuzzing from 2 to a less strict 7 |
|
2944 | 2959 | |
|
2945 | 2960 | hg import --config ui.fuzz=7 fuzz.patch |
|
2946 | 2961 | |
|
2947 | 2962 | Returns 0 on success, 1 on partial success (see --partial). |
|
2948 | 2963 | """ |
|
2949 | 2964 | |
|
2950 | 2965 | opts = pycompat.byteskwargs(opts) |
|
2951 | 2966 | if not patch1: |
|
2952 | 2967 | raise error.Abort(_('need at least one patch to import')) |
|
2953 | 2968 | |
|
2954 | 2969 | patches = (patch1,) + patches |
|
2955 | 2970 | |
|
2956 | 2971 | date = opts.get('date') |
|
2957 | 2972 | if date: |
|
2958 | 2973 | opts['date'] = util.parsedate(date) |
|
2959 | 2974 | |
|
2960 | 2975 | exact = opts.get('exact') |
|
2961 | 2976 | update = not opts.get('bypass') |
|
2962 | 2977 | if not update and opts.get('no_commit'): |
|
2963 | 2978 | raise error.Abort(_('cannot use --no-commit with --bypass')) |
|
2964 | 2979 | try: |
|
2965 | 2980 | sim = float(opts.get('similarity') or 0) |
|
2966 | 2981 | except ValueError: |
|
2967 | 2982 | raise error.Abort(_('similarity must be a number')) |
|
2968 | 2983 | if sim < 0 or sim > 100: |
|
2969 | 2984 | raise error.Abort(_('similarity must be between 0 and 100')) |
|
2970 | 2985 | if sim and not update: |
|
2971 | 2986 | raise error.Abort(_('cannot use --similarity with --bypass')) |
|
2972 | 2987 | if exact: |
|
2973 | 2988 | if opts.get('edit'): |
|
2974 | 2989 | raise error.Abort(_('cannot use --exact with --edit')) |
|
2975 | 2990 | if opts.get('prefix'): |
|
2976 | 2991 | raise error.Abort(_('cannot use --exact with --prefix')) |
|
2977 | 2992 | |
|
2978 | 2993 | base = opts["base"] |
|
2979 | 2994 | wlock = dsguard = lock = tr = None |
|
2980 | 2995 | msgs = [] |
|
2981 | 2996 | ret = 0 |
|
2982 | 2997 | |
|
2983 | 2998 | |
|
2984 | 2999 | try: |
|
2985 | 3000 | wlock = repo.wlock() |
|
2986 | 3001 | |
|
2987 | 3002 | if update: |
|
2988 | 3003 | cmdutil.checkunfinished(repo) |
|
2989 | 3004 | if (exact or not opts.get('force')): |
|
2990 | 3005 | cmdutil.bailifchanged(repo) |
|
2991 | 3006 | |
|
2992 | 3007 | if not opts.get('no_commit'): |
|
2993 | 3008 | lock = repo.lock() |
|
2994 | 3009 | tr = repo.transaction('import') |
|
2995 | 3010 | else: |
|
2996 | 3011 | dsguard = dirstateguard.dirstateguard(repo, 'import') |
|
2997 | 3012 | parents = repo[None].parents() |
|
2998 | 3013 | for patchurl in patches: |
|
2999 | 3014 | if patchurl == '-': |
|
3000 | 3015 | ui.status(_('applying patch from stdin\n')) |
|
3001 | 3016 | patchfile = ui.fin |
|
3002 | 3017 | patchurl = 'stdin' # for error message |
|
3003 | 3018 | else: |
|
3004 | 3019 | patchurl = os.path.join(base, patchurl) |
|
3005 | 3020 | ui.status(_('applying %s\n') % patchurl) |
|
3006 | 3021 | patchfile = hg.openpath(ui, patchurl) |
|
3007 | 3022 | |
|
3008 | 3023 | haspatch = False |
|
3009 | 3024 | for hunk in patch.split(patchfile): |
|
3010 | 3025 | (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, |
|
3011 | 3026 | parents, opts, |
|
3012 | 3027 | msgs, hg.clean) |
|
3013 | 3028 | if msg: |
|
3014 | 3029 | haspatch = True |
|
3015 | 3030 | ui.note(msg + '\n') |
|
3016 | 3031 | if update or exact: |
|
3017 | 3032 | parents = repo[None].parents() |
|
3018 | 3033 | else: |
|
3019 | 3034 | parents = [repo[node]] |
|
3020 | 3035 | if rej: |
|
3021 | 3036 | ui.write_err(_("patch applied partially\n")) |
|
3022 | 3037 | ui.write_err(_("(fix the .rej files and run " |
|
3023 | 3038 | "`hg commit --amend`)\n")) |
|
3024 | 3039 | ret = 1 |
|
3025 | 3040 | break |
|
3026 | 3041 | |
|
3027 | 3042 | if not haspatch: |
|
3028 | 3043 | raise error.Abort(_('%s: no diffs found') % patchurl) |
|
3029 | 3044 | |
|
3030 | 3045 | if tr: |
|
3031 | 3046 | tr.close() |
|
3032 | 3047 | if msgs: |
|
3033 | 3048 | repo.savecommitmessage('\n* * *\n'.join(msgs)) |
|
3034 | 3049 | if dsguard: |
|
3035 | 3050 | dsguard.close() |
|
3036 | 3051 | return ret |
|
3037 | 3052 | finally: |
|
3038 | 3053 | if tr: |
|
3039 | 3054 | tr.release() |
|
3040 | 3055 | release(lock, dsguard, wlock) |
|
3041 | 3056 | |
|
3042 | 3057 | @command('incoming|in', |
|
3043 | 3058 | [('f', 'force', None, |
|
3044 | 3059 | _('run even if remote repository is unrelated')), |
|
3045 | 3060 | ('n', 'newest-first', None, _('show newest record first')), |
|
3046 | 3061 | ('', 'bundle', '', |
|
3047 | 3062 | _('file to store the bundles into'), _('FILE')), |
|
3048 | 3063 | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |
|
3049 | 3064 | ('B', 'bookmarks', False, _("compare bookmarks")), |
|
3050 | 3065 | ('b', 'branch', [], |
|
3051 | 3066 | _('a specific branch you would like to pull'), _('BRANCH')), |
|
3052 | 3067 | ] + logopts + remoteopts + subrepoopts, |
|
3053 | 3068 | _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]')) |
|
3054 | 3069 | def incoming(ui, repo, source="default", **opts): |
|
3055 | 3070 | """show new changesets found in source |
|
3056 | 3071 | |
|
3057 | 3072 | Show new changesets found in the specified path/URL or the default |
|
3058 | 3073 | pull location. These are the changesets that would have been pulled |
|
3059 | 3074 | if a pull at the time you issued this command. |
|
3060 | 3075 | |
|
3061 | 3076 | See pull for valid source format details. |
|
3062 | 3077 | |
|
3063 | 3078 | .. container:: verbose |
|
3064 | 3079 | |
|
3065 | 3080 | With -B/--bookmarks, the result of bookmark comparison between |
|
3066 | 3081 | local and remote repositories is displayed. With -v/--verbose, |
|
3067 | 3082 | status is also displayed for each bookmark like below:: |
|
3068 | 3083 | |
|
3069 | 3084 | BM1 01234567890a added |
|
3070 | 3085 | BM2 1234567890ab advanced |
|
3071 | 3086 | BM3 234567890abc diverged |
|
3072 | 3087 | BM4 34567890abcd changed |
|
3073 | 3088 | |
|
3074 | 3089 | The action taken locally when pulling depends on the |
|
3075 | 3090 | status of each bookmark: |
|
3076 | 3091 | |
|
3077 | 3092 | :``added``: pull will create it |
|
3078 | 3093 | :``advanced``: pull will update it |
|
3079 | 3094 | :``diverged``: pull will create a divergent bookmark |
|
3080 | 3095 | :``changed``: result depends on remote changesets |
|
3081 | 3096 | |
|
3082 | 3097 | From the point of view of pulling behavior, bookmark |
|
3083 | 3098 | existing only in the remote repository are treated as ``added``, |
|
3084 | 3099 | even if it is in fact locally deleted. |
|
3085 | 3100 | |
|
3086 | 3101 | .. container:: verbose |
|
3087 | 3102 | |
|
3088 | 3103 | For remote repository, using --bundle avoids downloading the |
|
3089 | 3104 | changesets twice if the incoming is followed by a pull. |
|
3090 | 3105 | |
|
3091 | 3106 | Examples: |
|
3092 | 3107 | |
|
3093 | 3108 | - show incoming changes with patches and full description:: |
|
3094 | 3109 | |
|
3095 | 3110 | hg incoming -vp |
|
3096 | 3111 | |
|
3097 | 3112 | - show incoming changes excluding merges, store a bundle:: |
|
3098 | 3113 | |
|
3099 | 3114 | hg in -vpM --bundle incoming.hg |
|
3100 | 3115 | hg pull incoming.hg |
|
3101 | 3116 | |
|
3102 | 3117 | - briefly list changes inside a bundle:: |
|
3103 | 3118 | |
|
3104 | 3119 | hg in changes.hg -T "{desc|firstline}\\n" |
|
3105 | 3120 | |
|
3106 | 3121 | Returns 0 if there are incoming changes, 1 otherwise. |
|
3107 | 3122 | """ |
|
3108 | 3123 | opts = pycompat.byteskwargs(opts) |
|
3109 | 3124 | if opts.get('graph'): |
|
3110 | 3125 | cmdutil.checkunsupportedgraphflags([], opts) |
|
3111 | 3126 | def display(other, chlist, displayer): |
|
3112 | 3127 | revdag = cmdutil.graphrevs(other, chlist, opts) |
|
3113 | 3128 | cmdutil.displaygraph(ui, repo, revdag, displayer, |
|
3114 | 3129 | graphmod.asciiedges) |
|
3115 | 3130 | |
|
3116 | 3131 | hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True) |
|
3117 | 3132 | return 0 |
|
3118 | 3133 | |
|
3119 | 3134 | if opts.get('bundle') and opts.get('subrepos'): |
|
3120 | 3135 | raise error.Abort(_('cannot combine --bundle and --subrepos')) |
|
3121 | 3136 | |
|
3122 | 3137 | if opts.get('bookmarks'): |
|
3123 | 3138 | source, branches = hg.parseurl(ui.expandpath(source), |
|
3124 | 3139 | opts.get('branch')) |
|
3125 | 3140 | other = hg.peer(repo, opts, source) |
|
3126 | 3141 | if 'bookmarks' not in other.listkeys('namespaces'): |
|
3127 | 3142 | ui.warn(_("remote doesn't support bookmarks\n")) |
|
3128 | 3143 | return 0 |
|
3129 | 3144 | ui.pager('incoming') |
|
3130 | 3145 | ui.status(_('comparing with %s\n') % util.hidepassword(source)) |
|
3131 | 3146 | return bookmarks.incoming(ui, repo, other) |
|
3132 | 3147 | |
|
3133 | 3148 | repo._subtoppath = ui.expandpath(source) |
|
3134 | 3149 | try: |
|
3135 | 3150 | return hg.incoming(ui, repo, source, opts) |
|
3136 | 3151 | finally: |
|
3137 | 3152 | del repo._subtoppath |
|
3138 | 3153 | |
|
3139 | 3154 | |
|
3140 | 3155 | @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'), |
|
3141 | 3156 | norepo=True) |
|
3142 | 3157 | def init(ui, dest=".", **opts): |
|
3143 | 3158 | """create a new repository in the given directory |
|
3144 | 3159 | |
|
3145 | 3160 | Initialize a new repository in the given directory. If the given |
|
3146 | 3161 | directory does not exist, it will be created. |
|
3147 | 3162 | |
|
3148 | 3163 | If no directory is given, the current directory is used. |
|
3149 | 3164 | |
|
3150 | 3165 | It is possible to specify an ``ssh://`` URL as the destination. |
|
3151 | 3166 | See :hg:`help urls` for more information. |
|
3152 | 3167 | |
|
3153 | 3168 | Returns 0 on success. |
|
3154 | 3169 | """ |
|
3155 | 3170 | opts = pycompat.byteskwargs(opts) |
|
3156 | 3171 | hg.peer(ui, opts, ui.expandpath(dest), create=True) |
|
3157 | 3172 | |
|
3158 | 3173 | @command('locate', |
|
3159 | 3174 | [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), |
|
3160 | 3175 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
|
3161 | 3176 | ('f', 'fullpath', None, _('print complete paths from the filesystem root')), |
|
3162 | 3177 | ] + walkopts, |
|
3163 | 3178 | _('[OPTION]... [PATTERN]...')) |
|
3164 | 3179 | def locate(ui, repo, *pats, **opts): |
|
3165 | 3180 | """locate files matching specific patterns (DEPRECATED) |
|
3166 | 3181 | |
|
3167 | 3182 | Print files under Mercurial control in the working directory whose |
|
3168 | 3183 | names match the given patterns. |
|
3169 | 3184 | |
|
3170 | 3185 | By default, this command searches all directories in the working |
|
3171 | 3186 | directory. To search just the current directory and its |
|
3172 | 3187 | subdirectories, use "--include .". |
|
3173 | 3188 | |
|
3174 | 3189 | If no patterns are given to match, this command prints the names |
|
3175 | 3190 | of all files under Mercurial control in the working directory. |
|
3176 | 3191 | |
|
3177 | 3192 | If you want to feed the output of this command into the "xargs" |
|
3178 | 3193 | command, use the -0 option to both this command and "xargs". This |
|
3179 | 3194 | will avoid the problem of "xargs" treating single filenames that |
|
3180 | 3195 | contain whitespace as multiple filenames. |
|
3181 | 3196 | |
|
3182 | 3197 | See :hg:`help files` for a more versatile command. |
|
3183 | 3198 | |
|
3184 | 3199 | Returns 0 if a match is found, 1 otherwise. |
|
3185 | 3200 | """ |
|
3186 | 3201 | opts = pycompat.byteskwargs(opts) |
|
3187 | 3202 | if opts.get('print0'): |
|
3188 | 3203 | end = '\0' |
|
3189 | 3204 | else: |
|
3190 | 3205 | end = '\n' |
|
3191 | 3206 | rev = scmutil.revsingle(repo, opts.get('rev'), None).node() |
|
3192 | 3207 | |
|
3193 | 3208 | ret = 1 |
|
3194 | 3209 | ctx = repo[rev] |
|
3195 | 3210 | m = scmutil.match(ctx, pats, opts, default='relglob', |
|
3196 | 3211 | badfn=lambda x, y: False) |
|
3197 | 3212 | |
|
3198 | 3213 | ui.pager('locate') |
|
3199 | 3214 | for abs in ctx.matches(m): |
|
3200 | 3215 | if opts.get('fullpath'): |
|
3201 | 3216 | ui.write(repo.wjoin(abs), end) |
|
3202 | 3217 | else: |
|
3203 | 3218 | ui.write(((pats and m.rel(abs)) or abs), end) |
|
3204 | 3219 | ret = 0 |
|
3205 | 3220 | |
|
3206 | 3221 | return ret |
|
3207 | 3222 | |
|
3208 | 3223 | @command('^log|history', |
|
3209 | 3224 | [('f', 'follow', None, |
|
3210 | 3225 | _('follow changeset history, or file history across copies and renames')), |
|
3211 | 3226 | ('', 'follow-first', None, |
|
3212 | 3227 | _('only follow the first parent of merge changesets (DEPRECATED)')), |
|
3213 | 3228 | ('d', 'date', '', _('show revisions matching date spec'), _('DATE')), |
|
3214 | 3229 | ('C', 'copies', None, _('show copied files')), |
|
3215 | 3230 | ('k', 'keyword', [], |
|
3216 | 3231 | _('do case-insensitive search for a given text'), _('TEXT')), |
|
3217 | 3232 | ('r', 'rev', [], _('show the specified revision or revset'), _('REV')), |
|
3218 | 3233 | ('', 'removed', None, _('include revisions where files were removed')), |
|
3219 | 3234 | ('m', 'only-merges', None, _('show only merges (DEPRECATED)')), |
|
3220 | 3235 | ('u', 'user', [], _('revisions committed by user'), _('USER')), |
|
3221 | 3236 | ('', 'only-branch', [], |
|
3222 | 3237 | _('show only changesets within the given named branch (DEPRECATED)'), |
|
3223 | 3238 | _('BRANCH')), |
|
3224 | 3239 | ('b', 'branch', [], |
|
3225 | 3240 | _('show changesets within the given named branch'), _('BRANCH')), |
|
3226 | 3241 | ('P', 'prune', [], |
|
3227 | 3242 | _('do not display revision or any of its ancestors'), _('REV')), |
|
3228 | 3243 | ] + logopts + walkopts, |
|
3229 | 3244 | _('[OPTION]... [FILE]'), |
|
3230 | 3245 | inferrepo=True) |
|
3231 | 3246 | def log(ui, repo, *pats, **opts): |
|
3232 | 3247 | """show revision history of entire repository or files |
|
3233 | 3248 | |
|
3234 | 3249 | Print the revision history of the specified files or the entire |
|
3235 | 3250 | project. |
|
3236 | 3251 | |
|
3237 | 3252 | If no revision range is specified, the default is ``tip:0`` unless |
|
3238 | 3253 | --follow is set, in which case the working directory parent is |
|
3239 | 3254 | used as the starting revision. |
|
3240 | 3255 | |
|
3241 | 3256 | File history is shown without following rename or copy history of |
|
3242 | 3257 | files. Use -f/--follow with a filename to follow history across |
|
3243 | 3258 | renames and copies. --follow without a filename will only show |
|
3244 | 3259 | ancestors or descendants of the starting revision. |
|
3245 | 3260 | |
|
3246 | 3261 | By default this command prints revision number and changeset id, |
|
3247 | 3262 | tags, non-trivial parents, user, date and time, and a summary for |
|
3248 | 3263 | each commit. When the -v/--verbose switch is used, the list of |
|
3249 | 3264 | changed files and full commit message are shown. |
|
3250 | 3265 | |
|
3251 | 3266 | With --graph the revisions are shown as an ASCII art DAG with the most |
|
3252 | 3267 | recent changeset at the top. |
|
3253 | 3268 | 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete, |
|
3254 | 3269 | and '+' represents a fork where the changeset from the lines below is a |
|
3255 | 3270 | parent of the 'o' merge on the same line. |
|
3256 | 3271 | Paths in the DAG are represented with '|', '/' and so forth. ':' in place |
|
3257 | 3272 | of a '|' indicates one or more revisions in a path are omitted. |
|
3258 | 3273 | |
|
3259 | 3274 | .. note:: |
|
3260 | 3275 | |
|
3261 | 3276 | :hg:`log --patch` may generate unexpected diff output for merge |
|
3262 | 3277 | changesets, as it will only compare the merge changeset against |
|
3263 | 3278 | its first parent. Also, only files different from BOTH parents |
|
3264 | 3279 | will appear in files:. |
|
3265 | 3280 | |
|
3266 | 3281 | .. note:: |
|
3267 | 3282 | |
|
3268 | 3283 | For performance reasons, :hg:`log FILE` may omit duplicate changes |
|
3269 | 3284 | made on branches and will not show removals or mode changes. To |
|
3270 | 3285 | see all such changes, use the --removed switch. |
|
3271 | 3286 | |
|
3272 | 3287 | .. container:: verbose |
|
3273 | 3288 | |
|
3274 | 3289 | Some examples: |
|
3275 | 3290 | |
|
3276 | 3291 | - changesets with full descriptions and file lists:: |
|
3277 | 3292 | |
|
3278 | 3293 | hg log -v |
|
3279 | 3294 | |
|
3280 | 3295 | - changesets ancestral to the working directory:: |
|
3281 | 3296 | |
|
3282 | 3297 | hg log -f |
|
3283 | 3298 | |
|
3284 | 3299 | - last 10 commits on the current branch:: |
|
3285 | 3300 | |
|
3286 | 3301 | hg log -l 10 -b . |
|
3287 | 3302 | |
|
3288 | 3303 | - changesets showing all modifications of a file, including removals:: |
|
3289 | 3304 | |
|
3290 | 3305 | hg log --removed file.c |
|
3291 | 3306 | |
|
3292 | 3307 | - all changesets that touch a directory, with diffs, excluding merges:: |
|
3293 | 3308 | |
|
3294 | 3309 | hg log -Mp lib/ |
|
3295 | 3310 | |
|
3296 | 3311 | - all revision numbers that match a keyword:: |
|
3297 | 3312 | |
|
3298 | 3313 | hg log -k bug --template "{rev}\\n" |
|
3299 | 3314 | |
|
3300 | 3315 | - the full hash identifier of the working directory parent:: |
|
3301 | 3316 | |
|
3302 | 3317 | hg log -r . --template "{node}\\n" |
|
3303 | 3318 | |
|
3304 | 3319 | - list available log templates:: |
|
3305 | 3320 | |
|
3306 | 3321 | hg log -T list |
|
3307 | 3322 | |
|
3308 | 3323 | - check if a given changeset is included in a tagged release:: |
|
3309 | 3324 | |
|
3310 | 3325 | hg log -r "a21ccf and ancestor(1.9)" |
|
3311 | 3326 | |
|
3312 | 3327 | - find all changesets by some user in a date range:: |
|
3313 | 3328 | |
|
3314 | 3329 | hg log -k alice -d "may 2008 to jul 2008" |
|
3315 | 3330 | |
|
3316 | 3331 | - summary of all changesets after the last tag:: |
|
3317 | 3332 | |
|
3318 | 3333 | hg log -r "last(tagged())::" --template "{desc|firstline}\\n" |
|
3319 | 3334 | |
|
3320 | 3335 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
3321 | 3336 | |
|
3322 | 3337 | See :hg:`help revisions` for more about specifying and ordering |
|
3323 | 3338 | revisions. |
|
3324 | 3339 | |
|
3325 | 3340 | See :hg:`help templates` for more about pre-packaged styles and |
|
3326 | 3341 | specifying custom templates. The default template used by the log |
|
3327 | 3342 | command can be customized via the ``ui.logtemplate`` configuration |
|
3328 | 3343 | setting. |
|
3329 | 3344 | |
|
3330 | 3345 | Returns 0 on success. |
|
3331 | 3346 | |
|
3332 | 3347 | """ |
|
3333 | 3348 | opts = pycompat.byteskwargs(opts) |
|
3334 | 3349 | if opts.get('follow') and opts.get('rev'): |
|
3335 | 3350 | opts['rev'] = [revsetlang.formatspec('reverse(::%lr)', opts.get('rev'))] |
|
3336 | 3351 | del opts['follow'] |
|
3337 | 3352 | |
|
3338 | 3353 | if opts.get('graph'): |
|
3339 | 3354 | return cmdutil.graphlog(ui, repo, pats, opts) |
|
3340 | 3355 | |
|
3341 | 3356 | revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) |
|
3342 | 3357 | limit = cmdutil.loglimit(opts) |
|
3343 | 3358 | count = 0 |
|
3344 | 3359 | |
|
3345 | 3360 | getrenamed = None |
|
3346 | 3361 | if opts.get('copies'): |
|
3347 | 3362 | endrev = None |
|
3348 | 3363 | if opts.get('rev'): |
|
3349 | 3364 | endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1 |
|
3350 | 3365 | getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) |
|
3351 | 3366 | |
|
3352 | 3367 | ui.pager('log') |
|
3353 | 3368 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) |
|
3354 | 3369 | for rev in revs: |
|
3355 | 3370 | if count == limit: |
|
3356 | 3371 | break |
|
3357 | 3372 | ctx = repo[rev] |
|
3358 | 3373 | copies = None |
|
3359 | 3374 | if getrenamed is not None and rev: |
|
3360 | 3375 | copies = [] |
|
3361 | 3376 | for fn in ctx.files(): |
|
3362 | 3377 | rename = getrenamed(fn, rev) |
|
3363 | 3378 | if rename: |
|
3364 | 3379 | copies.append((fn, rename[0])) |
|
3365 | 3380 | if filematcher: |
|
3366 | 3381 | revmatchfn = filematcher(ctx.rev()) |
|
3367 | 3382 | else: |
|
3368 | 3383 | revmatchfn = None |
|
3369 | 3384 | displayer.show(ctx, copies=copies, matchfn=revmatchfn) |
|
3370 | 3385 | if displayer.flush(ctx): |
|
3371 | 3386 | count += 1 |
|
3372 | 3387 | |
|
3373 | 3388 | displayer.close() |
|
3374 | 3389 | |
|
3375 | 3390 | @command('manifest', |
|
3376 | 3391 | [('r', 'rev', '', _('revision to display'), _('REV')), |
|
3377 | 3392 | ('', 'all', False, _("list files from all revisions"))] |
|
3378 | 3393 | + formatteropts, |
|
3379 | 3394 | _('[-r REV]')) |
|
3380 | 3395 | def manifest(ui, repo, node=None, rev=None, **opts): |
|
3381 | 3396 | """output the current or given revision of the project manifest |
|
3382 | 3397 | |
|
3383 | 3398 | Print a list of version controlled files for the given revision. |
|
3384 | 3399 | If no revision is given, the first parent of the working directory |
|
3385 | 3400 | is used, or the null revision if no revision is checked out. |
|
3386 | 3401 | |
|
3387 | 3402 | With -v, print file permissions, symlink and executable bits. |
|
3388 | 3403 | With --debug, print file revision hashes. |
|
3389 | 3404 | |
|
3390 | 3405 | If option --all is specified, the list of all files from all revisions |
|
3391 | 3406 | is printed. This includes deleted and renamed files. |
|
3392 | 3407 | |
|
3393 | 3408 | Returns 0 on success. |
|
3394 | 3409 | """ |
|
3395 | 3410 | opts = pycompat.byteskwargs(opts) |
|
3396 | 3411 | fm = ui.formatter('manifest', opts) |
|
3397 | 3412 | |
|
3398 | 3413 | if opts.get('all'): |
|
3399 | 3414 | if rev or node: |
|
3400 | 3415 | raise error.Abort(_("can't specify a revision with --all")) |
|
3401 | 3416 | |
|
3402 | 3417 | res = [] |
|
3403 | 3418 | prefix = "data/" |
|
3404 | 3419 | suffix = ".i" |
|
3405 | 3420 | plen = len(prefix) |
|
3406 | 3421 | slen = len(suffix) |
|
3407 | 3422 | with repo.lock(): |
|
3408 | 3423 | for fn, b, size in repo.store.datafiles(): |
|
3409 | 3424 | if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix: |
|
3410 | 3425 | res.append(fn[plen:-slen]) |
|
3411 | 3426 | ui.pager('manifest') |
|
3412 | 3427 | for f in res: |
|
3413 | 3428 | fm.startitem() |
|
3414 | 3429 | fm.write("path", '%s\n', f) |
|
3415 | 3430 | fm.end() |
|
3416 | 3431 | return |
|
3417 | 3432 | |
|
3418 | 3433 | if rev and node: |
|
3419 | 3434 | raise error.Abort(_("please specify just one revision")) |
|
3420 | 3435 | |
|
3421 | 3436 | if not node: |
|
3422 | 3437 | node = rev |
|
3423 | 3438 | |
|
3424 | 3439 | char = {'l': '@', 'x': '*', '': ''} |
|
3425 | 3440 | mode = {'l': '644', 'x': '755', '': '644'} |
|
3426 | 3441 | ctx = scmutil.revsingle(repo, node) |
|
3427 | 3442 | mf = ctx.manifest() |
|
3428 | 3443 | ui.pager('manifest') |
|
3429 | 3444 | for f in ctx: |
|
3430 | 3445 | fm.startitem() |
|
3431 | 3446 | fl = ctx[f].flags() |
|
3432 | 3447 | fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f])) |
|
3433 | 3448 | fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl]) |
|
3434 | 3449 | fm.write('path', '%s\n', f) |
|
3435 | 3450 | fm.end() |
|
3436 | 3451 | |
|
3437 | 3452 | @command('^merge', |
|
3438 | 3453 | [('f', 'force', None, |
|
3439 | 3454 | _('force a merge including outstanding changes (DEPRECATED)')), |
|
3440 | 3455 | ('r', 'rev', '', _('revision to merge'), _('REV')), |
|
3441 | 3456 | ('P', 'preview', None, |
|
3442 | 3457 | _('review revisions to merge (no merge is performed)')) |
|
3443 | 3458 | ] + mergetoolopts, |
|
3444 | 3459 | _('[-P] [[-r] REV]')) |
|
3445 | 3460 | def merge(ui, repo, node=None, **opts): |
|
3446 | 3461 | """merge another revision into working directory |
|
3447 | 3462 | |
|
3448 | 3463 | The current working directory is updated with all changes made in |
|
3449 | 3464 | the requested revision since the last common predecessor revision. |
|
3450 | 3465 | |
|
3451 | 3466 | Files that changed between either parent are marked as changed for |
|
3452 | 3467 | the next commit and a commit must be performed before any further |
|
3453 | 3468 | updates to the repository are allowed. The next commit will have |
|
3454 | 3469 | two parents. |
|
3455 | 3470 | |
|
3456 | 3471 | ``--tool`` can be used to specify the merge tool used for file |
|
3457 | 3472 | merges. It overrides the HGMERGE environment variable and your |
|
3458 | 3473 | configuration files. See :hg:`help merge-tools` for options. |
|
3459 | 3474 | |
|
3460 | 3475 | If no revision is specified, the working directory's parent is a |
|
3461 | 3476 | head revision, and the current branch contains exactly one other |
|
3462 | 3477 | head, the other head is merged with by default. Otherwise, an |
|
3463 | 3478 | explicit revision with which to merge with must be provided. |
|
3464 | 3479 | |
|
3465 | 3480 | See :hg:`help resolve` for information on handling file conflicts. |
|
3466 | 3481 | |
|
3467 | 3482 | To undo an uncommitted merge, use :hg:`update --clean .` which |
|
3468 | 3483 | will check out a clean copy of the original merge parent, losing |
|
3469 | 3484 | all changes. |
|
3470 | 3485 | |
|
3471 | 3486 | Returns 0 on success, 1 if there are unresolved files. |
|
3472 | 3487 | """ |
|
3473 | 3488 | |
|
3474 | 3489 | opts = pycompat.byteskwargs(opts) |
|
3475 | 3490 | if opts.get('rev') and node: |
|
3476 | 3491 | raise error.Abort(_("please specify just one revision")) |
|
3477 | 3492 | if not node: |
|
3478 | 3493 | node = opts.get('rev') |
|
3479 | 3494 | |
|
3480 | 3495 | if node: |
|
3481 | 3496 | node = scmutil.revsingle(repo, node).node() |
|
3482 | 3497 | |
|
3483 | 3498 | if not node: |
|
3484 | 3499 | node = repo[destutil.destmerge(repo)].node() |
|
3485 | 3500 | |
|
3486 | 3501 | if opts.get('preview'): |
|
3487 | 3502 | # find nodes that are ancestors of p2 but not of p1 |
|
3488 | 3503 | p1 = repo.lookup('.') |
|
3489 | 3504 | p2 = repo.lookup(node) |
|
3490 | 3505 | nodes = repo.changelog.findmissing(common=[p1], heads=[p2]) |
|
3491 | 3506 | |
|
3492 | 3507 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
3493 | 3508 | for node in nodes: |
|
3494 | 3509 | displayer.show(repo[node]) |
|
3495 | 3510 | displayer.close() |
|
3496 | 3511 | return 0 |
|
3497 | 3512 | |
|
3498 | 3513 | try: |
|
3499 | 3514 | # ui.forcemerge is an internal variable, do not document |
|
3500 | 3515 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge') |
|
3501 | 3516 | force = opts.get('force') |
|
3502 | 3517 | labels = ['working copy', 'merge rev'] |
|
3503 | 3518 | return hg.merge(repo, node, force=force, mergeforce=force, |
|
3504 | 3519 | labels=labels) |
|
3505 | 3520 | finally: |
|
3506 | 3521 | ui.setconfig('ui', 'forcemerge', '', 'merge') |
|
3507 | 3522 | |
|
3508 | 3523 | @command('outgoing|out', |
|
3509 | 3524 | [('f', 'force', None, _('run even when the destination is unrelated')), |
|
3510 | 3525 | ('r', 'rev', [], |
|
3511 | 3526 | _('a changeset intended to be included in the destination'), _('REV')), |
|
3512 | 3527 | ('n', 'newest-first', None, _('show newest record first')), |
|
3513 | 3528 | ('B', 'bookmarks', False, _('compare bookmarks')), |
|
3514 | 3529 | ('b', 'branch', [], _('a specific branch you would like to push'), |
|
3515 | 3530 | _('BRANCH')), |
|
3516 | 3531 | ] + logopts + remoteopts + subrepoopts, |
|
3517 | 3532 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')) |
|
3518 | 3533 | def outgoing(ui, repo, dest=None, **opts): |
|
3519 | 3534 | """show changesets not found in the destination |
|
3520 | 3535 | |
|
3521 | 3536 | Show changesets not found in the specified destination repository |
|
3522 | 3537 | or the default push location. These are the changesets that would |
|
3523 | 3538 | be pushed if a push was requested. |
|
3524 | 3539 | |
|
3525 | 3540 | See pull for details of valid destination formats. |
|
3526 | 3541 | |
|
3527 | 3542 | .. container:: verbose |
|
3528 | 3543 | |
|
3529 | 3544 | With -B/--bookmarks, the result of bookmark comparison between |
|
3530 | 3545 | local and remote repositories is displayed. With -v/--verbose, |
|
3531 | 3546 | status is also displayed for each bookmark like below:: |
|
3532 | 3547 | |
|
3533 | 3548 | BM1 01234567890a added |
|
3534 | 3549 | BM2 deleted |
|
3535 | 3550 | BM3 234567890abc advanced |
|
3536 | 3551 | BM4 34567890abcd diverged |
|
3537 | 3552 | BM5 4567890abcde changed |
|
3538 | 3553 | |
|
3539 | 3554 | The action taken when pushing depends on the |
|
3540 | 3555 | status of each bookmark: |
|
3541 | 3556 | |
|
3542 | 3557 | :``added``: push with ``-B`` will create it |
|
3543 | 3558 | :``deleted``: push with ``-B`` will delete it |
|
3544 | 3559 | :``advanced``: push will update it |
|
3545 | 3560 | :``diverged``: push with ``-B`` will update it |
|
3546 | 3561 | :``changed``: push with ``-B`` will update it |
|
3547 | 3562 | |
|
3548 | 3563 | From the point of view of pushing behavior, bookmarks |
|
3549 | 3564 | existing only in the remote repository are treated as |
|
3550 | 3565 | ``deleted``, even if it is in fact added remotely. |
|
3551 | 3566 | |
|
3552 | 3567 | Returns 0 if there are outgoing changes, 1 otherwise. |
|
3553 | 3568 | """ |
|
3554 | 3569 | opts = pycompat.byteskwargs(opts) |
|
3555 | 3570 | if opts.get('graph'): |
|
3556 | 3571 | cmdutil.checkunsupportedgraphflags([], opts) |
|
3557 | 3572 | o, other = hg._outgoing(ui, repo, dest, opts) |
|
3558 | 3573 | if not o: |
|
3559 | 3574 | cmdutil.outgoinghooks(ui, repo, other, opts, o) |
|
3560 | 3575 | return |
|
3561 | 3576 | |
|
3562 | 3577 | revdag = cmdutil.graphrevs(repo, o, opts) |
|
3563 | 3578 | ui.pager('outgoing') |
|
3564 | 3579 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) |
|
3565 | 3580 | cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges) |
|
3566 | 3581 | cmdutil.outgoinghooks(ui, repo, other, opts, o) |
|
3567 | 3582 | return 0 |
|
3568 | 3583 | |
|
3569 | 3584 | if opts.get('bookmarks'): |
|
3570 | 3585 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
3571 | 3586 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
3572 | 3587 | other = hg.peer(repo, opts, dest) |
|
3573 | 3588 | if 'bookmarks' not in other.listkeys('namespaces'): |
|
3574 | 3589 | ui.warn(_("remote doesn't support bookmarks\n")) |
|
3575 | 3590 | return 0 |
|
3576 | 3591 | ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
|
3577 | 3592 | ui.pager('outgoing') |
|
3578 | 3593 | return bookmarks.outgoing(ui, repo, other) |
|
3579 | 3594 | |
|
3580 | 3595 | repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') |
|
3581 | 3596 | try: |
|
3582 | 3597 | return hg.outgoing(ui, repo, dest, opts) |
|
3583 | 3598 | finally: |
|
3584 | 3599 | del repo._subtoppath |
|
3585 | 3600 | |
|
3586 | 3601 | @command('parents', |
|
3587 | 3602 | [('r', 'rev', '', _('show parents of the specified revision'), _('REV')), |
|
3588 | 3603 | ] + templateopts, |
|
3589 | 3604 | _('[-r REV] [FILE]'), |
|
3590 | 3605 | inferrepo=True) |
|
3591 | 3606 | def parents(ui, repo, file_=None, **opts): |
|
3592 | 3607 | """show the parents of the working directory or revision (DEPRECATED) |
|
3593 | 3608 | |
|
3594 | 3609 | Print the working directory's parent revisions. If a revision is |
|
3595 | 3610 | given via -r/--rev, the parent of that revision will be printed. |
|
3596 | 3611 | If a file argument is given, the revision in which the file was |
|
3597 | 3612 | last changed (before the working directory revision or the |
|
3598 | 3613 | argument to --rev if given) is printed. |
|
3599 | 3614 | |
|
3600 | 3615 | This command is equivalent to:: |
|
3601 | 3616 | |
|
3602 | 3617 | hg log -r "p1()+p2()" or |
|
3603 | 3618 | hg log -r "p1(REV)+p2(REV)" or |
|
3604 | 3619 | hg log -r "max(::p1() and file(FILE))+max(::p2() and file(FILE))" or |
|
3605 | 3620 | hg log -r "max(::p1(REV) and file(FILE))+max(::p2(REV) and file(FILE))" |
|
3606 | 3621 | |
|
3607 | 3622 | See :hg:`summary` and :hg:`help revsets` for related information. |
|
3608 | 3623 | |
|
3609 | 3624 | Returns 0 on success. |
|
3610 | 3625 | """ |
|
3611 | 3626 | |
|
3612 | 3627 | opts = pycompat.byteskwargs(opts) |
|
3613 | 3628 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
3614 | 3629 | |
|
3615 | 3630 | if file_: |
|
3616 | 3631 | m = scmutil.match(ctx, (file_,), opts) |
|
3617 | 3632 | if m.anypats() or len(m.files()) != 1: |
|
3618 | 3633 | raise error.Abort(_('can only specify an explicit filename')) |
|
3619 | 3634 | file_ = m.files()[0] |
|
3620 | 3635 | filenodes = [] |
|
3621 | 3636 | for cp in ctx.parents(): |
|
3622 | 3637 | if not cp: |
|
3623 | 3638 | continue |
|
3624 | 3639 | try: |
|
3625 | 3640 | filenodes.append(cp.filenode(file_)) |
|
3626 | 3641 | except error.LookupError: |
|
3627 | 3642 | pass |
|
3628 | 3643 | if not filenodes: |
|
3629 | 3644 | raise error.Abort(_("'%s' not found in manifest!") % file_) |
|
3630 | 3645 | p = [] |
|
3631 | 3646 | for fn in filenodes: |
|
3632 | 3647 | fctx = repo.filectx(file_, fileid=fn) |
|
3633 | 3648 | p.append(fctx.node()) |
|
3634 | 3649 | else: |
|
3635 | 3650 | p = [cp.node() for cp in ctx.parents()] |
|
3636 | 3651 | |
|
3637 | 3652 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
3638 | 3653 | for n in p: |
|
3639 | 3654 | if n != nullid: |
|
3640 | 3655 | displayer.show(repo[n]) |
|
3641 | 3656 | displayer.close() |
|
3642 | 3657 | |
|
3643 | 3658 | @command('paths', formatteropts, _('[NAME]'), optionalrepo=True) |
|
3644 | 3659 | def paths(ui, repo, search=None, **opts): |
|
3645 | 3660 | """show aliases for remote repositories |
|
3646 | 3661 | |
|
3647 | 3662 | Show definition of symbolic path name NAME. If no name is given, |
|
3648 | 3663 | show definition of all available names. |
|
3649 | 3664 | |
|
3650 | 3665 | Option -q/--quiet suppresses all output when searching for NAME |
|
3651 | 3666 | and shows only the path names when listing all definitions. |
|
3652 | 3667 | |
|
3653 | 3668 | Path names are defined in the [paths] section of your |
|
3654 | 3669 | configuration file and in ``/etc/mercurial/hgrc``. If run inside a |
|
3655 | 3670 | repository, ``.hg/hgrc`` is used, too. |
|
3656 | 3671 | |
|
3657 | 3672 | The path names ``default`` and ``default-push`` have a special |
|
3658 | 3673 | meaning. When performing a push or pull operation, they are used |
|
3659 | 3674 | as fallbacks if no location is specified on the command-line. |
|
3660 | 3675 | When ``default-push`` is set, it will be used for push and |
|
3661 | 3676 | ``default`` will be used for pull; otherwise ``default`` is used |
|
3662 | 3677 | as the fallback for both. When cloning a repository, the clone |
|
3663 | 3678 | source is written as ``default`` in ``.hg/hgrc``. |
|
3664 | 3679 | |
|
3665 | 3680 | .. note:: |
|
3666 | 3681 | |
|
3667 | 3682 | ``default`` and ``default-push`` apply to all inbound (e.g. |
|
3668 | 3683 | :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` |
|
3669 | 3684 | and :hg:`bundle`) operations. |
|
3670 | 3685 | |
|
3671 | 3686 | See :hg:`help urls` for more information. |
|
3672 | 3687 | |
|
3673 | 3688 | Returns 0 on success. |
|
3674 | 3689 | """ |
|
3675 | 3690 | |
|
3676 | 3691 | opts = pycompat.byteskwargs(opts) |
|
3677 | 3692 | ui.pager('paths') |
|
3678 | 3693 | if search: |
|
3679 | 3694 | pathitems = [(name, path) for name, path in ui.paths.iteritems() |
|
3680 | 3695 | if name == search] |
|
3681 | 3696 | else: |
|
3682 | 3697 | pathitems = sorted(ui.paths.iteritems()) |
|
3683 | 3698 | |
|
3684 | 3699 | fm = ui.formatter('paths', opts) |
|
3685 | 3700 | if fm.isplain(): |
|
3686 | 3701 | hidepassword = util.hidepassword |
|
3687 | 3702 | else: |
|
3688 | 3703 | hidepassword = str |
|
3689 | 3704 | if ui.quiet: |
|
3690 | 3705 | namefmt = '%s\n' |
|
3691 | 3706 | else: |
|
3692 | 3707 | namefmt = '%s = ' |
|
3693 | 3708 | showsubopts = not search and not ui.quiet |
|
3694 | 3709 | |
|
3695 | 3710 | for name, path in pathitems: |
|
3696 | 3711 | fm.startitem() |
|
3697 | 3712 | fm.condwrite(not search, 'name', namefmt, name) |
|
3698 | 3713 | fm.condwrite(not ui.quiet, 'url', '%s\n', hidepassword(path.rawloc)) |
|
3699 | 3714 | for subopt, value in sorted(path.suboptions.items()): |
|
3700 | 3715 | assert subopt not in ('name', 'url') |
|
3701 | 3716 | if showsubopts: |
|
3702 | 3717 | fm.plain('%s:%s = ' % (name, subopt)) |
|
3703 | 3718 | fm.condwrite(showsubopts, subopt, '%s\n', value) |
|
3704 | 3719 | |
|
3705 | 3720 | fm.end() |
|
3706 | 3721 | |
|
3707 | 3722 | if search and not pathitems: |
|
3708 | 3723 | if not ui.quiet: |
|
3709 | 3724 | ui.warn(_("not found!\n")) |
|
3710 | 3725 | return 1 |
|
3711 | 3726 | else: |
|
3712 | 3727 | return 0 |
|
3713 | 3728 | |
|
3714 | 3729 | @command('phase', |
|
3715 | 3730 | [('p', 'public', False, _('set changeset phase to public')), |
|
3716 | 3731 | ('d', 'draft', False, _('set changeset phase to draft')), |
|
3717 | 3732 | ('s', 'secret', False, _('set changeset phase to secret')), |
|
3718 | 3733 | ('f', 'force', False, _('allow to move boundary backward')), |
|
3719 | 3734 | ('r', 'rev', [], _('target revision'), _('REV')), |
|
3720 | 3735 | ], |
|
3721 | 3736 | _('[-p|-d|-s] [-f] [-r] [REV...]')) |
|
3722 | 3737 | def phase(ui, repo, *revs, **opts): |
|
3723 | 3738 | """set or show the current phase name |
|
3724 | 3739 | |
|
3725 | 3740 | With no argument, show the phase name of the current revision(s). |
|
3726 | 3741 | |
|
3727 | 3742 | With one of -p/--public, -d/--draft or -s/--secret, change the |
|
3728 | 3743 | phase value of the specified revisions. |
|
3729 | 3744 | |
|
3730 | 3745 | Unless -f/--force is specified, :hg:`phase` won't move changeset from a |
|
3731 | 3746 | lower phase to an higher phase. Phases are ordered as follows:: |
|
3732 | 3747 | |
|
3733 | 3748 | public < draft < secret |
|
3734 | 3749 | |
|
3735 | 3750 | Returns 0 on success, 1 if some phases could not be changed. |
|
3736 | 3751 | |
|
3737 | 3752 | (For more information about the phases concept, see :hg:`help phases`.) |
|
3738 | 3753 | """ |
|
3739 | 3754 | opts = pycompat.byteskwargs(opts) |
|
3740 | 3755 | # search for a unique phase argument |
|
3741 | 3756 | targetphase = None |
|
3742 | 3757 | for idx, name in enumerate(phases.phasenames): |
|
3743 | 3758 | if opts[name]: |
|
3744 | 3759 | if targetphase is not None: |
|
3745 | 3760 | raise error.Abort(_('only one phase can be specified')) |
|
3746 | 3761 | targetphase = idx |
|
3747 | 3762 | |
|
3748 | 3763 | # look for specified revision |
|
3749 | 3764 | revs = list(revs) |
|
3750 | 3765 | revs.extend(opts['rev']) |
|
3751 | 3766 | if not revs: |
|
3752 | 3767 | # display both parents as the second parent phase can influence |
|
3753 | 3768 | # the phase of a merge commit |
|
3754 | 3769 | revs = [c.rev() for c in repo[None].parents()] |
|
3755 | 3770 | |
|
3756 | 3771 | revs = scmutil.revrange(repo, revs) |
|
3757 | 3772 | |
|
3758 | 3773 | lock = None |
|
3759 | 3774 | ret = 0 |
|
3760 | 3775 | if targetphase is None: |
|
3761 | 3776 | # display |
|
3762 | 3777 | for r in revs: |
|
3763 | 3778 | ctx = repo[r] |
|
3764 | 3779 | ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) |
|
3765 | 3780 | else: |
|
3766 | 3781 | tr = None |
|
3767 | 3782 | lock = repo.lock() |
|
3768 | 3783 | try: |
|
3769 | 3784 | tr = repo.transaction("phase") |
|
3770 | 3785 | # set phase |
|
3771 | 3786 | if not revs: |
|
3772 | 3787 | raise error.Abort(_('empty revision set')) |
|
3773 | 3788 | nodes = [repo[r].node() for r in revs] |
|
3774 | 3789 | # moving revision from public to draft may hide them |
|
3775 | 3790 | # We have to check result on an unfiltered repository |
|
3776 | 3791 | unfi = repo.unfiltered() |
|
3777 | 3792 | getphase = unfi._phasecache.phase |
|
3778 | 3793 | olddata = [getphase(unfi, r) for r in unfi] |
|
3779 | 3794 | phases.advanceboundary(repo, tr, targetphase, nodes) |
|
3780 | 3795 | if opts['force']: |
|
3781 | 3796 | phases.retractboundary(repo, tr, targetphase, nodes) |
|
3782 | 3797 | tr.close() |
|
3783 | 3798 | finally: |
|
3784 | 3799 | if tr is not None: |
|
3785 | 3800 | tr.release() |
|
3786 | 3801 | lock.release() |
|
3787 | 3802 | getphase = unfi._phasecache.phase |
|
3788 | 3803 | newdata = [getphase(unfi, r) for r in unfi] |
|
3789 | 3804 | changes = sum(newdata[r] != olddata[r] for r in unfi) |
|
3790 | 3805 | cl = unfi.changelog |
|
3791 | 3806 | rejected = [n for n in nodes |
|
3792 | 3807 | if newdata[cl.rev(n)] < targetphase] |
|
3793 | 3808 | if rejected: |
|
3794 | 3809 | ui.warn(_('cannot move %i changesets to a higher ' |
|
3795 | 3810 | 'phase, use --force\n') % len(rejected)) |
|
3796 | 3811 | ret = 1 |
|
3797 | 3812 | if changes: |
|
3798 | 3813 | msg = _('phase changed for %i changesets\n') % changes |
|
3799 | 3814 | if ret: |
|
3800 | 3815 | ui.status(msg) |
|
3801 | 3816 | else: |
|
3802 | 3817 | ui.note(msg) |
|
3803 | 3818 | else: |
|
3804 | 3819 | ui.warn(_('no phases changed\n')) |
|
3805 | 3820 | return ret |
|
3806 | 3821 | |
|
3807 | 3822 | def postincoming(ui, repo, modheads, optupdate, checkout, brev): |
|
3808 | 3823 | """Run after a changegroup has been added via pull/unbundle |
|
3809 | 3824 | |
|
3810 | 3825 | This takes arguments below: |
|
3811 | 3826 | |
|
3812 | 3827 | :modheads: change of heads by pull/unbundle |
|
3813 | 3828 | :optupdate: updating working directory is needed or not |
|
3814 | 3829 | :checkout: update destination revision (or None to default destination) |
|
3815 | 3830 | :brev: a name, which might be a bookmark to be activated after updating |
|
3816 | 3831 | """ |
|
3817 | 3832 | if modheads == 0: |
|
3818 | 3833 | return |
|
3819 | 3834 | if optupdate: |
|
3820 | 3835 | try: |
|
3821 | 3836 | return hg.updatetotally(ui, repo, checkout, brev) |
|
3822 | 3837 | except error.UpdateAbort as inst: |
|
3823 | 3838 | msg = _("not updating: %s") % str(inst) |
|
3824 | 3839 | hint = inst.hint |
|
3825 | 3840 | raise error.UpdateAbort(msg, hint=hint) |
|
3826 | 3841 | if modheads > 1: |
|
3827 | 3842 | currentbranchheads = len(repo.branchheads()) |
|
3828 | 3843 | if currentbranchheads == modheads: |
|
3829 | 3844 | ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
|
3830 | 3845 | elif currentbranchheads > 1: |
|
3831 | 3846 | ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to " |
|
3832 | 3847 | "merge)\n")) |
|
3833 | 3848 | else: |
|
3834 | 3849 | ui.status(_("(run 'hg heads' to see heads)\n")) |
|
3835 | 3850 | elif not ui.configbool('commands', 'update.requiredest'): |
|
3836 | 3851 | ui.status(_("(run 'hg update' to get a working copy)\n")) |
|
3837 | 3852 | |
|
3838 | 3853 | @command('^pull', |
|
3839 | 3854 | [('u', 'update', None, |
|
3840 | 3855 | _('update to new branch head if changesets were pulled')), |
|
3841 | 3856 | ('f', 'force', None, _('run even when remote repository is unrelated')), |
|
3842 | 3857 | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |
|
3843 | 3858 | ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')), |
|
3844 | 3859 | ('b', 'branch', [], _('a specific branch you would like to pull'), |
|
3845 | 3860 | _('BRANCH')), |
|
3846 | 3861 | ] + remoteopts, |
|
3847 | 3862 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')) |
|
3848 | 3863 | def pull(ui, repo, source="default", **opts): |
|
3849 | 3864 | """pull changes from the specified source |
|
3850 | 3865 | |
|
3851 | 3866 | Pull changes from a remote repository to a local one. |
|
3852 | 3867 | |
|
3853 | 3868 | This finds all changes from the repository at the specified path |
|
3854 | 3869 | or URL and adds them to a local repository (the current one unless |
|
3855 | 3870 | -R is specified). By default, this does not update the copy of the |
|
3856 | 3871 | project in the working directory. |
|
3857 | 3872 | |
|
3858 | 3873 | Use :hg:`incoming` if you want to see what would have been added |
|
3859 | 3874 | by a pull at the time you issued this command. If you then decide |
|
3860 | 3875 | to add those changes to the repository, you should use :hg:`pull |
|
3861 | 3876 | -r X` where ``X`` is the last changeset listed by :hg:`incoming`. |
|
3862 | 3877 | |
|
3863 | 3878 | If SOURCE is omitted, the 'default' path will be used. |
|
3864 | 3879 | See :hg:`help urls` for more information. |
|
3865 | 3880 | |
|
3866 | 3881 | Specifying bookmark as ``.`` is equivalent to specifying the active |
|
3867 | 3882 | bookmark's name. |
|
3868 | 3883 | |
|
3869 | 3884 | Returns 0 on success, 1 if an update had unresolved files. |
|
3870 | 3885 | """ |
|
3871 | 3886 | |
|
3872 | 3887 | opts = pycompat.byteskwargs(opts) |
|
3873 | 3888 | if ui.configbool('commands', 'update.requiredest') and opts.get('update'): |
|
3874 | 3889 | msg = _('update destination required by configuration') |
|
3875 | 3890 | hint = _('use hg pull followed by hg update DEST') |
|
3876 | 3891 | raise error.Abort(msg, hint=hint) |
|
3877 | 3892 | |
|
3878 | 3893 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
|
3879 | 3894 | ui.status(_('pulling from %s\n') % util.hidepassword(source)) |
|
3880 | 3895 | other = hg.peer(repo, opts, source) |
|
3881 | 3896 | try: |
|
3882 | 3897 | revs, checkout = hg.addbranchrevs(repo, other, branches, |
|
3883 | 3898 | opts.get('rev')) |
|
3884 | 3899 | |
|
3885 | 3900 | |
|
3886 | 3901 | pullopargs = {} |
|
3887 | 3902 | if opts.get('bookmark'): |
|
3888 | 3903 | if not revs: |
|
3889 | 3904 | revs = [] |
|
3890 | 3905 | # The list of bookmark used here is not the one used to actually |
|
3891 | 3906 | # update the bookmark name. This can result in the revision pulled |
|
3892 | 3907 | # not ending up with the name of the bookmark because of a race |
|
3893 | 3908 | # condition on the server. (See issue 4689 for details) |
|
3894 | 3909 | remotebookmarks = other.listkeys('bookmarks') |
|
3895 | 3910 | pullopargs['remotebookmarks'] = remotebookmarks |
|
3896 | 3911 | for b in opts['bookmark']: |
|
3897 | 3912 | b = repo._bookmarks.expandname(b) |
|
3898 | 3913 | if b not in remotebookmarks: |
|
3899 | 3914 | raise error.Abort(_('remote bookmark %s not found!') % b) |
|
3900 | 3915 | revs.append(remotebookmarks[b]) |
|
3901 | 3916 | |
|
3902 | 3917 | if revs: |
|
3903 | 3918 | try: |
|
3904 | 3919 | # When 'rev' is a bookmark name, we cannot guarantee that it |
|
3905 | 3920 | # will be updated with that name because of a race condition |
|
3906 | 3921 | # server side. (See issue 4689 for details) |
|
3907 | 3922 | oldrevs = revs |
|
3908 | 3923 | revs = [] # actually, nodes |
|
3909 | 3924 | for r in oldrevs: |
|
3910 | 3925 | node = other.lookup(r) |
|
3911 | 3926 | revs.append(node) |
|
3912 | 3927 | if r == checkout: |
|
3913 | 3928 | checkout = node |
|
3914 | 3929 | except error.CapabilityError: |
|
3915 | 3930 | err = _("other repository doesn't support revision lookup, " |
|
3916 | 3931 | "so a rev cannot be specified.") |
|
3917 | 3932 | raise error.Abort(err) |
|
3918 | 3933 | |
|
3919 | 3934 | pullopargs.update(opts.get('opargs', {})) |
|
3920 | 3935 | modheads = exchange.pull(repo, other, heads=revs, |
|
3921 | 3936 | force=opts.get('force'), |
|
3922 | 3937 | bookmarks=opts.get('bookmark', ()), |
|
3923 | 3938 | opargs=pullopargs).cgresult |
|
3924 | 3939 | |
|
3925 | 3940 | # brev is a name, which might be a bookmark to be activated at |
|
3926 | 3941 | # the end of the update. In other words, it is an explicit |
|
3927 | 3942 | # destination of the update |
|
3928 | 3943 | brev = None |
|
3929 | 3944 | |
|
3930 | 3945 | if checkout: |
|
3931 | 3946 | checkout = str(repo.changelog.rev(checkout)) |
|
3932 | 3947 | |
|
3933 | 3948 | # order below depends on implementation of |
|
3934 | 3949 | # hg.addbranchrevs(). opts['bookmark'] is ignored, |
|
3935 | 3950 | # because 'checkout' is determined without it. |
|
3936 | 3951 | if opts.get('rev'): |
|
3937 | 3952 | brev = opts['rev'][0] |
|
3938 | 3953 | elif opts.get('branch'): |
|
3939 | 3954 | brev = opts['branch'][0] |
|
3940 | 3955 | else: |
|
3941 | 3956 | brev = branches[0] |
|
3942 | 3957 | repo._subtoppath = source |
|
3943 | 3958 | try: |
|
3944 | 3959 | ret = postincoming(ui, repo, modheads, opts.get('update'), |
|
3945 | 3960 | checkout, brev) |
|
3946 | 3961 | |
|
3947 | 3962 | finally: |
|
3948 | 3963 | del repo._subtoppath |
|
3949 | 3964 | |
|
3950 | 3965 | finally: |
|
3951 | 3966 | other.close() |
|
3952 | 3967 | return ret |
|
3953 | 3968 | |
|
3954 | 3969 | @command('^push', |
|
3955 | 3970 | [('f', 'force', None, _('force push')), |
|
3956 | 3971 | ('r', 'rev', [], |
|
3957 | 3972 | _('a changeset intended to be included in the destination'), |
|
3958 | 3973 | _('REV')), |
|
3959 | 3974 | ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')), |
|
3960 | 3975 | ('b', 'branch', [], |
|
3961 | 3976 | _('a specific branch you would like to push'), _('BRANCH')), |
|
3962 | 3977 | ('', 'new-branch', False, _('allow pushing a new branch')), |
|
3963 | 3978 | ('', 'pushvars', [], _('variables that can be sent to server (ADVANCED)')), |
|
3964 | 3979 | ] + remoteopts, |
|
3965 | 3980 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')) |
|
3966 | 3981 | def push(ui, repo, dest=None, **opts): |
|
3967 | 3982 | """push changes to the specified destination |
|
3968 | 3983 | |
|
3969 | 3984 | Push changesets from the local repository to the specified |
|
3970 | 3985 | destination. |
|
3971 | 3986 | |
|
3972 | 3987 | This operation is symmetrical to pull: it is identical to a pull |
|
3973 | 3988 | in the destination repository from the current one. |
|
3974 | 3989 | |
|
3975 | 3990 | By default, push will not allow creation of new heads at the |
|
3976 | 3991 | destination, since multiple heads would make it unclear which head |
|
3977 | 3992 | to use. In this situation, it is recommended to pull and merge |
|
3978 | 3993 | before pushing. |
|
3979 | 3994 | |
|
3980 | 3995 | Use --new-branch if you want to allow push to create a new named |
|
3981 | 3996 | branch that is not present at the destination. This allows you to |
|
3982 | 3997 | only create a new branch without forcing other changes. |
|
3983 | 3998 | |
|
3984 | 3999 | .. note:: |
|
3985 | 4000 | |
|
3986 | 4001 | Extra care should be taken with the -f/--force option, |
|
3987 | 4002 | which will push all new heads on all branches, an action which will |
|
3988 | 4003 | almost always cause confusion for collaborators. |
|
3989 | 4004 | |
|
3990 | 4005 | If -r/--rev is used, the specified revision and all its ancestors |
|
3991 | 4006 | will be pushed to the remote repository. |
|
3992 | 4007 | |
|
3993 | 4008 | If -B/--bookmark is used, the specified bookmarked revision, its |
|
3994 | 4009 | ancestors, and the bookmark will be pushed to the remote |
|
3995 | 4010 | repository. Specifying ``.`` is equivalent to specifying the active |
|
3996 | 4011 | bookmark's name. |
|
3997 | 4012 | |
|
3998 | 4013 | Please see :hg:`help urls` for important details about ``ssh://`` |
|
3999 | 4014 | URLs. If DESTINATION is omitted, a default path will be used. |
|
4000 | 4015 | |
|
4001 | 4016 | .. container:: verbose |
|
4002 | 4017 | |
|
4003 | 4018 | The --pushvars option sends strings to the server that become |
|
4004 | 4019 | environment variables prepended with ``HG_USERVAR_``. For example, |
|
4005 | 4020 | ``--pushvars ENABLE_FEATURE=true``, provides the server side hooks with |
|
4006 | 4021 | ``HG_USERVAR_ENABLE_FEATURE=true`` as part of their environment. |
|
4007 | 4022 | |
|
4008 | 4023 | pushvars can provide for user-overridable hooks as well as set debug |
|
4009 | 4024 | levels. One example is having a hook that blocks commits containing |
|
4010 | 4025 | conflict markers, but enables the user to override the hook if the file |
|
4011 | 4026 | is using conflict markers for testing purposes or the file format has |
|
4012 | 4027 | strings that look like conflict markers. |
|
4013 | 4028 | |
|
4014 | 4029 | By default, servers will ignore `--pushvars`. To enable it add the |
|
4015 | 4030 | following to your configuration file:: |
|
4016 | 4031 | |
|
4017 | 4032 | [push] |
|
4018 | 4033 | pushvars.server = true |
|
4019 | 4034 | |
|
4020 | 4035 | Returns 0 if push was successful, 1 if nothing to push. |
|
4021 | 4036 | """ |
|
4022 | 4037 | |
|
4023 | 4038 | opts = pycompat.byteskwargs(opts) |
|
4024 | 4039 | if opts.get('bookmark'): |
|
4025 | 4040 | ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push') |
|
4026 | 4041 | for b in opts['bookmark']: |
|
4027 | 4042 | # translate -B options to -r so changesets get pushed |
|
4028 | 4043 | b = repo._bookmarks.expandname(b) |
|
4029 | 4044 | if b in repo._bookmarks: |
|
4030 | 4045 | opts.setdefault('rev', []).append(b) |
|
4031 | 4046 | else: |
|
4032 | 4047 | # if we try to push a deleted bookmark, translate it to null |
|
4033 | 4048 | # this lets simultaneous -r, -b options continue working |
|
4034 | 4049 | opts.setdefault('rev', []).append("null") |
|
4035 | 4050 | |
|
4036 | 4051 | path = ui.paths.getpath(dest, default=('default-push', 'default')) |
|
4037 | 4052 | if not path: |
|
4038 | 4053 | raise error.Abort(_('default repository not configured!'), |
|
4039 | 4054 | hint=_("see 'hg help config.paths'")) |
|
4040 | 4055 | dest = path.pushloc or path.loc |
|
4041 | 4056 | branches = (path.branch, opts.get('branch') or []) |
|
4042 | 4057 | ui.status(_('pushing to %s\n') % util.hidepassword(dest)) |
|
4043 | 4058 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
|
4044 | 4059 | other = hg.peer(repo, opts, dest) |
|
4045 | 4060 | |
|
4046 | 4061 | if revs: |
|
4047 | 4062 | revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] |
|
4048 | 4063 | if not revs: |
|
4049 | 4064 | raise error.Abort(_("specified revisions evaluate to an empty set"), |
|
4050 | 4065 | hint=_("use different revision arguments")) |
|
4051 | 4066 | elif path.pushrev: |
|
4052 | 4067 | # It doesn't make any sense to specify ancestor revisions. So limit |
|
4053 | 4068 | # to DAG heads to make discovery simpler. |
|
4054 | 4069 | expr = revsetlang.formatspec('heads(%r)', path.pushrev) |
|
4055 | 4070 | revs = scmutil.revrange(repo, [expr]) |
|
4056 | 4071 | revs = [repo[rev].node() for rev in revs] |
|
4057 | 4072 | if not revs: |
|
4058 | 4073 | raise error.Abort(_('default push revset for path evaluates to an ' |
|
4059 | 4074 | 'empty set')) |
|
4060 | 4075 | |
|
4061 | 4076 | repo._subtoppath = dest |
|
4062 | 4077 | try: |
|
4063 | 4078 | # push subrepos depth-first for coherent ordering |
|
4064 | 4079 | c = repo[''] |
|
4065 | 4080 | subs = c.substate # only repos that are committed |
|
4066 | 4081 | for s in sorted(subs): |
|
4067 | 4082 | result = c.sub(s).push(opts) |
|
4068 | 4083 | if result == 0: |
|
4069 | 4084 | return not result |
|
4070 | 4085 | finally: |
|
4071 | 4086 | del repo._subtoppath |
|
4072 | 4087 | |
|
4073 | 4088 | opargs = dict(opts.get('opargs', {})) # copy opargs since we may mutate it |
|
4074 | 4089 | opargs.setdefault('pushvars', []).extend(opts.get('pushvars', [])) |
|
4075 | 4090 | |
|
4076 | 4091 | pushop = exchange.push(repo, other, opts.get('force'), revs=revs, |
|
4077 | 4092 | newbranch=opts.get('new_branch'), |
|
4078 | 4093 | bookmarks=opts.get('bookmark', ()), |
|
4079 | 4094 | opargs=opargs) |
|
4080 | 4095 | |
|
4081 | 4096 | result = not pushop.cgresult |
|
4082 | 4097 | |
|
4083 | 4098 | if pushop.bkresult is not None: |
|
4084 | 4099 | if pushop.bkresult == 2: |
|
4085 | 4100 | result = 2 |
|
4086 | 4101 | elif not result and pushop.bkresult: |
|
4087 | 4102 | result = 2 |
|
4088 | 4103 | |
|
4089 | 4104 | return result |
|
4090 | 4105 | |
|
4091 | 4106 | @command('recover', []) |
|
4092 | 4107 | def recover(ui, repo): |
|
4093 | 4108 | """roll back an interrupted transaction |
|
4094 | 4109 | |
|
4095 | 4110 | Recover from an interrupted commit or pull. |
|
4096 | 4111 | |
|
4097 | 4112 | This command tries to fix the repository status after an |
|
4098 | 4113 | interrupted operation. It should only be necessary when Mercurial |
|
4099 | 4114 | suggests it. |
|
4100 | 4115 | |
|
4101 | 4116 | Returns 0 if successful, 1 if nothing to recover or verify fails. |
|
4102 | 4117 | """ |
|
4103 | 4118 | if repo.recover(): |
|
4104 | 4119 | return hg.verify(repo) |
|
4105 | 4120 | return 1 |
|
4106 | 4121 | |
|
4107 | 4122 | @command('^remove|rm', |
|
4108 | 4123 | [('A', 'after', None, _('record delete for missing files')), |
|
4109 | 4124 | ('f', 'force', None, |
|
4110 | 4125 | _('forget added files, delete modified files')), |
|
4111 | 4126 | ] + subrepoopts + walkopts, |
|
4112 | 4127 | _('[OPTION]... FILE...'), |
|
4113 | 4128 | inferrepo=True) |
|
4114 | 4129 | def remove(ui, repo, *pats, **opts): |
|
4115 | 4130 | """remove the specified files on the next commit |
|
4116 | 4131 | |
|
4117 | 4132 | Schedule the indicated files for removal from the current branch. |
|
4118 | 4133 | |
|
4119 | 4134 | This command schedules the files to be removed at the next commit. |
|
4120 | 4135 | To undo a remove before that, see :hg:`revert`. To undo added |
|
4121 | 4136 | files, see :hg:`forget`. |
|
4122 | 4137 | |
|
4123 | 4138 | .. container:: verbose |
|
4124 | 4139 | |
|
4125 | 4140 | -A/--after can be used to remove only files that have already |
|
4126 | 4141 | been deleted, -f/--force can be used to force deletion, and -Af |
|
4127 | 4142 | can be used to remove files from the next revision without |
|
4128 | 4143 | deleting them from the working directory. |
|
4129 | 4144 | |
|
4130 | 4145 | The following table details the behavior of remove for different |
|
4131 | 4146 | file states (columns) and option combinations (rows). The file |
|
4132 | 4147 | states are Added [A], Clean [C], Modified [M] and Missing [!] |
|
4133 | 4148 | (as reported by :hg:`status`). The actions are Warn, Remove |
|
4134 | 4149 | (from branch) and Delete (from disk): |
|
4135 | 4150 | |
|
4136 | 4151 | ========= == == == == |
|
4137 | 4152 | opt/state A C M ! |
|
4138 | 4153 | ========= == == == == |
|
4139 | 4154 | none W RD W R |
|
4140 | 4155 | -f R RD RD R |
|
4141 | 4156 | -A W W W R |
|
4142 | 4157 | -Af R R R R |
|
4143 | 4158 | ========= == == == == |
|
4144 | 4159 | |
|
4145 | 4160 | .. note:: |
|
4146 | 4161 | |
|
4147 | 4162 | :hg:`remove` never deletes files in Added [A] state from the |
|
4148 | 4163 | working directory, not even if ``--force`` is specified. |
|
4149 | 4164 | |
|
4150 | 4165 | Returns 0 on success, 1 if any warnings encountered. |
|
4151 | 4166 | """ |
|
4152 | 4167 | |
|
4153 | 4168 | opts = pycompat.byteskwargs(opts) |
|
4154 | 4169 | after, force = opts.get('after'), opts.get('force') |
|
4155 | 4170 | if not pats and not after: |
|
4156 | 4171 | raise error.Abort(_('no files specified')) |
|
4157 | 4172 | |
|
4158 | 4173 | m = scmutil.match(repo[None], pats, opts) |
|
4159 | 4174 | subrepos = opts.get('subrepos') |
|
4160 | 4175 | return cmdutil.remove(ui, repo, m, "", after, force, subrepos) |
|
4161 | 4176 | |
|
4162 | 4177 | @command('rename|move|mv', |
|
4163 | 4178 | [('A', 'after', None, _('record a rename that has already occurred')), |
|
4164 | 4179 | ('f', 'force', None, _('forcibly copy over an existing managed file')), |
|
4165 | 4180 | ] + walkopts + dryrunopts, |
|
4166 | 4181 | _('[OPTION]... SOURCE... DEST')) |
|
4167 | 4182 | def rename(ui, repo, *pats, **opts): |
|
4168 | 4183 | """rename files; equivalent of copy + remove |
|
4169 | 4184 | |
|
4170 | 4185 | Mark dest as copies of sources; mark sources for deletion. If dest |
|
4171 | 4186 | is a directory, copies are put in that directory. If dest is a |
|
4172 | 4187 | file, there can only be one source. |
|
4173 | 4188 | |
|
4174 | 4189 | By default, this command copies the contents of files as they |
|
4175 | 4190 | exist in the working directory. If invoked with -A/--after, the |
|
4176 | 4191 | operation is recorded, but no copying is performed. |
|
4177 | 4192 | |
|
4178 | 4193 | This command takes effect at the next commit. To undo a rename |
|
4179 | 4194 | before that, see :hg:`revert`. |
|
4180 | 4195 | |
|
4181 | 4196 | Returns 0 on success, 1 if errors are encountered. |
|
4182 | 4197 | """ |
|
4183 | 4198 | opts = pycompat.byteskwargs(opts) |
|
4184 | 4199 | with repo.wlock(False): |
|
4185 | 4200 | return cmdutil.copy(ui, repo, pats, opts, rename=True) |
|
4186 | 4201 | |
|
4187 | 4202 | @command('resolve', |
|
4188 | 4203 | [('a', 'all', None, _('select all unresolved files')), |
|
4189 | 4204 | ('l', 'list', None, _('list state of files needing merge')), |
|
4190 | 4205 | ('m', 'mark', None, _('mark files as resolved')), |
|
4191 | 4206 | ('u', 'unmark', None, _('mark files as unresolved')), |
|
4192 | 4207 | ('n', 'no-status', None, _('hide status prefix'))] |
|
4193 | 4208 | + mergetoolopts + walkopts + formatteropts, |
|
4194 | 4209 | _('[OPTION]... [FILE]...'), |
|
4195 | 4210 | inferrepo=True) |
|
4196 | 4211 | def resolve(ui, repo, *pats, **opts): |
|
4197 | 4212 | """redo merges or set/view the merge status of files |
|
4198 | 4213 | |
|
4199 | 4214 | Merges with unresolved conflicts are often the result of |
|
4200 | 4215 | non-interactive merging using the ``internal:merge`` configuration |
|
4201 | 4216 | setting, or a command-line merge tool like ``diff3``. The resolve |
|
4202 | 4217 | command is used to manage the files involved in a merge, after |
|
4203 | 4218 | :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the |
|
4204 | 4219 | working directory must have two parents). See :hg:`help |
|
4205 | 4220 | merge-tools` for information on configuring merge tools. |
|
4206 | 4221 | |
|
4207 | 4222 | The resolve command can be used in the following ways: |
|
4208 | 4223 | |
|
4209 | 4224 | - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified |
|
4210 | 4225 | files, discarding any previous merge attempts. Re-merging is not |
|
4211 | 4226 | performed for files already marked as resolved. Use ``--all/-a`` |
|
4212 | 4227 | to select all unresolved files. ``--tool`` can be used to specify |
|
4213 | 4228 | the merge tool used for the given files. It overrides the HGMERGE |
|
4214 | 4229 | environment variable and your configuration files. Previous file |
|
4215 | 4230 | contents are saved with a ``.orig`` suffix. |
|
4216 | 4231 | |
|
4217 | 4232 | - :hg:`resolve -m [FILE]`: mark a file as having been resolved |
|
4218 | 4233 | (e.g. after having manually fixed-up the files). The default is |
|
4219 | 4234 | to mark all unresolved files. |
|
4220 | 4235 | |
|
4221 | 4236 | - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The |
|
4222 | 4237 | default is to mark all resolved files. |
|
4223 | 4238 | |
|
4224 | 4239 | - :hg:`resolve -l`: list files which had or still have conflicts. |
|
4225 | 4240 | In the printed list, ``U`` = unresolved and ``R`` = resolved. |
|
4226 | 4241 | You can use ``set:unresolved()`` or ``set:resolved()`` to filter |
|
4227 | 4242 | the list. See :hg:`help filesets` for details. |
|
4228 | 4243 | |
|
4229 | 4244 | .. note:: |
|
4230 | 4245 | |
|
4231 | 4246 | Mercurial will not let you commit files with unresolved merge |
|
4232 | 4247 | conflicts. You must use :hg:`resolve -m ...` before you can |
|
4233 | 4248 | commit after a conflicting merge. |
|
4234 | 4249 | |
|
4235 | 4250 | Returns 0 on success, 1 if any files fail a resolve attempt. |
|
4236 | 4251 | """ |
|
4237 | 4252 | |
|
4238 | 4253 | opts = pycompat.byteskwargs(opts) |
|
4239 | 4254 | flaglist = 'all mark unmark list no_status'.split() |
|
4240 | 4255 | all, mark, unmark, show, nostatus = \ |
|
4241 | 4256 | [opts.get(o) for o in flaglist] |
|
4242 | 4257 | |
|
4243 | 4258 | if (show and (mark or unmark)) or (mark and unmark): |
|
4244 | 4259 | raise error.Abort(_("too many options specified")) |
|
4245 | 4260 | if pats and all: |
|
4246 | 4261 | raise error.Abort(_("can't specify --all and patterns")) |
|
4247 | 4262 | if not (all or pats or show or mark or unmark): |
|
4248 | 4263 | raise error.Abort(_('no files or directories specified'), |
|
4249 | 4264 | hint=('use --all to re-merge all unresolved files')) |
|
4250 | 4265 | |
|
4251 | 4266 | if show: |
|
4252 | 4267 | ui.pager('resolve') |
|
4253 | 4268 | fm = ui.formatter('resolve', opts) |
|
4254 | 4269 | ms = mergemod.mergestate.read(repo) |
|
4255 | 4270 | m = scmutil.match(repo[None], pats, opts) |
|
4256 | 4271 | for f in ms: |
|
4257 | 4272 | if not m(f): |
|
4258 | 4273 | continue |
|
4259 | 4274 | l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved', |
|
4260 | 4275 | 'd': 'driverresolved'}[ms[f]] |
|
4261 | 4276 | fm.startitem() |
|
4262 | 4277 | fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l) |
|
4263 | 4278 | fm.write('path', '%s\n', f, label=l) |
|
4264 | 4279 | fm.end() |
|
4265 | 4280 | return 0 |
|
4266 | 4281 | |
|
4267 | 4282 | with repo.wlock(): |
|
4268 | 4283 | ms = mergemod.mergestate.read(repo) |
|
4269 | 4284 | |
|
4270 | 4285 | if not (ms.active() or repo.dirstate.p2() != nullid): |
|
4271 | 4286 | raise error.Abort( |
|
4272 | 4287 | _('resolve command not applicable when not merging')) |
|
4273 | 4288 | |
|
4274 | 4289 | wctx = repo[None] |
|
4275 | 4290 | |
|
4276 | 4291 | if ms.mergedriver and ms.mdstate() == 'u': |
|
4277 | 4292 | proceed = mergemod.driverpreprocess(repo, ms, wctx) |
|
4278 | 4293 | ms.commit() |
|
4279 | 4294 | # allow mark and unmark to go through |
|
4280 | 4295 | if not mark and not unmark and not proceed: |
|
4281 | 4296 | return 1 |
|
4282 | 4297 | |
|
4283 | 4298 | m = scmutil.match(wctx, pats, opts) |
|
4284 | 4299 | ret = 0 |
|
4285 | 4300 | didwork = False |
|
4286 | 4301 | runconclude = False |
|
4287 | 4302 | |
|
4288 | 4303 | tocomplete = [] |
|
4289 | 4304 | for f in ms: |
|
4290 | 4305 | if not m(f): |
|
4291 | 4306 | continue |
|
4292 | 4307 | |
|
4293 | 4308 | didwork = True |
|
4294 | 4309 | |
|
4295 | 4310 | # don't let driver-resolved files be marked, and run the conclude |
|
4296 | 4311 | # step if asked to resolve |
|
4297 | 4312 | if ms[f] == "d": |
|
4298 | 4313 | exact = m.exact(f) |
|
4299 | 4314 | if mark: |
|
4300 | 4315 | if exact: |
|
4301 | 4316 | ui.warn(_('not marking %s as it is driver-resolved\n') |
|
4302 | 4317 | % f) |
|
4303 | 4318 | elif unmark: |
|
4304 | 4319 | if exact: |
|
4305 | 4320 | ui.warn(_('not unmarking %s as it is driver-resolved\n') |
|
4306 | 4321 | % f) |
|
4307 | 4322 | else: |
|
4308 | 4323 | runconclude = True |
|
4309 | 4324 | continue |
|
4310 | 4325 | |
|
4311 | 4326 | if mark: |
|
4312 | 4327 | ms.mark(f, "r") |
|
4313 | 4328 | elif unmark: |
|
4314 | 4329 | ms.mark(f, "u") |
|
4315 | 4330 | else: |
|
4316 | 4331 | # backup pre-resolve (merge uses .orig for its own purposes) |
|
4317 | 4332 | a = repo.wjoin(f) |
|
4318 | 4333 | try: |
|
4319 | 4334 | util.copyfile(a, a + ".resolve") |
|
4320 | 4335 | except (IOError, OSError) as inst: |
|
4321 | 4336 | if inst.errno != errno.ENOENT: |
|
4322 | 4337 | raise |
|
4323 | 4338 | |
|
4324 | 4339 | try: |
|
4325 | 4340 | # preresolve file |
|
4326 | 4341 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
4327 | 4342 | 'resolve') |
|
4328 | 4343 | complete, r = ms.preresolve(f, wctx) |
|
4329 | 4344 | if not complete: |
|
4330 | 4345 | tocomplete.append(f) |
|
4331 | 4346 | elif r: |
|
4332 | 4347 | ret = 1 |
|
4333 | 4348 | finally: |
|
4334 | 4349 | ui.setconfig('ui', 'forcemerge', '', 'resolve') |
|
4335 | 4350 | ms.commit() |
|
4336 | 4351 | |
|
4337 | 4352 | # replace filemerge's .orig file with our resolve file, but only |
|
4338 | 4353 | # for merges that are complete |
|
4339 | 4354 | if complete: |
|
4340 | 4355 | try: |
|
4341 | 4356 | util.rename(a + ".resolve", |
|
4342 | 4357 | scmutil.origpath(ui, repo, a)) |
|
4343 | 4358 | except OSError as inst: |
|
4344 | 4359 | if inst.errno != errno.ENOENT: |
|
4345 | 4360 | raise |
|
4346 | 4361 | |
|
4347 | 4362 | for f in tocomplete: |
|
4348 | 4363 | try: |
|
4349 | 4364 | # resolve file |
|
4350 | 4365 | ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
|
4351 | 4366 | 'resolve') |
|
4352 | 4367 | r = ms.resolve(f, wctx) |
|
4353 | 4368 | if r: |
|
4354 | 4369 | ret = 1 |
|
4355 | 4370 | finally: |
|
4356 | 4371 | ui.setconfig('ui', 'forcemerge', '', 'resolve') |
|
4357 | 4372 | ms.commit() |
|
4358 | 4373 | |
|
4359 | 4374 | # replace filemerge's .orig file with our resolve file |
|
4360 | 4375 | a = repo.wjoin(f) |
|
4361 | 4376 | try: |
|
4362 | 4377 | util.rename(a + ".resolve", scmutil.origpath(ui, repo, a)) |
|
4363 | 4378 | except OSError as inst: |
|
4364 | 4379 | if inst.errno != errno.ENOENT: |
|
4365 | 4380 | raise |
|
4366 | 4381 | |
|
4367 | 4382 | ms.commit() |
|
4368 | 4383 | ms.recordactions() |
|
4369 | 4384 | |
|
4370 | 4385 | if not didwork and pats: |
|
4371 | 4386 | hint = None |
|
4372 | 4387 | if not any([p for p in pats if p.find(':') >= 0]): |
|
4373 | 4388 | pats = ['path:%s' % p for p in pats] |
|
4374 | 4389 | m = scmutil.match(wctx, pats, opts) |
|
4375 | 4390 | for f in ms: |
|
4376 | 4391 | if not m(f): |
|
4377 | 4392 | continue |
|
4378 | 4393 | flags = ''.join(['-%s ' % o[0] for o in flaglist |
|
4379 | 4394 | if opts.get(o)]) |
|
4380 | 4395 | hint = _("(try: hg resolve %s%s)\n") % ( |
|
4381 | 4396 | flags, |
|
4382 | 4397 | ' '.join(pats)) |
|
4383 | 4398 | break |
|
4384 | 4399 | ui.warn(_("arguments do not match paths that need resolving\n")) |
|
4385 | 4400 | if hint: |
|
4386 | 4401 | ui.warn(hint) |
|
4387 | 4402 | elif ms.mergedriver and ms.mdstate() != 's': |
|
4388 | 4403 | # run conclude step when either a driver-resolved file is requested |
|
4389 | 4404 | # or there are no driver-resolved files |
|
4390 | 4405 | # we can't use 'ret' to determine whether any files are unresolved |
|
4391 | 4406 | # because we might not have tried to resolve some |
|
4392 | 4407 | if ((runconclude or not list(ms.driverresolved())) |
|
4393 | 4408 | and not list(ms.unresolved())): |
|
4394 | 4409 | proceed = mergemod.driverconclude(repo, ms, wctx) |
|
4395 | 4410 | ms.commit() |
|
4396 | 4411 | if not proceed: |
|
4397 | 4412 | return 1 |
|
4398 | 4413 | |
|
4399 | 4414 | # Nudge users into finishing an unfinished operation |
|
4400 | 4415 | unresolvedf = list(ms.unresolved()) |
|
4401 | 4416 | driverresolvedf = list(ms.driverresolved()) |
|
4402 | 4417 | if not unresolvedf and not driverresolvedf: |
|
4403 | 4418 | ui.status(_('(no more unresolved files)\n')) |
|
4404 | 4419 | cmdutil.checkafterresolved(repo) |
|
4405 | 4420 | elif not unresolvedf: |
|
4406 | 4421 | ui.status(_('(no more unresolved files -- ' |
|
4407 | 4422 | 'run "hg resolve --all" to conclude)\n')) |
|
4408 | 4423 | |
|
4409 | 4424 | return ret |
|
4410 | 4425 | |
|
4411 | 4426 | @command('revert', |
|
4412 | 4427 | [('a', 'all', None, _('revert all changes when no arguments given')), |
|
4413 | 4428 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
|
4414 | 4429 | ('r', 'rev', '', _('revert to the specified revision'), _('REV')), |
|
4415 | 4430 | ('C', 'no-backup', None, _('do not save backup copies of files')), |
|
4416 | 4431 | ('i', 'interactive', None, |
|
4417 | 4432 | _('interactively select the changes (EXPERIMENTAL)')), |
|
4418 | 4433 | ] + walkopts + dryrunopts, |
|
4419 | 4434 | _('[OPTION]... [-r REV] [NAME]...')) |
|
4420 | 4435 | def revert(ui, repo, *pats, **opts): |
|
4421 | 4436 | """restore files to their checkout state |
|
4422 | 4437 | |
|
4423 | 4438 | .. note:: |
|
4424 | 4439 | |
|
4425 | 4440 | To check out earlier revisions, you should use :hg:`update REV`. |
|
4426 | 4441 | To cancel an uncommitted merge (and lose your changes), |
|
4427 | 4442 | use :hg:`update --clean .`. |
|
4428 | 4443 | |
|
4429 | 4444 | With no revision specified, revert the specified files or directories |
|
4430 | 4445 | to the contents they had in the parent of the working directory. |
|
4431 | 4446 | This restores the contents of files to an unmodified |
|
4432 | 4447 | state and unschedules adds, removes, copies, and renames. If the |
|
4433 | 4448 | working directory has two parents, you must explicitly specify a |
|
4434 | 4449 | revision. |
|
4435 | 4450 | |
|
4436 | 4451 | Using the -r/--rev or -d/--date options, revert the given files or |
|
4437 | 4452 | directories to their states as of a specific revision. Because |
|
4438 | 4453 | revert does not change the working directory parents, this will |
|
4439 | 4454 | cause these files to appear modified. This can be helpful to "back |
|
4440 | 4455 | out" some or all of an earlier change. See :hg:`backout` for a |
|
4441 | 4456 | related method. |
|
4442 | 4457 | |
|
4443 | 4458 | Modified files are saved with a .orig suffix before reverting. |
|
4444 | 4459 | To disable these backups, use --no-backup. It is possible to store |
|
4445 | 4460 | the backup files in a custom directory relative to the root of the |
|
4446 | 4461 | repository by setting the ``ui.origbackuppath`` configuration |
|
4447 | 4462 | option. |
|
4448 | 4463 | |
|
4449 | 4464 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
4450 | 4465 | |
|
4451 | 4466 | See :hg:`help backout` for a way to reverse the effect of an |
|
4452 | 4467 | earlier changeset. |
|
4453 | 4468 | |
|
4454 | 4469 | Returns 0 on success. |
|
4455 | 4470 | """ |
|
4456 | 4471 | |
|
4457 | 4472 | if opts.get("date"): |
|
4458 | 4473 | if opts.get("rev"): |
|
4459 | 4474 | raise error.Abort(_("you can't specify a revision and a date")) |
|
4460 | 4475 | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) |
|
4461 | 4476 | |
|
4462 | 4477 | parent, p2 = repo.dirstate.parents() |
|
4463 | 4478 | if not opts.get('rev') and p2 != nullid: |
|
4464 | 4479 | # revert after merge is a trap for new users (issue2915) |
|
4465 | 4480 | raise error.Abort(_('uncommitted merge with no revision specified'), |
|
4466 | 4481 | hint=_("use 'hg update' or see 'hg help revert'")) |
|
4467 | 4482 | |
|
4468 | 4483 | ctx = scmutil.revsingle(repo, opts.get('rev')) |
|
4469 | 4484 | |
|
4470 | 4485 | if (not (pats or opts.get('include') or opts.get('exclude') or |
|
4471 | 4486 | opts.get('all') or opts.get('interactive'))): |
|
4472 | 4487 | msg = _("no files or directories specified") |
|
4473 | 4488 | if p2 != nullid: |
|
4474 | 4489 | hint = _("uncommitted merge, use --all to discard all changes," |
|
4475 | 4490 | " or 'hg update -C .' to abort the merge") |
|
4476 | 4491 | raise error.Abort(msg, hint=hint) |
|
4477 | 4492 | dirty = any(repo.status()) |
|
4478 | 4493 | node = ctx.node() |
|
4479 | 4494 | if node != parent: |
|
4480 | 4495 | if dirty: |
|
4481 | 4496 | hint = _("uncommitted changes, use --all to discard all" |
|
4482 | 4497 | " changes, or 'hg update %s' to update") % ctx.rev() |
|
4483 | 4498 | else: |
|
4484 | 4499 | hint = _("use --all to revert all files," |
|
4485 | 4500 | " or 'hg update %s' to update") % ctx.rev() |
|
4486 | 4501 | elif dirty: |
|
4487 | 4502 | hint = _("uncommitted changes, use --all to discard all changes") |
|
4488 | 4503 | else: |
|
4489 | 4504 | hint = _("use --all to revert all files") |
|
4490 | 4505 | raise error.Abort(msg, hint=hint) |
|
4491 | 4506 | |
|
4492 | 4507 | return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts) |
|
4493 | 4508 | |
|
4494 | 4509 | @command('rollback', dryrunopts + |
|
4495 | 4510 | [('f', 'force', False, _('ignore safety measures'))]) |
|
4496 | 4511 | def rollback(ui, repo, **opts): |
|
4497 | 4512 | """roll back the last transaction (DANGEROUS) (DEPRECATED) |
|
4498 | 4513 | |
|
4499 | 4514 | Please use :hg:`commit --amend` instead of rollback to correct |
|
4500 | 4515 | mistakes in the last commit. |
|
4501 | 4516 | |
|
4502 | 4517 | This command should be used with care. There is only one level of |
|
4503 | 4518 | rollback, and there is no way to undo a rollback. It will also |
|
4504 | 4519 | restore the dirstate at the time of the last transaction, losing |
|
4505 | 4520 | any dirstate changes since that time. This command does not alter |
|
4506 | 4521 | the working directory. |
|
4507 | 4522 | |
|
4508 | 4523 | Transactions are used to encapsulate the effects of all commands |
|
4509 | 4524 | that create new changesets or propagate existing changesets into a |
|
4510 | 4525 | repository. |
|
4511 | 4526 | |
|
4512 | 4527 | .. container:: verbose |
|
4513 | 4528 | |
|
4514 | 4529 | For example, the following commands are transactional, and their |
|
4515 | 4530 | effects can be rolled back: |
|
4516 | 4531 | |
|
4517 | 4532 | - commit |
|
4518 | 4533 | - import |
|
4519 | 4534 | - pull |
|
4520 | 4535 | - push (with this repository as the destination) |
|
4521 | 4536 | - unbundle |
|
4522 | 4537 | |
|
4523 | 4538 | To avoid permanent data loss, rollback will refuse to rollback a |
|
4524 | 4539 | commit transaction if it isn't checked out. Use --force to |
|
4525 | 4540 | override this protection. |
|
4526 | 4541 | |
|
4527 | 4542 | The rollback command can be entirely disabled by setting the |
|
4528 | 4543 | ``ui.rollback`` configuration setting to false. If you're here |
|
4529 | 4544 | because you want to use rollback and it's disabled, you can |
|
4530 | 4545 | re-enable the command by setting ``ui.rollback`` to true. |
|
4531 | 4546 | |
|
4532 | 4547 | This command is not intended for use on public repositories. Once |
|
4533 | 4548 | changes are visible for pull by other users, rolling a transaction |
|
4534 | 4549 | back locally is ineffective (someone else may already have pulled |
|
4535 | 4550 | the changes). Furthermore, a race is possible with readers of the |
|
4536 | 4551 | repository; for example an in-progress pull from the repository |
|
4537 | 4552 | may fail if a rollback is performed. |
|
4538 | 4553 | |
|
4539 | 4554 | Returns 0 on success, 1 if no rollback data is available. |
|
4540 | 4555 | """ |
|
4541 | 4556 | if not ui.configbool('ui', 'rollback'): |
|
4542 | 4557 | raise error.Abort(_('rollback is disabled because it is unsafe'), |
|
4543 | 4558 | hint=('see `hg help -v rollback` for information')) |
|
4544 | 4559 | return repo.rollback(dryrun=opts.get(r'dry_run'), |
|
4545 | 4560 | force=opts.get(r'force')) |
|
4546 | 4561 | |
|
4547 | 4562 | @command('root', []) |
|
4548 | 4563 | def root(ui, repo): |
|
4549 | 4564 | """print the root (top) of the current working directory |
|
4550 | 4565 | |
|
4551 | 4566 | Print the root directory of the current repository. |
|
4552 | 4567 | |
|
4553 | 4568 | Returns 0 on success. |
|
4554 | 4569 | """ |
|
4555 | 4570 | ui.write(repo.root + "\n") |
|
4556 | 4571 | |
|
4557 | 4572 | @command('^serve', |
|
4558 | 4573 | [('A', 'accesslog', '', _('name of access log file to write to'), |
|
4559 | 4574 | _('FILE')), |
|
4560 | 4575 | ('d', 'daemon', None, _('run server in background')), |
|
4561 | 4576 | ('', 'daemon-postexec', [], _('used internally by daemon mode')), |
|
4562 | 4577 | ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')), |
|
4563 | 4578 | # use string type, then we can check if something was passed |
|
4564 | 4579 | ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')), |
|
4565 | 4580 | ('a', 'address', '', _('address to listen on (default: all interfaces)'), |
|
4566 | 4581 | _('ADDR')), |
|
4567 | 4582 | ('', 'prefix', '', _('prefix path to serve from (default: server root)'), |
|
4568 | 4583 | _('PREFIX')), |
|
4569 | 4584 | ('n', 'name', '', |
|
4570 | 4585 | _('name to show in web pages (default: working directory)'), _('NAME')), |
|
4571 | 4586 | ('', 'web-conf', '', |
|
4572 | 4587 | _("name of the hgweb config file (see 'hg help hgweb')"), _('FILE')), |
|
4573 | 4588 | ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'), |
|
4574 | 4589 | _('FILE')), |
|
4575 | 4590 | ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')), |
|
4576 | 4591 | ('', 'stdio', None, _('for remote clients (ADVANCED)')), |
|
4577 | 4592 | ('', 'cmdserver', '', _('for remote clients (ADVANCED)'), _('MODE')), |
|
4578 | 4593 | ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')), |
|
4579 | 4594 | ('', 'style', '', _('template style to use'), _('STYLE')), |
|
4580 | 4595 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), |
|
4581 | 4596 | ('', 'certificate', '', _('SSL certificate file'), _('FILE'))] |
|
4582 | 4597 | + subrepoopts, |
|
4583 | 4598 | _('[OPTION]...'), |
|
4584 | 4599 | optionalrepo=True) |
|
4585 | 4600 | def serve(ui, repo, **opts): |
|
4586 | 4601 | """start stand-alone webserver |
|
4587 | 4602 | |
|
4588 | 4603 | Start a local HTTP repository browser and pull server. You can use |
|
4589 | 4604 | this for ad-hoc sharing and browsing of repositories. It is |
|
4590 | 4605 | recommended to use a real web server to serve a repository for |
|
4591 | 4606 | longer periods of time. |
|
4592 | 4607 | |
|
4593 | 4608 | Please note that the server does not implement access control. |
|
4594 | 4609 | This means that, by default, anybody can read from the server and |
|
4595 | 4610 | nobody can write to it by default. Set the ``web.allow_push`` |
|
4596 | 4611 | option to ``*`` to allow everybody to push to the server. You |
|
4597 | 4612 | should use a real web server if you need to authenticate users. |
|
4598 | 4613 | |
|
4599 | 4614 | By default, the server logs accesses to stdout and errors to |
|
4600 | 4615 | stderr. Use the -A/--accesslog and -E/--errorlog options to log to |
|
4601 | 4616 | files. |
|
4602 | 4617 | |
|
4603 | 4618 | To have the server choose a free port number to listen on, specify |
|
4604 | 4619 | a port number of 0; in this case, the server will print the port |
|
4605 | 4620 | number it uses. |
|
4606 | 4621 | |
|
4607 | 4622 | Returns 0 on success. |
|
4608 | 4623 | """ |
|
4609 | 4624 | |
|
4610 | 4625 | opts = pycompat.byteskwargs(opts) |
|
4611 | 4626 | if opts["stdio"] and opts["cmdserver"]: |
|
4612 | 4627 | raise error.Abort(_("cannot use --stdio with --cmdserver")) |
|
4613 | 4628 | |
|
4614 | 4629 | if opts["stdio"]: |
|
4615 | 4630 | if repo is None: |
|
4616 | 4631 | raise error.RepoError(_("there is no Mercurial repository here" |
|
4617 | 4632 | " (.hg not found)")) |
|
4618 | 4633 | s = sshserver.sshserver(ui, repo) |
|
4619 | 4634 | s.serve_forever() |
|
4620 | 4635 | |
|
4621 | 4636 | service = server.createservice(ui, repo, opts) |
|
4622 | 4637 | return server.runservice(opts, initfn=service.init, runfn=service.run) |
|
4623 | 4638 | |
|
4624 | 4639 | @command('^status|st', |
|
4625 | 4640 | [('A', 'all', None, _('show status of all files')), |
|
4626 | 4641 | ('m', 'modified', None, _('show only modified files')), |
|
4627 | 4642 | ('a', 'added', None, _('show only added files')), |
|
4628 | 4643 | ('r', 'removed', None, _('show only removed files')), |
|
4629 | 4644 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), |
|
4630 | 4645 | ('c', 'clean', None, _('show only files without changes')), |
|
4631 | 4646 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), |
|
4632 | 4647 | ('i', 'ignored', None, _('show only ignored files')), |
|
4633 | 4648 | ('n', 'no-status', None, _('hide status prefix')), |
|
4634 | 4649 | ('t', 'terse', '', _('show the terse output (EXPERIMENTAL)')), |
|
4635 | 4650 | ('C', 'copies', None, _('show source of copied files')), |
|
4636 | 4651 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
|
4637 | 4652 | ('', 'rev', [], _('show difference from revision'), _('REV')), |
|
4638 | 4653 | ('', 'change', '', _('list the changed files of a revision'), _('REV')), |
|
4639 | 4654 | ] + walkopts + subrepoopts + formatteropts, |
|
4640 | 4655 | _('[OPTION]... [FILE]...'), |
|
4641 | 4656 | inferrepo=True) |
|
4642 | 4657 | def status(ui, repo, *pats, **opts): |
|
4643 | 4658 | """show changed files in the working directory |
|
4644 | 4659 | |
|
4645 | 4660 | Show status of files in the repository. If names are given, only |
|
4646 | 4661 | files that match are shown. Files that are clean or ignored or |
|
4647 | 4662 | the source of a copy/move operation, are not listed unless |
|
4648 | 4663 | -c/--clean, -i/--ignored, -C/--copies or -A/--all are given. |
|
4649 | 4664 | Unless options described with "show only ..." are given, the |
|
4650 | 4665 | options -mardu are used. |
|
4651 | 4666 | |
|
4652 | 4667 | Option -q/--quiet hides untracked (unknown and ignored) files |
|
4653 | 4668 | unless explicitly requested with -u/--unknown or -i/--ignored. |
|
4654 | 4669 | |
|
4655 | 4670 | .. note:: |
|
4656 | 4671 | |
|
4657 | 4672 | :hg:`status` may appear to disagree with diff if permissions have |
|
4658 | 4673 | changed or a merge has occurred. The standard diff format does |
|
4659 | 4674 | not report permission changes and diff only reports changes |
|
4660 | 4675 | relative to one merge parent. |
|
4661 | 4676 | |
|
4662 | 4677 | If one revision is given, it is used as the base revision. |
|
4663 | 4678 | If two revisions are given, the differences between them are |
|
4664 | 4679 | shown. The --change option can also be used as a shortcut to list |
|
4665 | 4680 | the changed files of a revision from its first parent. |
|
4666 | 4681 | |
|
4667 | 4682 | The codes used to show the status of files are:: |
|
4668 | 4683 | |
|
4669 | 4684 | M = modified |
|
4670 | 4685 | A = added |
|
4671 | 4686 | R = removed |
|
4672 | 4687 | C = clean |
|
4673 | 4688 | ! = missing (deleted by non-hg command, but still tracked) |
|
4674 | 4689 | ? = not tracked |
|
4675 | 4690 | I = ignored |
|
4676 | 4691 | = origin of the previous file (with --copies) |
|
4677 | 4692 | |
|
4678 | 4693 | .. container:: verbose |
|
4679 | 4694 | |
|
4680 | 4695 | The -t/--terse option abbreviates the output by showing directory name |
|
4681 | 4696 | if all the files in it share the same status. The option expects a value |
|
4682 | 4697 | which can be a string formed by using 'm', 'a', 'r', 'd', 'u', 'i', 'c' |
|
4683 | 4698 | where, 'm' stands for 'modified', 'a' for 'added', 'r' for 'removed', |
|
4684 | 4699 | 'd' for 'deleted', 'u' for 'unknown', 'i' for 'ignored' and 'c' for clean. |
|
4685 | 4700 | |
|
4686 | 4701 | It terses the output of only those status which are passed. The ignored |
|
4687 | 4702 | files are not considered while tersing until 'i' is there in --terse value |
|
4688 | 4703 | or the --ignored option is used. |
|
4689 | 4704 | |
|
4690 | 4705 | --verbose option shows more context about the state of the repo |
|
4691 | 4706 | like the repository is in unfinised merge, shelve, rebase state etc. |
|
4692 | 4707 | You can have this behaviour turned on by default by following config: |
|
4693 | 4708 | |
|
4694 | 4709 | [commands] |
|
4695 | 4710 | status.verbose = true |
|
4696 | 4711 | |
|
4697 | 4712 | You can also skip some states like bisect by adding following in |
|
4698 | 4713 | configuration file. |
|
4699 | 4714 | |
|
4700 | 4715 | [commands] |
|
4701 | 4716 | status.skipstates = bisect |
|
4702 | 4717 | |
|
4703 | 4718 | Examples: |
|
4704 | 4719 | |
|
4705 | 4720 | - show changes in the working directory relative to a |
|
4706 | 4721 | changeset:: |
|
4707 | 4722 | |
|
4708 | 4723 | hg status --rev 9353 |
|
4709 | 4724 | |
|
4710 | 4725 | - show changes in the working directory relative to the |
|
4711 | 4726 | current directory (see :hg:`help patterns` for more information):: |
|
4712 | 4727 | |
|
4713 | 4728 | hg status re: |
|
4714 | 4729 | |
|
4715 | 4730 | - show all changes including copies in an existing changeset:: |
|
4716 | 4731 | |
|
4717 | 4732 | hg status --copies --change 9353 |
|
4718 | 4733 | |
|
4719 | 4734 | - get a NUL separated list of added files, suitable for xargs:: |
|
4720 | 4735 | |
|
4721 | 4736 | hg status -an0 |
|
4722 | 4737 | |
|
4723 | 4738 | Returns 0 on success. |
|
4724 | 4739 | """ |
|
4725 | 4740 | |
|
4726 | 4741 | opts = pycompat.byteskwargs(opts) |
|
4727 | 4742 | revs = opts.get('rev') |
|
4728 | 4743 | change = opts.get('change') |
|
4729 | 4744 | terse = opts.get('terse') |
|
4730 | 4745 | |
|
4731 | 4746 | if revs and change: |
|
4732 | 4747 | msg = _('cannot specify --rev and --change at the same time') |
|
4733 | 4748 | raise error.Abort(msg) |
|
4734 | 4749 | elif revs and terse: |
|
4735 | 4750 | msg = _('cannot use --terse with --rev') |
|
4736 | 4751 | raise error.Abort(msg) |
|
4737 | 4752 | elif change: |
|
4738 | 4753 | node2 = scmutil.revsingle(repo, change, None).node() |
|
4739 | 4754 | node1 = repo[node2].p1().node() |
|
4740 | 4755 | else: |
|
4741 | 4756 | node1, node2 = scmutil.revpair(repo, revs) |
|
4742 | 4757 | |
|
4743 | 4758 | if pats or ui.configbool('commands', 'status.relative'): |
|
4744 | 4759 | cwd = repo.getcwd() |
|
4745 | 4760 | else: |
|
4746 | 4761 | cwd = '' |
|
4747 | 4762 | |
|
4748 | 4763 | if opts.get('print0'): |
|
4749 | 4764 | end = '\0' |
|
4750 | 4765 | else: |
|
4751 | 4766 | end = '\n' |
|
4752 | 4767 | copy = {} |
|
4753 | 4768 | states = 'modified added removed deleted unknown ignored clean'.split() |
|
4754 | 4769 | show = [k for k in states if opts.get(k)] |
|
4755 | 4770 | if opts.get('all'): |
|
4756 | 4771 | show += ui.quiet and (states[:4] + ['clean']) or states |
|
4757 | 4772 | |
|
4758 | 4773 | if not show: |
|
4759 | 4774 | if ui.quiet: |
|
4760 | 4775 | show = states[:4] |
|
4761 | 4776 | else: |
|
4762 | 4777 | show = states[:5] |
|
4763 | 4778 | |
|
4764 | 4779 | m = scmutil.match(repo[node2], pats, opts) |
|
4765 | 4780 | stat = repo.status(node1, node2, m, |
|
4766 | 4781 | 'ignored' in show, 'clean' in show, 'unknown' in show, |
|
4767 | 4782 | opts.get('subrepos')) |
|
4768 | 4783 | if terse: |
|
4769 | 4784 | stat = cmdutil.tersestatus(repo.root, stat, terse, |
|
4770 | 4785 | repo.dirstate._ignore, opts.get('ignored')) |
|
4771 | 4786 | changestates = zip(states, pycompat.iterbytestr('MAR!?IC'), stat) |
|
4772 | 4787 | |
|
4773 | 4788 | if (opts.get('all') or opts.get('copies') |
|
4774 | 4789 | or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'): |
|
4775 | 4790 | copy = copies.pathcopies(repo[node1], repo[node2], m) |
|
4776 | 4791 | |
|
4777 | 4792 | ui.pager('status') |
|
4778 | 4793 | fm = ui.formatter('status', opts) |
|
4779 | 4794 | fmt = '%s' + end |
|
4780 | 4795 | showchar = not opts.get('no_status') |
|
4781 | 4796 | |
|
4782 | 4797 | for state, char, files in changestates: |
|
4783 | 4798 | if state in show: |
|
4784 | 4799 | label = 'status.' + state |
|
4785 | 4800 | for f in files: |
|
4786 | 4801 | fm.startitem() |
|
4787 | 4802 | fm.condwrite(showchar, 'status', '%s ', char, label=label) |
|
4788 | 4803 | fm.write('path', fmt, repo.pathto(f, cwd), label=label) |
|
4789 | 4804 | if f in copy: |
|
4790 | 4805 | fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), |
|
4791 | 4806 | label='status.copied') |
|
4792 | 4807 | |
|
4793 | 4808 | if ((ui.verbose or ui.configbool('commands', 'status.verbose')) |
|
4794 | 4809 | and not ui.plain()): |
|
4795 | 4810 | cmdutil.morestatus(repo, fm) |
|
4796 | 4811 | fm.end() |
|
4797 | 4812 | |
|
4798 | 4813 | @command('^summary|sum', |
|
4799 | 4814 | [('', 'remote', None, _('check for push and pull'))], '[--remote]') |
|
4800 | 4815 | def summary(ui, repo, **opts): |
|
4801 | 4816 | """summarize working directory state |
|
4802 | 4817 | |
|
4803 | 4818 | This generates a brief summary of the working directory state, |
|
4804 | 4819 | including parents, branch, commit status, phase and available updates. |
|
4805 | 4820 | |
|
4806 | 4821 | With the --remote option, this will check the default paths for |
|
4807 | 4822 | incoming and outgoing changes. This can be time-consuming. |
|
4808 | 4823 | |
|
4809 | 4824 | Returns 0 on success. |
|
4810 | 4825 | """ |
|
4811 | 4826 | |
|
4812 | 4827 | opts = pycompat.byteskwargs(opts) |
|
4813 | 4828 | ui.pager('summary') |
|
4814 | 4829 | ctx = repo[None] |
|
4815 | 4830 | parents = ctx.parents() |
|
4816 | 4831 | pnode = parents[0].node() |
|
4817 | 4832 | marks = [] |
|
4818 | 4833 | |
|
4819 | 4834 | ms = None |
|
4820 | 4835 | try: |
|
4821 | 4836 | ms = mergemod.mergestate.read(repo) |
|
4822 | 4837 | except error.UnsupportedMergeRecords as e: |
|
4823 | 4838 | s = ' '.join(e.recordtypes) |
|
4824 | 4839 | ui.warn( |
|
4825 | 4840 | _('warning: merge state has unsupported record types: %s\n') % s) |
|
4826 | 4841 | unresolved = [] |
|
4827 | 4842 | else: |
|
4828 | 4843 | unresolved = list(ms.unresolved()) |
|
4829 | 4844 | |
|
4830 | 4845 | for p in parents: |
|
4831 | 4846 | # label with log.changeset (instead of log.parent) since this |
|
4832 | 4847 | # shows a working directory parent *changeset*: |
|
4833 | 4848 | # i18n: column positioning for "hg summary" |
|
4834 | 4849 | ui.write(_('parent: %d:%s ') % (p.rev(), p), |
|
4835 | 4850 | label=cmdutil._changesetlabels(p)) |
|
4836 | 4851 | ui.write(' '.join(p.tags()), label='log.tag') |
|
4837 | 4852 | if p.bookmarks(): |
|
4838 | 4853 | marks.extend(p.bookmarks()) |
|
4839 | 4854 | if p.rev() == -1: |
|
4840 | 4855 | if not len(repo): |
|
4841 | 4856 | ui.write(_(' (empty repository)')) |
|
4842 | 4857 | else: |
|
4843 | 4858 | ui.write(_(' (no revision checked out)')) |
|
4844 | 4859 | if p.obsolete(): |
|
4845 | 4860 | ui.write(_(' (obsolete)')) |
|
4846 | 4861 | if p.isunstable(): |
|
4847 | 4862 | instabilities = (ui.label(instability, 'trouble.%s' % instability) |
|
4848 | 4863 | for instability in p.instabilities()) |
|
4849 | 4864 | ui.write(' (' |
|
4850 | 4865 | + ', '.join(instabilities) |
|
4851 | 4866 | + ')') |
|
4852 | 4867 | ui.write('\n') |
|
4853 | 4868 | if p.description(): |
|
4854 | 4869 | ui.status(' ' + p.description().splitlines()[0].strip() + '\n', |
|
4855 | 4870 | label='log.summary') |
|
4856 | 4871 | |
|
4857 | 4872 | branch = ctx.branch() |
|
4858 | 4873 | bheads = repo.branchheads(branch) |
|
4859 | 4874 | # i18n: column positioning for "hg summary" |
|
4860 | 4875 | m = _('branch: %s\n') % branch |
|
4861 | 4876 | if branch != 'default': |
|
4862 | 4877 | ui.write(m, label='log.branch') |
|
4863 | 4878 | else: |
|
4864 | 4879 | ui.status(m, label='log.branch') |
|
4865 | 4880 | |
|
4866 | 4881 | if marks: |
|
4867 | 4882 | active = repo._activebookmark |
|
4868 | 4883 | # i18n: column positioning for "hg summary" |
|
4869 | 4884 | ui.write(_('bookmarks:'), label='log.bookmark') |
|
4870 | 4885 | if active is not None: |
|
4871 | 4886 | if active in marks: |
|
4872 | 4887 | ui.write(' *' + active, label=bookmarks.activebookmarklabel) |
|
4873 | 4888 | marks.remove(active) |
|
4874 | 4889 | else: |
|
4875 | 4890 | ui.write(' [%s]' % active, label=bookmarks.activebookmarklabel) |
|
4876 | 4891 | for m in marks: |
|
4877 | 4892 | ui.write(' ' + m, label='log.bookmark') |
|
4878 | 4893 | ui.write('\n', label='log.bookmark') |
|
4879 | 4894 | |
|
4880 | 4895 | status = repo.status(unknown=True) |
|
4881 | 4896 | |
|
4882 | 4897 | c = repo.dirstate.copies() |
|
4883 | 4898 | copied, renamed = [], [] |
|
4884 | 4899 | for d, s in c.iteritems(): |
|
4885 | 4900 | if s in status.removed: |
|
4886 | 4901 | status.removed.remove(s) |
|
4887 | 4902 | renamed.append(d) |
|
4888 | 4903 | else: |
|
4889 | 4904 | copied.append(d) |
|
4890 | 4905 | if d in status.added: |
|
4891 | 4906 | status.added.remove(d) |
|
4892 | 4907 | |
|
4893 | 4908 | subs = [s for s in ctx.substate if ctx.sub(s).dirty()] |
|
4894 | 4909 | |
|
4895 | 4910 | labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified), |
|
4896 | 4911 | (ui.label(_('%d added'), 'status.added'), status.added), |
|
4897 | 4912 | (ui.label(_('%d removed'), 'status.removed'), status.removed), |
|
4898 | 4913 | (ui.label(_('%d renamed'), 'status.copied'), renamed), |
|
4899 | 4914 | (ui.label(_('%d copied'), 'status.copied'), copied), |
|
4900 | 4915 | (ui.label(_('%d deleted'), 'status.deleted'), status.deleted), |
|
4901 | 4916 | (ui.label(_('%d unknown'), 'status.unknown'), status.unknown), |
|
4902 | 4917 | (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved), |
|
4903 | 4918 | (ui.label(_('%d subrepos'), 'status.modified'), subs)] |
|
4904 | 4919 | t = [] |
|
4905 | 4920 | for l, s in labels: |
|
4906 | 4921 | if s: |
|
4907 | 4922 | t.append(l % len(s)) |
|
4908 | 4923 | |
|
4909 | 4924 | t = ', '.join(t) |
|
4910 | 4925 | cleanworkdir = False |
|
4911 | 4926 | |
|
4912 | 4927 | if repo.vfs.exists('graftstate'): |
|
4913 | 4928 | t += _(' (graft in progress)') |
|
4914 | 4929 | if repo.vfs.exists('updatestate'): |
|
4915 | 4930 | t += _(' (interrupted update)') |
|
4916 | 4931 | elif len(parents) > 1: |
|
4917 | 4932 | t += _(' (merge)') |
|
4918 | 4933 | elif branch != parents[0].branch(): |
|
4919 | 4934 | t += _(' (new branch)') |
|
4920 | 4935 | elif (parents[0].closesbranch() and |
|
4921 | 4936 | pnode in repo.branchheads(branch, closed=True)): |
|
4922 | 4937 | t += _(' (head closed)') |
|
4923 | 4938 | elif not (status.modified or status.added or status.removed or renamed or |
|
4924 | 4939 | copied or subs): |
|
4925 | 4940 | t += _(' (clean)') |
|
4926 | 4941 | cleanworkdir = True |
|
4927 | 4942 | elif pnode not in bheads: |
|
4928 | 4943 | t += _(' (new branch head)') |
|
4929 | 4944 | |
|
4930 | 4945 | if parents: |
|
4931 | 4946 | pendingphase = max(p.phase() for p in parents) |
|
4932 | 4947 | else: |
|
4933 | 4948 | pendingphase = phases.public |
|
4934 | 4949 | |
|
4935 | 4950 | if pendingphase > phases.newcommitphase(ui): |
|
4936 | 4951 | t += ' (%s)' % phases.phasenames[pendingphase] |
|
4937 | 4952 | |
|
4938 | 4953 | if cleanworkdir: |
|
4939 | 4954 | # i18n: column positioning for "hg summary" |
|
4940 | 4955 | ui.status(_('commit: %s\n') % t.strip()) |
|
4941 | 4956 | else: |
|
4942 | 4957 | # i18n: column positioning for "hg summary" |
|
4943 | 4958 | ui.write(_('commit: %s\n') % t.strip()) |
|
4944 | 4959 | |
|
4945 | 4960 | # all ancestors of branch heads - all ancestors of parent = new csets |
|
4946 | 4961 | new = len(repo.changelog.findmissing([pctx.node() for pctx in parents], |
|
4947 | 4962 | bheads)) |
|
4948 | 4963 | |
|
4949 | 4964 | if new == 0: |
|
4950 | 4965 | # i18n: column positioning for "hg summary" |
|
4951 | 4966 | ui.status(_('update: (current)\n')) |
|
4952 | 4967 | elif pnode not in bheads: |
|
4953 | 4968 | # i18n: column positioning for "hg summary" |
|
4954 | 4969 | ui.write(_('update: %d new changesets (update)\n') % new) |
|
4955 | 4970 | else: |
|
4956 | 4971 | # i18n: column positioning for "hg summary" |
|
4957 | 4972 | ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % |
|
4958 | 4973 | (new, len(bheads))) |
|
4959 | 4974 | |
|
4960 | 4975 | t = [] |
|
4961 | 4976 | draft = len(repo.revs('draft()')) |
|
4962 | 4977 | if draft: |
|
4963 | 4978 | t.append(_('%d draft') % draft) |
|
4964 | 4979 | secret = len(repo.revs('secret()')) |
|
4965 | 4980 | if secret: |
|
4966 | 4981 | t.append(_('%d secret') % secret) |
|
4967 | 4982 | |
|
4968 | 4983 | if draft or secret: |
|
4969 | 4984 | ui.status(_('phases: %s\n') % ', '.join(t)) |
|
4970 | 4985 | |
|
4971 | 4986 | if obsolete.isenabled(repo, obsolete.createmarkersopt): |
|
4972 | 4987 | for trouble in ("orphan", "contentdivergent", "phasedivergent"): |
|
4973 | 4988 | numtrouble = len(repo.revs(trouble + "()")) |
|
4974 | 4989 | # We write all the possibilities to ease translation |
|
4975 | 4990 | troublemsg = { |
|
4976 | 4991 | "orphan": _("orphan: %d changesets"), |
|
4977 | 4992 | "contentdivergent": _("content-divergent: %d changesets"), |
|
4978 | 4993 | "phasedivergent": _("phase-divergent: %d changesets"), |
|
4979 | 4994 | } |
|
4980 | 4995 | if numtrouble > 0: |
|
4981 | 4996 | ui.status(troublemsg[trouble] % numtrouble + "\n") |
|
4982 | 4997 | |
|
4983 | 4998 | cmdutil.summaryhooks(ui, repo) |
|
4984 | 4999 | |
|
4985 | 5000 | if opts.get('remote'): |
|
4986 | 5001 | needsincoming, needsoutgoing = True, True |
|
4987 | 5002 | else: |
|
4988 | 5003 | needsincoming, needsoutgoing = False, False |
|
4989 | 5004 | for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None): |
|
4990 | 5005 | if i: |
|
4991 | 5006 | needsincoming = True |
|
4992 | 5007 | if o: |
|
4993 | 5008 | needsoutgoing = True |
|
4994 | 5009 | if not needsincoming and not needsoutgoing: |
|
4995 | 5010 | return |
|
4996 | 5011 | |
|
4997 | 5012 | def getincoming(): |
|
4998 | 5013 | source, branches = hg.parseurl(ui.expandpath('default')) |
|
4999 | 5014 | sbranch = branches[0] |
|
5000 | 5015 | try: |
|
5001 | 5016 | other = hg.peer(repo, {}, source) |
|
5002 | 5017 | except error.RepoError: |
|
5003 | 5018 | if opts.get('remote'): |
|
5004 | 5019 | raise |
|
5005 | 5020 | return source, sbranch, None, None, None |
|
5006 | 5021 | revs, checkout = hg.addbranchrevs(repo, other, branches, None) |
|
5007 | 5022 | if revs: |
|
5008 | 5023 | revs = [other.lookup(rev) for rev in revs] |
|
5009 | 5024 | ui.debug('comparing with %s\n' % util.hidepassword(source)) |
|
5010 | 5025 | repo.ui.pushbuffer() |
|
5011 | 5026 | commoninc = discovery.findcommonincoming(repo, other, heads=revs) |
|
5012 | 5027 | repo.ui.popbuffer() |
|
5013 | 5028 | return source, sbranch, other, commoninc, commoninc[1] |
|
5014 | 5029 | |
|
5015 | 5030 | if needsincoming: |
|
5016 | 5031 | source, sbranch, sother, commoninc, incoming = getincoming() |
|
5017 | 5032 | else: |
|
5018 | 5033 | source = sbranch = sother = commoninc = incoming = None |
|
5019 | 5034 | |
|
5020 | 5035 | def getoutgoing(): |
|
5021 | 5036 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) |
|
5022 | 5037 | dbranch = branches[0] |
|
5023 | 5038 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
|
5024 | 5039 | if source != dest: |
|
5025 | 5040 | try: |
|
5026 | 5041 | dother = hg.peer(repo, {}, dest) |
|
5027 | 5042 | except error.RepoError: |
|
5028 | 5043 | if opts.get('remote'): |
|
5029 | 5044 | raise |
|
5030 | 5045 | return dest, dbranch, None, None |
|
5031 | 5046 | ui.debug('comparing with %s\n' % util.hidepassword(dest)) |
|
5032 | 5047 | elif sother is None: |
|
5033 | 5048 | # there is no explicit destination peer, but source one is invalid |
|
5034 | 5049 | return dest, dbranch, None, None |
|
5035 | 5050 | else: |
|
5036 | 5051 | dother = sother |
|
5037 | 5052 | if (source != dest or (sbranch is not None and sbranch != dbranch)): |
|
5038 | 5053 | common = None |
|
5039 | 5054 | else: |
|
5040 | 5055 | common = commoninc |
|
5041 | 5056 | if revs: |
|
5042 | 5057 | revs = [repo.lookup(rev) for rev in revs] |
|
5043 | 5058 | repo.ui.pushbuffer() |
|
5044 | 5059 | outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs, |
|
5045 | 5060 | commoninc=common) |
|
5046 | 5061 | repo.ui.popbuffer() |
|
5047 | 5062 | return dest, dbranch, dother, outgoing |
|
5048 | 5063 | |
|
5049 | 5064 | if needsoutgoing: |
|
5050 | 5065 | dest, dbranch, dother, outgoing = getoutgoing() |
|
5051 | 5066 | else: |
|
5052 | 5067 | dest = dbranch = dother = outgoing = None |
|
5053 | 5068 | |
|
5054 | 5069 | if opts.get('remote'): |
|
5055 | 5070 | t = [] |
|
5056 | 5071 | if incoming: |
|
5057 | 5072 | t.append(_('1 or more incoming')) |
|
5058 | 5073 | o = outgoing.missing |
|
5059 | 5074 | if o: |
|
5060 | 5075 | t.append(_('%d outgoing') % len(o)) |
|
5061 | 5076 | other = dother or sother |
|
5062 | 5077 | if 'bookmarks' in other.listkeys('namespaces'): |
|
5063 | 5078 | counts = bookmarks.summary(repo, other) |
|
5064 | 5079 | if counts[0] > 0: |
|
5065 | 5080 | t.append(_('%d incoming bookmarks') % counts[0]) |
|
5066 | 5081 | if counts[1] > 0: |
|
5067 | 5082 | t.append(_('%d outgoing bookmarks') % counts[1]) |
|
5068 | 5083 | |
|
5069 | 5084 | if t: |
|
5070 | 5085 | # i18n: column positioning for "hg summary" |
|
5071 | 5086 | ui.write(_('remote: %s\n') % (', '.join(t))) |
|
5072 | 5087 | else: |
|
5073 | 5088 | # i18n: column positioning for "hg summary" |
|
5074 | 5089 | ui.status(_('remote: (synced)\n')) |
|
5075 | 5090 | |
|
5076 | 5091 | cmdutil.summaryremotehooks(ui, repo, opts, |
|
5077 | 5092 | ((source, sbranch, sother, commoninc), |
|
5078 | 5093 | (dest, dbranch, dother, outgoing))) |
|
5079 | 5094 | |
|
5080 | 5095 | @command('tag', |
|
5081 | 5096 | [('f', 'force', None, _('force tag')), |
|
5082 | 5097 | ('l', 'local', None, _('make the tag local')), |
|
5083 | 5098 | ('r', 'rev', '', _('revision to tag'), _('REV')), |
|
5084 | 5099 | ('', 'remove', None, _('remove a tag')), |
|
5085 | 5100 | # -l/--local is already there, commitopts cannot be used |
|
5086 | 5101 | ('e', 'edit', None, _('invoke editor on commit messages')), |
|
5087 | 5102 | ('m', 'message', '', _('use text as commit message'), _('TEXT')), |
|
5088 | 5103 | ] + commitopts2, |
|
5089 | 5104 | _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')) |
|
5090 | 5105 | def tag(ui, repo, name1, *names, **opts): |
|
5091 | 5106 | """add one or more tags for the current or given revision |
|
5092 | 5107 | |
|
5093 | 5108 | Name a particular revision using <name>. |
|
5094 | 5109 | |
|
5095 | 5110 | Tags are used to name particular revisions of the repository and are |
|
5096 | 5111 | very useful to compare different revisions, to go back to significant |
|
5097 | 5112 | earlier versions or to mark branch points as releases, etc. Changing |
|
5098 | 5113 | an existing tag is normally disallowed; use -f/--force to override. |
|
5099 | 5114 | |
|
5100 | 5115 | If no revision is given, the parent of the working directory is |
|
5101 | 5116 | used. |
|
5102 | 5117 | |
|
5103 | 5118 | To facilitate version control, distribution, and merging of tags, |
|
5104 | 5119 | they are stored as a file named ".hgtags" which is managed similarly |
|
5105 | 5120 | to other project files and can be hand-edited if necessary. This |
|
5106 | 5121 | also means that tagging creates a new commit. The file |
|
5107 | 5122 | ".hg/localtags" is used for local tags (not shared among |
|
5108 | 5123 | repositories). |
|
5109 | 5124 | |
|
5110 | 5125 | Tag commits are usually made at the head of a branch. If the parent |
|
5111 | 5126 | of the working directory is not a branch head, :hg:`tag` aborts; use |
|
5112 | 5127 | -f/--force to force the tag commit to be based on a non-head |
|
5113 | 5128 | changeset. |
|
5114 | 5129 | |
|
5115 | 5130 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
5116 | 5131 | |
|
5117 | 5132 | Since tag names have priority over branch names during revision |
|
5118 | 5133 | lookup, using an existing branch name as a tag name is discouraged. |
|
5119 | 5134 | |
|
5120 | 5135 | Returns 0 on success. |
|
5121 | 5136 | """ |
|
5122 | 5137 | opts = pycompat.byteskwargs(opts) |
|
5123 | 5138 | wlock = lock = None |
|
5124 | 5139 | try: |
|
5125 | 5140 | wlock = repo.wlock() |
|
5126 | 5141 | lock = repo.lock() |
|
5127 | 5142 | rev_ = "." |
|
5128 | 5143 | names = [t.strip() for t in (name1,) + names] |
|
5129 | 5144 | if len(names) != len(set(names)): |
|
5130 | 5145 | raise error.Abort(_('tag names must be unique')) |
|
5131 | 5146 | for n in names: |
|
5132 | 5147 | scmutil.checknewlabel(repo, n, 'tag') |
|
5133 | 5148 | if not n: |
|
5134 | 5149 | raise error.Abort(_('tag names cannot consist entirely of ' |
|
5135 | 5150 | 'whitespace')) |
|
5136 | 5151 | if opts.get('rev') and opts.get('remove'): |
|
5137 | 5152 | raise error.Abort(_("--rev and --remove are incompatible")) |
|
5138 | 5153 | if opts.get('rev'): |
|
5139 | 5154 | rev_ = opts['rev'] |
|
5140 | 5155 | message = opts.get('message') |
|
5141 | 5156 | if opts.get('remove'): |
|
5142 | 5157 | if opts.get('local'): |
|
5143 | 5158 | expectedtype = 'local' |
|
5144 | 5159 | else: |
|
5145 | 5160 | expectedtype = 'global' |
|
5146 | 5161 | |
|
5147 | 5162 | for n in names: |
|
5148 | 5163 | if not repo.tagtype(n): |
|
5149 | 5164 | raise error.Abort(_("tag '%s' does not exist") % n) |
|
5150 | 5165 | if repo.tagtype(n) != expectedtype: |
|
5151 | 5166 | if expectedtype == 'global': |
|
5152 | 5167 | raise error.Abort(_("tag '%s' is not a global tag") % n) |
|
5153 | 5168 | else: |
|
5154 | 5169 | raise error.Abort(_("tag '%s' is not a local tag") % n) |
|
5155 | 5170 | rev_ = 'null' |
|
5156 | 5171 | if not message: |
|
5157 | 5172 | # we don't translate commit messages |
|
5158 | 5173 | message = 'Removed tag %s' % ', '.join(names) |
|
5159 | 5174 | elif not opts.get('force'): |
|
5160 | 5175 | for n in names: |
|
5161 | 5176 | if n in repo.tags(): |
|
5162 | 5177 | raise error.Abort(_("tag '%s' already exists " |
|
5163 | 5178 | "(use -f to force)") % n) |
|
5164 | 5179 | if not opts.get('local'): |
|
5165 | 5180 | p1, p2 = repo.dirstate.parents() |
|
5166 | 5181 | if p2 != nullid: |
|
5167 | 5182 | raise error.Abort(_('uncommitted merge')) |
|
5168 | 5183 | bheads = repo.branchheads() |
|
5169 | 5184 | if not opts.get('force') and bheads and p1 not in bheads: |
|
5170 | 5185 | raise error.Abort(_('working directory is not at a branch head ' |
|
5171 | 5186 | '(use -f to force)')) |
|
5172 | 5187 | r = scmutil.revsingle(repo, rev_).node() |
|
5173 | 5188 | |
|
5174 | 5189 | if not message: |
|
5175 | 5190 | # we don't translate commit messages |
|
5176 | 5191 | message = ('Added tag %s for changeset %s' % |
|
5177 | 5192 | (', '.join(names), short(r))) |
|
5178 | 5193 | |
|
5179 | 5194 | date = opts.get('date') |
|
5180 | 5195 | if date: |
|
5181 | 5196 | date = util.parsedate(date) |
|
5182 | 5197 | |
|
5183 | 5198 | if opts.get('remove'): |
|
5184 | 5199 | editform = 'tag.remove' |
|
5185 | 5200 | else: |
|
5186 | 5201 | editform = 'tag.add' |
|
5187 | 5202 | editor = cmdutil.getcommiteditor(editform=editform, |
|
5188 | 5203 | **pycompat.strkwargs(opts)) |
|
5189 | 5204 | |
|
5190 | 5205 | # don't allow tagging the null rev |
|
5191 | 5206 | if (not opts.get('remove') and |
|
5192 | 5207 | scmutil.revsingle(repo, rev_).rev() == nullrev): |
|
5193 | 5208 | raise error.Abort(_("cannot tag null revision")) |
|
5194 | 5209 | |
|
5195 | 5210 | tagsmod.tag(repo, names, r, message, opts.get('local'), |
|
5196 | 5211 | opts.get('user'), date, editor=editor) |
|
5197 | 5212 | finally: |
|
5198 | 5213 | release(lock, wlock) |
|
5199 | 5214 | |
|
5200 | 5215 | @command('tags', formatteropts, '') |
|
5201 | 5216 | def tags(ui, repo, **opts): |
|
5202 | 5217 | """list repository tags |
|
5203 | 5218 | |
|
5204 | 5219 | This lists both regular and local tags. When the -v/--verbose |
|
5205 | 5220 | switch is used, a third column "local" is printed for local tags. |
|
5206 | 5221 | When the -q/--quiet switch is used, only the tag name is printed. |
|
5207 | 5222 | |
|
5208 | 5223 | Returns 0 on success. |
|
5209 | 5224 | """ |
|
5210 | 5225 | |
|
5211 | 5226 | opts = pycompat.byteskwargs(opts) |
|
5212 | 5227 | ui.pager('tags') |
|
5213 | 5228 | fm = ui.formatter('tags', opts) |
|
5214 | 5229 | hexfunc = fm.hexfunc |
|
5215 | 5230 | tagtype = "" |
|
5216 | 5231 | |
|
5217 | 5232 | for t, n in reversed(repo.tagslist()): |
|
5218 | 5233 | hn = hexfunc(n) |
|
5219 | 5234 | label = 'tags.normal' |
|
5220 | 5235 | tagtype = '' |
|
5221 | 5236 | if repo.tagtype(t) == 'local': |
|
5222 | 5237 | label = 'tags.local' |
|
5223 | 5238 | tagtype = 'local' |
|
5224 | 5239 | |
|
5225 | 5240 | fm.startitem() |
|
5226 | 5241 | fm.write('tag', '%s', t, label=label) |
|
5227 | 5242 | fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s' |
|
5228 | 5243 | fm.condwrite(not ui.quiet, 'rev node', fmt, |
|
5229 | 5244 | repo.changelog.rev(n), hn, label=label) |
|
5230 | 5245 | fm.condwrite(ui.verbose and tagtype, 'type', ' %s', |
|
5231 | 5246 | tagtype, label=label) |
|
5232 | 5247 | fm.plain('\n') |
|
5233 | 5248 | fm.end() |
|
5234 | 5249 | |
|
5235 | 5250 | @command('tip', |
|
5236 | 5251 | [('p', 'patch', None, _('show patch')), |
|
5237 | 5252 | ('g', 'git', None, _('use git extended diff format')), |
|
5238 | 5253 | ] + templateopts, |
|
5239 | 5254 | _('[-p] [-g]')) |
|
5240 | 5255 | def tip(ui, repo, **opts): |
|
5241 | 5256 | """show the tip revision (DEPRECATED) |
|
5242 | 5257 | |
|
5243 | 5258 | The tip revision (usually just called the tip) is the changeset |
|
5244 | 5259 | most recently added to the repository (and therefore the most |
|
5245 | 5260 | recently changed head). |
|
5246 | 5261 | |
|
5247 | 5262 | If you have just made a commit, that commit will be the tip. If |
|
5248 | 5263 | you have just pulled changes from another repository, the tip of |
|
5249 | 5264 | that repository becomes the current tip. The "tip" tag is special |
|
5250 | 5265 | and cannot be renamed or assigned to a different changeset. |
|
5251 | 5266 | |
|
5252 | 5267 | This command is deprecated, please use :hg:`heads` instead. |
|
5253 | 5268 | |
|
5254 | 5269 | Returns 0 on success. |
|
5255 | 5270 | """ |
|
5256 | 5271 | opts = pycompat.byteskwargs(opts) |
|
5257 | 5272 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
5258 | 5273 | displayer.show(repo['tip']) |
|
5259 | 5274 | displayer.close() |
|
5260 | 5275 | |
|
5261 | 5276 | @command('unbundle', |
|
5262 | 5277 | [('u', 'update', None, |
|
5263 | 5278 | _('update to new branch head if changesets were unbundled'))], |
|
5264 | 5279 | _('[-u] FILE...')) |
|
5265 | 5280 | def unbundle(ui, repo, fname1, *fnames, **opts): |
|
5266 | 5281 | """apply one or more bundle files |
|
5267 | 5282 | |
|
5268 | 5283 | Apply one or more bundle files generated by :hg:`bundle`. |
|
5269 | 5284 | |
|
5270 | 5285 | Returns 0 on success, 1 if an update has unresolved files. |
|
5271 | 5286 | """ |
|
5272 | 5287 | fnames = (fname1,) + fnames |
|
5273 | 5288 | |
|
5274 | 5289 | with repo.lock(): |
|
5275 | 5290 | for fname in fnames: |
|
5276 | 5291 | f = hg.openpath(ui, fname) |
|
5277 | 5292 | gen = exchange.readbundle(ui, f, fname) |
|
5278 | 5293 | if isinstance(gen, streamclone.streamcloneapplier): |
|
5279 | 5294 | raise error.Abort( |
|
5280 | 5295 | _('packed bundles cannot be applied with ' |
|
5281 | 5296 | '"hg unbundle"'), |
|
5282 | 5297 | hint=_('use "hg debugapplystreamclonebundle"')) |
|
5283 | 5298 | url = 'bundle:' + fname |
|
5284 | 5299 | try: |
|
5285 | 5300 | txnname = 'unbundle' |
|
5286 | 5301 | if not isinstance(gen, bundle2.unbundle20): |
|
5287 | 5302 | txnname = 'unbundle\n%s' % util.hidepassword(url) |
|
5288 | 5303 | with repo.transaction(txnname) as tr: |
|
5289 | 5304 | op = bundle2.applybundle(repo, gen, tr, source='unbundle', |
|
5290 | 5305 | url=url) |
|
5291 | 5306 | except error.BundleUnknownFeatureError as exc: |
|
5292 | 5307 | raise error.Abort( |
|
5293 | 5308 | _('%s: unknown bundle feature, %s') % (fname, exc), |
|
5294 | 5309 | hint=_("see https://mercurial-scm.org/" |
|
5295 | 5310 | "wiki/BundleFeature for more " |
|
5296 | 5311 | "information")) |
|
5297 | 5312 | modheads = bundle2.combinechangegroupresults(op) |
|
5298 | 5313 | |
|
5299 | 5314 | return postincoming(ui, repo, modheads, opts.get(r'update'), None, None) |
|
5300 | 5315 | |
|
5301 | 5316 | @command('^update|up|checkout|co', |
|
5302 | 5317 | [('C', 'clean', None, _('discard uncommitted changes (no backup)')), |
|
5303 | 5318 | ('c', 'check', None, _('require clean working directory')), |
|
5304 | 5319 | ('m', 'merge', None, _('merge uncommitted changes')), |
|
5305 | 5320 | ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
|
5306 | 5321 | ('r', 'rev', '', _('revision'), _('REV')) |
|
5307 | 5322 | ] + mergetoolopts, |
|
5308 | 5323 | _('[-C|-c|-m] [-d DATE] [[-r] REV]')) |
|
5309 | 5324 | def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False, |
|
5310 | 5325 | merge=None, tool=None): |
|
5311 | 5326 | """update working directory (or switch revisions) |
|
5312 | 5327 | |
|
5313 | 5328 | Update the repository's working directory to the specified |
|
5314 | 5329 | changeset. If no changeset is specified, update to the tip of the |
|
5315 | 5330 | current named branch and move the active bookmark (see :hg:`help |
|
5316 | 5331 | bookmarks`). |
|
5317 | 5332 | |
|
5318 | 5333 | Update sets the working directory's parent revision to the specified |
|
5319 | 5334 | changeset (see :hg:`help parents`). |
|
5320 | 5335 | |
|
5321 | 5336 | If the changeset is not a descendant or ancestor of the working |
|
5322 | 5337 | directory's parent and there are uncommitted changes, the update is |
|
5323 | 5338 | aborted. With the -c/--check option, the working directory is checked |
|
5324 | 5339 | for uncommitted changes; if none are found, the working directory is |
|
5325 | 5340 | updated to the specified changeset. |
|
5326 | 5341 | |
|
5327 | 5342 | .. container:: verbose |
|
5328 | 5343 | |
|
5329 | 5344 | The -C/--clean, -c/--check, and -m/--merge options control what |
|
5330 | 5345 | happens if the working directory contains uncommitted changes. |
|
5331 | 5346 | At most of one of them can be specified. |
|
5332 | 5347 | |
|
5333 | 5348 | 1. If no option is specified, and if |
|
5334 | 5349 | the requested changeset is an ancestor or descendant of |
|
5335 | 5350 | the working directory's parent, the uncommitted changes |
|
5336 | 5351 | are merged into the requested changeset and the merged |
|
5337 | 5352 | result is left uncommitted. If the requested changeset is |
|
5338 | 5353 | not an ancestor or descendant (that is, it is on another |
|
5339 | 5354 | branch), the update is aborted and the uncommitted changes |
|
5340 | 5355 | are preserved. |
|
5341 | 5356 | |
|
5342 | 5357 | 2. With the -m/--merge option, the update is allowed even if the |
|
5343 | 5358 | requested changeset is not an ancestor or descendant of |
|
5344 | 5359 | the working directory's parent. |
|
5345 | 5360 | |
|
5346 | 5361 | 3. With the -c/--check option, the update is aborted and the |
|
5347 | 5362 | uncommitted changes are preserved. |
|
5348 | 5363 | |
|
5349 | 5364 | 4. With the -C/--clean option, uncommitted changes are discarded and |
|
5350 | 5365 | the working directory is updated to the requested changeset. |
|
5351 | 5366 | |
|
5352 | 5367 | To cancel an uncommitted merge (and lose your changes), use |
|
5353 | 5368 | :hg:`update --clean .`. |
|
5354 | 5369 | |
|
5355 | 5370 | Use null as the changeset to remove the working directory (like |
|
5356 | 5371 | :hg:`clone -U`). |
|
5357 | 5372 | |
|
5358 | 5373 | If you want to revert just one file to an older revision, use |
|
5359 | 5374 | :hg:`revert [-r REV] NAME`. |
|
5360 | 5375 | |
|
5361 | 5376 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
5362 | 5377 | |
|
5363 | 5378 | Returns 0 on success, 1 if there are unresolved files. |
|
5364 | 5379 | """ |
|
5365 | 5380 | if rev and node: |
|
5366 | 5381 | raise error.Abort(_("please specify just one revision")) |
|
5367 | 5382 | |
|
5368 | 5383 | if ui.configbool('commands', 'update.requiredest'): |
|
5369 | 5384 | if not node and not rev and not date: |
|
5370 | 5385 | raise error.Abort(_('you must specify a destination'), |
|
5371 | 5386 | hint=_('for example: hg update ".::"')) |
|
5372 | 5387 | |
|
5373 | 5388 | if rev is None or rev == '': |
|
5374 | 5389 | rev = node |
|
5375 | 5390 | |
|
5376 | 5391 | if date and rev is not None: |
|
5377 | 5392 | raise error.Abort(_("you can't specify a revision and a date")) |
|
5378 | 5393 | |
|
5379 | 5394 | if len([x for x in (clean, check, merge) if x]) > 1: |
|
5380 | 5395 | raise error.Abort(_("can only specify one of -C/--clean, -c/--check, " |
|
5381 | 5396 | "or -m/merge")) |
|
5382 | 5397 | |
|
5383 | 5398 | updatecheck = None |
|
5384 | 5399 | if check: |
|
5385 | 5400 | updatecheck = 'abort' |
|
5386 | 5401 | elif merge: |
|
5387 | 5402 | updatecheck = 'none' |
|
5388 | 5403 | |
|
5389 | 5404 | with repo.wlock(): |
|
5390 | 5405 | cmdutil.clearunfinished(repo) |
|
5391 | 5406 | |
|
5392 | 5407 | if date: |
|
5393 | 5408 | rev = cmdutil.finddate(ui, repo, date) |
|
5394 | 5409 | |
|
5395 | 5410 | # if we defined a bookmark, we have to remember the original name |
|
5396 | 5411 | brev = rev |
|
5397 | 5412 | rev = scmutil.revsingle(repo, rev, rev).rev() |
|
5398 | 5413 | |
|
5399 | 5414 | repo.ui.setconfig('ui', 'forcemerge', tool, 'update') |
|
5400 | 5415 | |
|
5401 | 5416 | return hg.updatetotally(ui, repo, rev, brev, clean=clean, |
|
5402 | 5417 | updatecheck=updatecheck) |
|
5403 | 5418 | |
|
5404 | 5419 | @command('verify', []) |
|
5405 | 5420 | def verify(ui, repo): |
|
5406 | 5421 | """verify the integrity of the repository |
|
5407 | 5422 | |
|
5408 | 5423 | Verify the integrity of the current repository. |
|
5409 | 5424 | |
|
5410 | 5425 | This will perform an extensive check of the repository's |
|
5411 | 5426 | integrity, validating the hashes and checksums of each entry in |
|
5412 | 5427 | the changelog, manifest, and tracked files, as well as the |
|
5413 | 5428 | integrity of their crosslinks and indices. |
|
5414 | 5429 | |
|
5415 | 5430 | Please see https://mercurial-scm.org/wiki/RepositoryCorruption |
|
5416 | 5431 | for more information about recovery from corruption of the |
|
5417 | 5432 | repository. |
|
5418 | 5433 | |
|
5419 | 5434 | Returns 0 on success, 1 if errors are encountered. |
|
5420 | 5435 | """ |
|
5421 | 5436 | return hg.verify(repo) |
|
5422 | 5437 | |
|
5423 | 5438 | @command('version', [] + formatteropts, norepo=True) |
|
5424 | 5439 | def version_(ui, **opts): |
|
5425 | 5440 | """output version and copyright information""" |
|
5426 | 5441 | opts = pycompat.byteskwargs(opts) |
|
5427 | 5442 | if ui.verbose: |
|
5428 | 5443 | ui.pager('version') |
|
5429 | 5444 | fm = ui.formatter("version", opts) |
|
5430 | 5445 | fm.startitem() |
|
5431 | 5446 | fm.write("ver", _("Mercurial Distributed SCM (version %s)\n"), |
|
5432 | 5447 | util.version()) |
|
5433 | 5448 | license = _( |
|
5434 | 5449 | "(see https://mercurial-scm.org for more information)\n" |
|
5435 | 5450 | "\nCopyright (C) 2005-2017 Matt Mackall and others\n" |
|
5436 | 5451 | "This is free software; see the source for copying conditions. " |
|
5437 | 5452 | "There is NO\nwarranty; " |
|
5438 | 5453 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
5439 | 5454 | ) |
|
5440 | 5455 | if not ui.quiet: |
|
5441 | 5456 | fm.plain(license) |
|
5442 | 5457 | |
|
5443 | 5458 | if ui.verbose: |
|
5444 | 5459 | fm.plain(_("\nEnabled extensions:\n\n")) |
|
5445 | 5460 | # format names and versions into columns |
|
5446 | 5461 | names = [] |
|
5447 | 5462 | vers = [] |
|
5448 | 5463 | isinternals = [] |
|
5449 | 5464 | for name, module in extensions.extensions(): |
|
5450 | 5465 | names.append(name) |
|
5451 | 5466 | vers.append(extensions.moduleversion(module) or None) |
|
5452 | 5467 | isinternals.append(extensions.ismoduleinternal(module)) |
|
5453 | 5468 | fn = fm.nested("extensions") |
|
5454 | 5469 | if names: |
|
5455 | 5470 | namefmt = " %%-%ds " % max(len(n) for n in names) |
|
5456 | 5471 | places = [_("external"), _("internal")] |
|
5457 | 5472 | for n, v, p in zip(names, vers, isinternals): |
|
5458 | 5473 | fn.startitem() |
|
5459 | 5474 | fn.condwrite(ui.verbose, "name", namefmt, n) |
|
5460 | 5475 | if ui.verbose: |
|
5461 | 5476 | fn.plain("%s " % places[p]) |
|
5462 | 5477 | fn.data(bundled=p) |
|
5463 | 5478 | fn.condwrite(ui.verbose and v, "ver", "%s", v) |
|
5464 | 5479 | if ui.verbose: |
|
5465 | 5480 | fn.plain("\n") |
|
5466 | 5481 | fn.end() |
|
5467 | 5482 | fm.end() |
|
5468 | 5483 | |
|
5469 | 5484 | def loadcmdtable(ui, name, cmdtable): |
|
5470 | 5485 | """Load command functions from specified cmdtable |
|
5471 | 5486 | """ |
|
5472 | 5487 | overrides = [cmd for cmd in cmdtable if cmd in table] |
|
5473 | 5488 | if overrides: |
|
5474 | 5489 | ui.warn(_("extension '%s' overrides commands: %s\n") |
|
5475 | 5490 | % (name, " ".join(overrides))) |
|
5476 | 5491 | table.update(cmdtable) |
@@ -1,921 +1,921 b'' | |||
|
1 | 1 | The Mercurial wire protocol is a request-response based protocol |
|
2 | 2 | with multiple wire representations. |
|
3 | 3 | |
|
4 | 4 | Each request is modeled as a command name, a dictionary of arguments, and |
|
5 | 5 | optional raw input. Command arguments and their types are intrinsic |
|
6 | 6 | properties of commands. So is the response type of the command. This means |
|
7 | 7 | clients can't always send arbitrary arguments to servers and servers can't |
|
8 | 8 | return multiple response types. |
|
9 | 9 | |
|
10 | 10 | The protocol is synchronous and does not support multiplexing (concurrent |
|
11 | 11 | commands). |
|
12 | 12 | |
|
13 | 13 | Transport Protocols |
|
14 | 14 | =================== |
|
15 | 15 | |
|
16 | 16 | HTTP Transport |
|
17 | 17 | -------------- |
|
18 | 18 | |
|
19 | 19 | Commands are issued as HTTP/1.0 or HTTP/1.1 requests. Commands are |
|
20 | 20 | sent to the base URL of the repository with the command name sent in |
|
21 | 21 | the ``cmd`` query string parameter. e.g. |
|
22 | 22 | ``https://example.com/repo?cmd=capabilities``. The HTTP method is ``GET`` |
|
23 | 23 | or ``POST`` depending on the command and whether there is a request |
|
24 | 24 | body. |
|
25 | 25 | |
|
26 | 26 | Command arguments can be sent multiple ways. |
|
27 | 27 | |
|
28 | 28 | The simplest is part of the URL query string using ``x-www-form-urlencoded`` |
|
29 | 29 | encoding (see Python's ``urllib.urlencode()``. However, many servers impose |
|
30 | 30 | length limitations on the URL. So this mechanism is typically only used if |
|
31 | 31 | the server doesn't support other mechanisms. |
|
32 | 32 | |
|
33 | 33 | If the server supports the ``httpheader`` capability, command arguments can |
|
34 | 34 | be sent in HTTP request headers named ``X-HgArg-<N>`` where ``<N>`` is an |
|
35 | 35 | integer starting at 1. A ``x-www-form-urlencoded`` representation of the |
|
36 | 36 | arguments is obtained. This full string is then split into chunks and sent |
|
37 | 37 | in numbered ``X-HgArg-<N>`` headers. The maximum length of each HTTP header |
|
38 | 38 | is defined by the server in the ``httpheader`` capability value, which defaults |
|
39 | 39 | to ``1024``. The server reassembles the encoded arguments string by |
|
40 | 40 | concatenating the ``X-HgArg-<N>`` headers then URL decodes them into a |
|
41 | 41 | dictionary. |
|
42 | 42 | |
|
43 | 43 | The list of ``X-HgArg-<N>`` headers should be added to the ``Vary`` request |
|
44 | 44 | header to instruct caches to take these headers into consideration when caching |
|
45 | 45 | requests. |
|
46 | 46 | |
|
47 | 47 | If the server supports the ``httppostargs`` capability, the client |
|
48 | 48 | may send command arguments in the HTTP request body as part of an |
|
49 | 49 | HTTP POST request. The command arguments will be URL encoded just like |
|
50 | 50 | they would for sending them via HTTP headers. However, no splitting is |
|
51 | 51 | performed: the raw arguments are included in the HTTP request body. |
|
52 | 52 | |
|
53 | 53 | The client sends a ``X-HgArgs-Post`` header with the string length of the |
|
54 | 54 | encoded arguments data. Additional data may be included in the HTTP |
|
55 | 55 | request body immediately following the argument data. The offset of the |
|
56 | 56 | non-argument data is defined by the ``X-HgArgs-Post`` header. The |
|
57 | 57 | ``X-HgArgs-Post`` header is not required if there is no argument data. |
|
58 | 58 | |
|
59 | 59 | Additional command data can be sent as part of the HTTP request body. The |
|
60 | 60 | default ``Content-Type`` when sending data is ``application/mercurial-0.1``. |
|
61 | 61 | A ``Content-Length`` header is currently always sent. |
|
62 | 62 | |
|
63 | 63 | Example HTTP requests:: |
|
64 | 64 | |
|
65 | 65 | GET /repo?cmd=capabilities |
|
66 | 66 | X-HgArg-1: foo=bar&baz=hello%20world |
|
67 | 67 | |
|
68 | 68 | The request media type should be chosen based on server support. If the |
|
69 | 69 | ``httpmediatype`` server capability is present, the client should send |
|
70 | 70 | the newest mutually supported media type. If this capability is absent, |
|
71 | 71 | the client must assume the server only supports the |
|
72 | 72 | ``application/mercurial-0.1`` media type. |
|
73 | 73 | |
|
74 | 74 | The ``Content-Type`` HTTP response header identifies the response as coming |
|
75 | 75 | from Mercurial and can also be used to signal an error has occurred. |
|
76 | 76 | |
|
77 | 77 | The ``application/mercurial-*`` media types indicate a generic Mercurial |
|
78 | 78 | data type. |
|
79 | 79 | |
|
80 | 80 | The ``application/mercurial-0.1`` media type is raw Mercurial data. It is the |
|
81 | 81 | predecessor of the format below. |
|
82 | 82 | |
|
83 | 83 | The ``application/mercurial-0.2`` media type is compression framed Mercurial |
|
84 | 84 | data. The first byte of the payload indicates the length of the compression |
|
85 | 85 | format identifier that follows. Next are N bytes indicating the compression |
|
86 | 86 | format. e.g. ``zlib``. The remaining bytes are compressed according to that |
|
87 | 87 | compression format. The decompressed data behaves the same as with |
|
88 | 88 | ``application/mercurial-0.1``. |
|
89 | 89 | |
|
90 | 90 | The ``application/hg-error`` media type indicates a generic error occurred. |
|
91 | 91 | The content of the HTTP response body typically holds text describing the |
|
92 | 92 | error. |
|
93 | 93 | |
|
94 | 94 | The ``application/hg-changegroup`` media type indicates a changegroup response |
|
95 | 95 | type. |
|
96 | 96 | |
|
97 | 97 | Clients also accept the ``text/plain`` media type. All other media |
|
98 | 98 | types should cause the client to error. |
|
99 | 99 | |
|
100 | 100 | Behavior of media types is further described in the ``Content Negotiation`` |
|
101 | 101 | section below. |
|
102 | 102 | |
|
103 | 103 | Clients should issue a ``User-Agent`` request header that identifies the client. |
|
104 | 104 | The server should not use the ``User-Agent`` for feature detection. |
|
105 | 105 | |
|
106 | 106 | A command returning a ``string`` response issues a |
|
107 | 107 | ``application/mercurial-0.*`` media type and the HTTP response body contains |
|
108 | 108 | the raw string value (after compression decoding, if used). A |
|
109 | 109 | ``Content-Length`` header is typically issued, but not required. |
|
110 | 110 | |
|
111 | 111 | A command returning a ``stream`` response issues a |
|
112 | 112 | ``application/mercurial-0.*`` media type and the HTTP response is typically |
|
113 | 113 | using *chunked transfer* (``Transfer-Encoding: chunked``). |
|
114 | 114 | |
|
115 | 115 | SSH Transport |
|
116 | 116 | ============= |
|
117 | 117 | |
|
118 | 118 | The SSH transport is a custom text-based protocol suitable for use over any |
|
119 | 119 | bi-directional stream transport. It is most commonly used with SSH. |
|
120 | 120 | |
|
121 | 121 | A SSH transport server can be started with ``hg serve --stdio``. The stdin, |
|
122 | 122 | stderr, and stdout file descriptors of the started process are used to exchange |
|
123 | 123 | data. When Mercurial connects to a remote server over SSH, it actually starts |
|
124 | 124 | a ``hg serve --stdio`` process on the remote server. |
|
125 | 125 | |
|
126 | 126 | Commands are issued by sending the command name followed by a trailing newline |
|
127 | 127 | ``\n`` to the server. e.g. ``capabilities\n``. |
|
128 | 128 | |
|
129 | 129 | Command arguments are sent in the following format:: |
|
130 | 130 | |
|
131 | 131 | <argument> <length>\n<value> |
|
132 | 132 | |
|
133 | 133 | That is, the argument string name followed by a space followed by the |
|
134 | 134 | integer length of the value (expressed as a string) followed by a newline |
|
135 | 135 | (``\n``) followed by the raw argument value. |
|
136 | 136 | |
|
137 | 137 | Dictionary arguments are encoded differently:: |
|
138 | 138 | |
|
139 | 139 | <argument> <# elements>\n |
|
140 | 140 | <key1> <length1>\n<value1> |
|
141 | 141 | <key2> <length2>\n<value2> |
|
142 | 142 | ... |
|
143 | 143 | |
|
144 | 144 | Non-argument data is sent immediately after the final argument value. It is |
|
145 | 145 | encoded in chunks:: |
|
146 | 146 | |
|
147 | 147 | <length>\n<data> |
|
148 | 148 | |
|
149 | 149 | Each command declares a list of supported arguments and their types. If a |
|
150 | 150 | client sends an unknown argument to the server, the server should abort |
|
151 | 151 | immediately. The special argument ``*`` in a command's definition indicates |
|
152 | 152 | that all argument names are allowed. |
|
153 | 153 | |
|
154 | 154 | The definition of supported arguments and types is initially made when a |
|
155 | 155 | new command is implemented. The client and server must initially independently |
|
156 | 156 | agree on the arguments and their types. This initial set of arguments can be |
|
157 | 157 | supplemented through the presence of *capabilities* advertised by the server. |
|
158 | 158 | |
|
159 | 159 | Each command has a defined expected response type. |
|
160 | 160 | |
|
161 | 161 | A ``string`` response type is a length framed value. The response consists of |
|
162 | 162 | the string encoded integer length of a value followed by a newline (``\n``) |
|
163 | 163 | followed by the value. Empty values are allowed (and are represented as |
|
164 | 164 | ``0\n``). |
|
165 | 165 | |
|
166 | 166 | A ``stream`` response type consists of raw bytes of data. There is no framing. |
|
167 | 167 | |
|
168 | 168 | A generic error response type is also supported. It consists of a an error |
|
169 | 169 | message written to ``stderr`` followed by ``\n-\n``. In addition, ``\n`` is |
|
170 | 170 | written to ``stdout``. |
|
171 | 171 | |
|
172 | 172 | If the server receives an unknown command, it will send an empty ``string`` |
|
173 | 173 | response. |
|
174 | 174 | |
|
175 | 175 | The server terminates if it receives an empty command (a ``\n`` character). |
|
176 | 176 | |
|
177 | 177 | Capabilities |
|
178 | 178 | ============ |
|
179 | 179 | |
|
180 | 180 | Servers advertise supported wire protocol features. This allows clients to |
|
181 | 181 | probe for server features before blindly calling a command or passing a |
|
182 | 182 | specific argument. |
|
183 | 183 | |
|
184 | 184 | The server's features are exposed via a *capabilities* string. This is a |
|
185 | 185 | space-delimited string of tokens/features. Some features are single words |
|
186 | 186 | like ``lookup`` or ``batch``. Others are complicated key-value pairs |
|
187 | 187 | advertising sub-features. e.g. ``httpheader=2048``. When complex, non-word |
|
188 | 188 | values are used, each feature name can define its own encoding of sub-values. |
|
189 | 189 | Comma-delimited and ``x-www-form-urlencoded`` values are common. |
|
190 | 190 | |
|
191 | 191 | The following document capabilities defined by the canonical Mercurial server |
|
192 | 192 | implementation. |
|
193 | 193 | |
|
194 | 194 | batch |
|
195 | 195 | ----- |
|
196 | 196 | |
|
197 | 197 | Whether the server supports the ``batch`` command. |
|
198 | 198 | |
|
199 | 199 | This capability/command was introduced in Mercurial 1.9 (released July 2011). |
|
200 | 200 | |
|
201 | 201 | branchmap |
|
202 | 202 | --------- |
|
203 | 203 | |
|
204 | 204 | Whether the server supports the ``branchmap`` command. |
|
205 | 205 | |
|
206 | 206 | This capability/command was introduced in Mercurial 1.3 (released July 2009). |
|
207 | 207 | |
|
208 | 208 | bundle2-exp |
|
209 | 209 | ----------- |
|
210 | 210 | |
|
211 | 211 | Precursor to ``bundle2`` capability that was used before bundle2 was a |
|
212 | 212 | stable feature. |
|
213 | 213 | |
|
214 | 214 | This capability was introduced in Mercurial 3.0 behind an experimental |
|
215 | 215 | flag. This capability should not be observed in the wild. |
|
216 | 216 | |
|
217 | 217 | bundle2 |
|
218 | 218 | ------- |
|
219 | 219 | |
|
220 | 220 | Indicates whether the server supports the ``bundle2`` data exchange format. |
|
221 | 221 | |
|
222 | 222 | The value of the capability is a URL quoted, newline (``\n``) delimited |
|
223 | 223 | list of keys or key-value pairs. |
|
224 | 224 | |
|
225 | 225 | A key is simply a URL encoded string. |
|
226 | 226 | |
|
227 | 227 | A key-value pair is a URL encoded key separated from a URL encoded value by |
|
228 | 228 | an ``=``. If the value is a list, elements are delimited by a ``,`` after |
|
229 | 229 | URL encoding. |
|
230 | 230 | |
|
231 | 231 | For example, say we have the values:: |
|
232 | 232 | |
|
233 | 233 | {'HG20': [], 'changegroup': ['01', '02'], 'digests': ['sha1', 'sha512']} |
|
234 | 234 | |
|
235 | 235 | We would first construct a string:: |
|
236 | 236 | |
|
237 | 237 | HG20\nchangegroup=01,02\ndigests=sha1,sha512 |
|
238 | 238 | |
|
239 | 239 | We would then URL quote this string:: |
|
240 | 240 | |
|
241 | 241 | HG20%0Achangegroup%3D01%2C02%0Adigests%3Dsha1%2Csha512 |
|
242 | 242 | |
|
243 | 243 | This capability was introduced in Mercurial 3.4 (released May 2015). |
|
244 | 244 | |
|
245 | 245 | changegroupsubset |
|
246 | 246 | ----------------- |
|
247 | 247 | |
|
248 | 248 | Whether the server supports the ``changegroupsubset`` command. |
|
249 | 249 | |
|
250 | 250 | This capability was introduced in Mercurial 0.9.2 (released December |
|
251 | 251 | 2006). |
|
252 | 252 | |
|
253 | 253 | This capability was introduced at the same time as the ``lookup`` |
|
254 | 254 | capability/command. |
|
255 | 255 | |
|
256 | 256 | compression |
|
257 | 257 | ----------- |
|
258 | 258 | |
|
259 | 259 | Declares support for negotiating compression formats. |
|
260 | 260 | |
|
261 | 261 | Presence of this capability indicates the server supports dynamic selection |
|
262 | 262 | of compression formats based on the client request. |
|
263 | 263 | |
|
264 | 264 | Servers advertising this capability are required to support the |
|
265 | 265 | ``application/mercurial-0.2`` media type in response to commands returning |
|
266 | 266 | streams. Servers may support this media type on any command. |
|
267 | 267 | |
|
268 | 268 | The value of the capability is a comma-delimited list of strings declaring |
|
269 | 269 | supported compression formats. The order of the compression formats is in |
|
270 | 270 | server-preferred order, most preferred first. |
|
271 | 271 | |
|
272 | 272 | The identifiers used by the official Mercurial distribution are: |
|
273 | 273 | |
|
274 | 274 | bzip2 |
|
275 | 275 | bzip2 |
|
276 | 276 | none |
|
277 | 277 | uncompressed / raw data |
|
278 | 278 | zlib |
|
279 | 279 | zlib (no gzip header) |
|
280 | 280 | zstd |
|
281 | 281 | zstd |
|
282 | 282 | |
|
283 | 283 | This capability was introduced in Mercurial 4.1 (released February 2017). |
|
284 | 284 | |
|
285 | 285 | getbundle |
|
286 | 286 | --------- |
|
287 | 287 | |
|
288 | 288 | Whether the server supports the ``getbundle`` command. |
|
289 | 289 | |
|
290 | 290 | This capability was introduced in Mercurial 1.9 (released July 2011). |
|
291 | 291 | |
|
292 | 292 | httpheader |
|
293 | 293 | ---------- |
|
294 | 294 | |
|
295 | 295 | Whether the server supports receiving command arguments via HTTP request |
|
296 | 296 | headers. |
|
297 | 297 | |
|
298 | 298 | The value of the capability is an integer describing the max header |
|
299 | 299 | length that clients should send. Clients should ignore any content after a |
|
300 | 300 | comma in the value, as this is reserved for future use. |
|
301 | 301 | |
|
302 | 302 | This capability was introduced in Mercurial 1.9 (released July 2011). |
|
303 | 303 | |
|
304 | 304 | httpmediatype |
|
305 | 305 | ------------- |
|
306 | 306 | |
|
307 | 307 | Indicates which HTTP media types (``Content-Type`` header) the server is |
|
308 | 308 | capable of receiving and sending. |
|
309 | 309 | |
|
310 | 310 | The value of the capability is a comma-delimited list of strings identifying |
|
311 | 311 | support for media type and transmission direction. The following strings may |
|
312 | 312 | be present: |
|
313 | 313 | |
|
314 | 314 | 0.1rx |
|
315 | 315 | Indicates server support for receiving ``application/mercurial-0.1`` media |
|
316 | 316 | types. |
|
317 | 317 | |
|
318 | 318 | 0.1tx |
|
319 | 319 | Indicates server support for sending ``application/mercurial-0.1`` media |
|
320 | 320 | types. |
|
321 | 321 | |
|
322 | 322 | 0.2rx |
|
323 | 323 | Indicates server support for receiving ``application/mercurial-0.2`` media |
|
324 | 324 | types. |
|
325 | 325 | |
|
326 | 326 | 0.2tx |
|
327 | 327 | Indicates server support for sending ``application/mercurial-0.2`` media |
|
328 | 328 | types. |
|
329 | 329 | |
|
330 | 330 | minrx=X |
|
331 | 331 | Minimum media type version the server is capable of receiving. Value is a |
|
332 | 332 | string like ``0.2``. |
|
333 | 333 | |
|
334 | 334 | This capability can be used by servers to limit connections from legacy |
|
335 | 335 | clients not using the latest supported media type. However, only clients |
|
336 | 336 | with knowledge of this capability will know to consult this value. This |
|
337 | 337 | capability is present so the client may issue a more user-friendly error |
|
338 | 338 | when the server has locked out a legacy client. |
|
339 | 339 | |
|
340 | 340 | mintx=X |
|
341 | 341 | Minimum media type version the server is capable of sending. Value is a |
|
342 | 342 | string like ``0.1``. |
|
343 | 343 | |
|
344 | 344 | Servers advertising support for the ``application/mercurial-0.2`` media type |
|
345 | 345 | should also advertise the ``compression`` capability. |
|
346 | 346 | |
|
347 | 347 | This capability was introduced in Mercurial 4.1 (released February 2017). |
|
348 | 348 | |
|
349 | 349 | httppostargs |
|
350 | 350 | ------------ |
|
351 | 351 | |
|
352 | 352 | **Experimental** |
|
353 | 353 | |
|
354 | 354 | Indicates that the server supports and prefers clients send command arguments |
|
355 | 355 | via a HTTP POST request as part of the request body. |
|
356 | 356 | |
|
357 | 357 | This capability was introduced in Mercurial 3.8 (released May 2016). |
|
358 | 358 | |
|
359 | 359 | known |
|
360 | 360 | ----- |
|
361 | 361 | |
|
362 | 362 | Whether the server supports the ``known`` command. |
|
363 | 363 | |
|
364 | 364 | This capability/command was introduced in Mercurial 1.9 (released July 2011). |
|
365 | 365 | |
|
366 | 366 | lookup |
|
367 | 367 | ------ |
|
368 | 368 | |
|
369 | 369 | Whether the server supports the ``lookup`` command. |
|
370 | 370 | |
|
371 | 371 | This capability was introduced in Mercurial 0.9.2 (released December |
|
372 | 372 | 2006). |
|
373 | 373 | |
|
374 | 374 | This capability was introduced at the same time as the ``changegroupsubset`` |
|
375 | 375 | capability/command. |
|
376 | 376 | |
|
377 | 377 | pushkey |
|
378 | 378 | ------- |
|
379 | 379 | |
|
380 | 380 | Whether the server supports the ``pushkey`` and ``listkeys`` commands. |
|
381 | 381 | |
|
382 | 382 | This capability was introduced in Mercurial 1.6 (released July 2010). |
|
383 | 383 | |
|
384 | 384 | standardbundle |
|
385 | 385 | -------------- |
|
386 | 386 | |
|
387 | 387 | **Unsupported** |
|
388 | 388 | |
|
389 | 389 | This capability was introduced during the Mercurial 0.9.2 development cycle in |
|
390 | 390 | 2006. It was never present in a release, as it was replaced by the ``unbundle`` |
|
391 | 391 | capability. This capability should not be encountered in the wild. |
|
392 | 392 | |
|
393 | 393 | stream-preferred |
|
394 | 394 | ---------------- |
|
395 | 395 | |
|
396 | 396 | If present the server prefers that clients clone using the streaming clone |
|
397 |
protocol (``hg clone -- |
|
|
397 | protocol (``hg clone --stream``) rather than the standard | |
|
398 | 398 | changegroup/bundle based protocol. |
|
399 | 399 | |
|
400 | 400 | This capability was introduced in Mercurial 2.2 (released May 2012). |
|
401 | 401 | |
|
402 | 402 | streamreqs |
|
403 | 403 | ---------- |
|
404 | 404 | |
|
405 | 405 | Indicates whether the server supports *streaming clones* and the *requirements* |
|
406 | 406 | that clients must support to receive it. |
|
407 | 407 | |
|
408 | 408 | If present, the server supports the ``stream_out`` command, which transmits |
|
409 | 409 | raw revlogs from the repository instead of changegroups. This provides a faster |
|
410 | 410 | cloning mechanism at the expense of more bandwidth used. |
|
411 | 411 | |
|
412 | 412 | The value of this capability is a comma-delimited list of repo format |
|
413 | 413 | *requirements*. These are requirements that impact the reading of data in |
|
414 | 414 | the ``.hg/store`` directory. An example value is |
|
415 | 415 | ``streamreqs=generaldelta,revlogv1`` indicating the server repo requires |
|
416 | 416 | the ``revlogv1`` and ``generaldelta`` requirements. |
|
417 | 417 | |
|
418 | 418 | If the only format requirement is ``revlogv1``, the server may expose the |
|
419 | 419 | ``stream`` capability instead of the ``streamreqs`` capability. |
|
420 | 420 | |
|
421 | 421 | This capability was introduced in Mercurial 1.7 (released November 2010). |
|
422 | 422 | |
|
423 | 423 | stream |
|
424 | 424 | ------ |
|
425 | 425 | |
|
426 | 426 | Whether the server supports *streaming clones* from ``revlogv1`` repos. |
|
427 | 427 | |
|
428 | 428 | If present, the server supports the ``stream_out`` command, which transmits |
|
429 | 429 | raw revlogs from the repository instead of changegroups. This provides a faster |
|
430 | 430 | cloning mechanism at the expense of more bandwidth used. |
|
431 | 431 | |
|
432 | 432 | This capability was introduced in Mercurial 0.9.1 (released July 2006). |
|
433 | 433 | |
|
434 | 434 | When initially introduced, the value of the capability was the numeric |
|
435 | 435 | revlog revision. e.g. ``stream=1``. This indicates the changegroup is using |
|
436 | 436 | ``revlogv1``. This simple integer value wasn't powerful enough, so the |
|
437 | 437 | ``streamreqs`` capability was invented to handle cases where the repo |
|
438 | 438 | requirements have more than just ``revlogv1``. Newer servers omit the |
|
439 | 439 | ``=1`` since it was the only value supported and the value of ``1`` can |
|
440 | 440 | be implied by clients. |
|
441 | 441 | |
|
442 | 442 | unbundlehash |
|
443 | 443 | ------------ |
|
444 | 444 | |
|
445 | 445 | Whether the ``unbundle`` commands supports receiving a hash of all the |
|
446 | 446 | heads instead of a list. |
|
447 | 447 | |
|
448 | 448 | For more, see the documentation for the ``unbundle`` command. |
|
449 | 449 | |
|
450 | 450 | This capability was introduced in Mercurial 1.9 (released July 2011). |
|
451 | 451 | |
|
452 | 452 | unbundle |
|
453 | 453 | -------- |
|
454 | 454 | |
|
455 | 455 | Whether the server supports pushing via the ``unbundle`` command. |
|
456 | 456 | |
|
457 | 457 | This capability/command has been present since Mercurial 0.9.1 (released |
|
458 | 458 | July 2006). |
|
459 | 459 | |
|
460 | 460 | Mercurial 0.9.2 (released December 2006) added values to the capability |
|
461 | 461 | indicating which bundle types the server supports receiving. This value is a |
|
462 | 462 | comma-delimited list. e.g. ``HG10GZ,HG10BZ,HG10UN``. The order of values |
|
463 | 463 | reflects the priority/preference of that type, where the first value is the |
|
464 | 464 | most preferred type. |
|
465 | 465 | |
|
466 | 466 | Handshake Protocol |
|
467 | 467 | ================== |
|
468 | 468 | |
|
469 | 469 | While not explicitly required, it is common for clients to perform a |
|
470 | 470 | *handshake* when connecting to a server. The handshake accomplishes 2 things: |
|
471 | 471 | |
|
472 | 472 | * Obtaining capabilities and other server features |
|
473 | 473 | * Flushing extra server output (e.g. SSH servers may print extra text |
|
474 | 474 | when connecting that may confuse the wire protocol) |
|
475 | 475 | |
|
476 | 476 | This isn't a traditional *handshake* as far as network protocols go because |
|
477 | 477 | there is no persistent state as a result of the handshake: the handshake is |
|
478 | 478 | simply the issuing of commands and commands are stateless. |
|
479 | 479 | |
|
480 | 480 | The canonical clients perform a capabilities lookup at connection establishment |
|
481 | 481 | time. This is because clients must assume a server only supports the features |
|
482 | 482 | of the original Mercurial server implementation until proven otherwise (from |
|
483 | 483 | advertised capabilities). Nearly every server running today supports features |
|
484 | 484 | that weren't present in the original Mercurial server implementation. Rather |
|
485 | 485 | than wait for a client to perform functionality that needs to consult |
|
486 | 486 | capabilities, it issues the lookup at connection start to avoid any delay later. |
|
487 | 487 | |
|
488 | 488 | For HTTP servers, the client sends a ``capabilities`` command request as |
|
489 | 489 | soon as the connection is established. The server responds with a capabilities |
|
490 | 490 | string, which the client parses. |
|
491 | 491 | |
|
492 | 492 | For SSH servers, the client sends the ``hello`` command (no arguments) |
|
493 | 493 | and a ``between`` command with the ``pairs`` argument having the value |
|
494 | 494 | ``0000000000000000000000000000000000000000-0000000000000000000000000000000000000000``. |
|
495 | 495 | |
|
496 | 496 | The ``between`` command has been supported since the original Mercurial |
|
497 | 497 | server. Requesting the empty range will return a ``\n`` string response, |
|
498 | 498 | which will be encoded as ``1\n\n`` (value length of ``1`` followed by a newline |
|
499 | 499 | followed by the value, which happens to be a newline). |
|
500 | 500 | |
|
501 | 501 | The ``hello`` command was later introduced. Servers supporting it will issue |
|
502 | 502 | a response to that command before sending the ``1\n\n`` response to the |
|
503 | 503 | ``between`` command. Servers not supporting ``hello`` will send an empty |
|
504 | 504 | response (``0\n``). |
|
505 | 505 | |
|
506 | 506 | In addition to the expected output from the ``hello`` and ``between`` commands, |
|
507 | 507 | servers may also send other output, such as *message of the day (MOTD)* |
|
508 | 508 | announcements. Clients assume servers will send this output before the |
|
509 | 509 | Mercurial server replies to the client-issued commands. So any server output |
|
510 | 510 | not conforming to the expected command responses is assumed to be not related |
|
511 | 511 | to Mercurial and can be ignored. |
|
512 | 512 | |
|
513 | 513 | Content Negotiation |
|
514 | 514 | =================== |
|
515 | 515 | |
|
516 | 516 | The wire protocol has some mechanisms to help peers determine what content |
|
517 | 517 | types and encoding the other side will accept. Historically, these mechanisms |
|
518 | 518 | have been built into commands themselves because most commands only send a |
|
519 | 519 | well-defined response type and only certain commands needed to support |
|
520 | 520 | functionality like compression. |
|
521 | 521 | |
|
522 | 522 | Currently, only the HTTP transport supports content negotiation at the protocol |
|
523 | 523 | layer. |
|
524 | 524 | |
|
525 | 525 | HTTP requests advertise supported response formats via the ``X-HgProto-<N>`` |
|
526 | 526 | request header, where ``<N>`` is an integer starting at 1 allowing the logical |
|
527 | 527 | value to span multiple headers. This value consists of a list of |
|
528 | 528 | space-delimited parameters. Each parameter denotes a feature or capability. |
|
529 | 529 | |
|
530 | 530 | The following parameters are defined: |
|
531 | 531 | |
|
532 | 532 | 0.1 |
|
533 | 533 | Indicates the client supports receiving ``application/mercurial-0.1`` |
|
534 | 534 | responses. |
|
535 | 535 | |
|
536 | 536 | 0.2 |
|
537 | 537 | Indicates the client supports receiving ``application/mercurial-0.2`` |
|
538 | 538 | responses. |
|
539 | 539 | |
|
540 | 540 | comp |
|
541 | 541 | Indicates compression formats the client can decode. Value is a list of |
|
542 | 542 | comma delimited strings identifying compression formats ordered from |
|
543 | 543 | most preferential to least preferential. e.g. ``comp=zstd,zlib,none``. |
|
544 | 544 | |
|
545 | 545 | This parameter does not have an effect if only the ``0.1`` parameter |
|
546 | 546 | is defined, as support for ``application/mercurial-0.2`` or greater is |
|
547 | 547 | required to use arbitrary compression formats. |
|
548 | 548 | |
|
549 | 549 | If this parameter is not advertised, the server interprets this as |
|
550 | 550 | equivalent to ``zlib,none``. |
|
551 | 551 | |
|
552 | 552 | Clients may choose to only send this header if the ``httpmediatype`` |
|
553 | 553 | server capability is present, as currently all server-side features |
|
554 | 554 | consulting this header require the client to opt in to new protocol features |
|
555 | 555 | advertised via the ``httpmediatype`` capability. |
|
556 | 556 | |
|
557 | 557 | A server that doesn't receive an ``X-HgProto-<N>`` header should infer a |
|
558 | 558 | value of ``0.1``. This is compatible with legacy clients. |
|
559 | 559 | |
|
560 | 560 | A server receiving a request indicating support for multiple media type |
|
561 | 561 | versions may respond with any of the supported media types. Not all servers |
|
562 | 562 | may support all media types on all commands. |
|
563 | 563 | |
|
564 | 564 | Commands |
|
565 | 565 | ======== |
|
566 | 566 | |
|
567 | 567 | This section contains a list of all wire protocol commands implemented by |
|
568 | 568 | the canonical Mercurial server. |
|
569 | 569 | |
|
570 | 570 | batch |
|
571 | 571 | ----- |
|
572 | 572 | |
|
573 | 573 | Issue multiple commands while sending a single command request. The purpose |
|
574 | 574 | of this command is to allow a client to issue multiple commands while avoiding |
|
575 | 575 | multiple round trips to the server therefore enabling commands to complete |
|
576 | 576 | quicker. |
|
577 | 577 | |
|
578 | 578 | The command accepts a ``cmds`` argument that contains a list of commands to |
|
579 | 579 | execute. |
|
580 | 580 | |
|
581 | 581 | The value of ``cmds`` is a ``;`` delimited list of strings. Each string has the |
|
582 | 582 | form ``<command> <arguments>``. That is, the command name followed by a space |
|
583 | 583 | followed by an argument string. |
|
584 | 584 | |
|
585 | 585 | The argument string is a ``,`` delimited list of ``<key>=<value>`` values |
|
586 | 586 | corresponding to command arguments. Both the argument name and value are |
|
587 | 587 | escaped using a special substitution map:: |
|
588 | 588 | |
|
589 | 589 | : -> :c |
|
590 | 590 | , -> :o |
|
591 | 591 | ; -> :s |
|
592 | 592 | = -> :e |
|
593 | 593 | |
|
594 | 594 | The response type for this command is ``string``. The value contains a |
|
595 | 595 | ``;`` delimited list of responses for each requested command. Each value |
|
596 | 596 | in this list is escaped using the same substitution map used for arguments. |
|
597 | 597 | |
|
598 | 598 | If an error occurs, the generic error response may be sent. |
|
599 | 599 | |
|
600 | 600 | between |
|
601 | 601 | ------- |
|
602 | 602 | |
|
603 | 603 | (Legacy command used for discovery in old clients) |
|
604 | 604 | |
|
605 | 605 | Obtain nodes between pairs of nodes. |
|
606 | 606 | |
|
607 | 607 | The ``pairs`` arguments contains a space-delimited list of ``-`` delimited |
|
608 | 608 | hex node pairs. e.g.:: |
|
609 | 609 | |
|
610 | 610 | a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896-6dc58916e7c070f678682bfe404d2e2d68291a18 |
|
611 | 611 | |
|
612 | 612 | Return type is a ``string``. Value consists of lines corresponding to each |
|
613 | 613 | requested range. Each line contains a space-delimited list of hex nodes. |
|
614 | 614 | A newline ``\n`` terminates each line, including the last one. |
|
615 | 615 | |
|
616 | 616 | branchmap |
|
617 | 617 | --------- |
|
618 | 618 | |
|
619 | 619 | Obtain heads in named branches. |
|
620 | 620 | |
|
621 | 621 | Accepts no arguments. Return type is a ``string``. |
|
622 | 622 | |
|
623 | 623 | Return value contains lines with URL encoded branch names followed by a space |
|
624 | 624 | followed by a space-delimited list of hex nodes of heads on that branch. |
|
625 | 625 | e.g.:: |
|
626 | 626 | |
|
627 | 627 | default a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896 6dc58916e7c070f678682bfe404d2e2d68291a18 |
|
628 | 628 | stable baae3bf31522f41dd5e6d7377d0edd8d1cf3fccc |
|
629 | 629 | |
|
630 | 630 | There is no trailing newline. |
|
631 | 631 | |
|
632 | 632 | branches |
|
633 | 633 | -------- |
|
634 | 634 | |
|
635 | 635 | (Legacy command used for discovery in old clients. Clients with ``getbundle`` |
|
636 | 636 | use the ``known`` and ``heads`` commands instead.) |
|
637 | 637 | |
|
638 | 638 | Obtain ancestor changesets of specific nodes back to a branch point. |
|
639 | 639 | |
|
640 | 640 | Despite the name, this command has nothing to do with Mercurial named branches. |
|
641 | 641 | Instead, it is related to DAG branches. |
|
642 | 642 | |
|
643 | 643 | The command accepts a ``nodes`` argument, which is a string of space-delimited |
|
644 | 644 | hex nodes. |
|
645 | 645 | |
|
646 | 646 | For each node requested, the server will find the first ancestor node that is |
|
647 | 647 | a DAG root or is a merge. |
|
648 | 648 | |
|
649 | 649 | Return type is a ``string``. Return value contains lines with result data for |
|
650 | 650 | each requested node. Each line contains space-delimited nodes followed by a |
|
651 | 651 | newline (``\n``). The 4 nodes reported on each line correspond to the requested |
|
652 | 652 | node, the ancestor node found, and its 2 parent nodes (which may be the null |
|
653 | 653 | node). |
|
654 | 654 | |
|
655 | 655 | capabilities |
|
656 | 656 | ------------ |
|
657 | 657 | |
|
658 | 658 | Obtain the capabilities string for the repo. |
|
659 | 659 | |
|
660 | 660 | Unlike the ``hello`` command, the capabilities string is not prefixed. |
|
661 | 661 | There is no trailing newline. |
|
662 | 662 | |
|
663 | 663 | This command does not accept any arguments. Return type is a ``string``. |
|
664 | 664 | |
|
665 | 665 | changegroup |
|
666 | 666 | ----------- |
|
667 | 667 | |
|
668 | 668 | (Legacy command: use ``getbundle`` instead) |
|
669 | 669 | |
|
670 | 670 | Obtain a changegroup version 1 with data for changesets that are |
|
671 | 671 | descendants of client-specified changesets. |
|
672 | 672 | |
|
673 | 673 | The ``roots`` arguments contains a list of space-delimited hex nodes. |
|
674 | 674 | |
|
675 | 675 | The server responds with a changegroup version 1 containing all |
|
676 | 676 | changesets between the requested root/base nodes and the repo's head nodes |
|
677 | 677 | at the time of the request. |
|
678 | 678 | |
|
679 | 679 | The return type is a ``stream``. |
|
680 | 680 | |
|
681 | 681 | changegroupsubset |
|
682 | 682 | ----------------- |
|
683 | 683 | |
|
684 | 684 | (Legacy command: use ``getbundle`` instead) |
|
685 | 685 | |
|
686 | 686 | Obtain a changegroup version 1 with data for changesetsets between |
|
687 | 687 | client specified base and head nodes. |
|
688 | 688 | |
|
689 | 689 | The ``bases`` argument contains a list of space-delimited hex nodes. |
|
690 | 690 | The ``heads`` argument contains a list of space-delimited hex nodes. |
|
691 | 691 | |
|
692 | 692 | The server responds with a changegroup version 1 containing all |
|
693 | 693 | changesets between the requested base and head nodes at the time of the |
|
694 | 694 | request. |
|
695 | 695 | |
|
696 | 696 | The return type is a ``stream``. |
|
697 | 697 | |
|
698 | 698 | clonebundles |
|
699 | 699 | ------------ |
|
700 | 700 | |
|
701 | 701 | Obtains a manifest of bundle URLs available to seed clones. |
|
702 | 702 | |
|
703 | 703 | Each returned line contains a URL followed by metadata. See the |
|
704 | 704 | documentation in the ``clonebundles`` extension for more. |
|
705 | 705 | |
|
706 | 706 | The return type is a ``string``. |
|
707 | 707 | |
|
708 | 708 | getbundle |
|
709 | 709 | --------- |
|
710 | 710 | |
|
711 | 711 | Obtain a bundle containing repository data. |
|
712 | 712 | |
|
713 | 713 | This command accepts the following arguments: |
|
714 | 714 | |
|
715 | 715 | heads |
|
716 | 716 | List of space-delimited hex nodes of heads to retrieve. |
|
717 | 717 | common |
|
718 | 718 | List of space-delimited hex nodes that the client has in common with the |
|
719 | 719 | server. |
|
720 | 720 | obsmarkers |
|
721 | 721 | Boolean indicating whether to include obsolescence markers as part |
|
722 | 722 | of the response. Only works with bundle2. |
|
723 | 723 | bundlecaps |
|
724 | 724 | Comma-delimited set of strings defining client bundle capabilities. |
|
725 | 725 | listkeys |
|
726 | 726 | Comma-delimited list of strings of ``pushkey`` namespaces. For each |
|
727 | 727 | namespace listed, a bundle2 part will be included with the content of |
|
728 | 728 | that namespace. |
|
729 | 729 | cg |
|
730 | 730 | Boolean indicating whether changegroup data is requested. |
|
731 | 731 | cbattempted |
|
732 | 732 | Boolean indicating whether the client attempted to use the *clone bundles* |
|
733 | 733 | feature before performing this request. |
|
734 | 734 | |
|
735 | 735 | The return type on success is a ``stream`` where the value is bundle. |
|
736 | 736 | On the HTTP transport, the response is zlib compressed. |
|
737 | 737 | |
|
738 | 738 | If an error occurs, a generic error response can be sent. |
|
739 | 739 | |
|
740 | 740 | Unless the client sends a false value for the ``cg`` argument, the returned |
|
741 | 741 | bundle contains a changegroup with the nodes between the specified ``common`` |
|
742 | 742 | and ``heads`` nodes. Depending on the command arguments, the type and content |
|
743 | 743 | of the returned bundle can vary significantly. |
|
744 | 744 | |
|
745 | 745 | The default behavior is for the server to send a raw changegroup version |
|
746 | 746 | ``01`` response. |
|
747 | 747 | |
|
748 | 748 | If the ``bundlecaps`` provided by the client contain a value beginning |
|
749 | 749 | with ``HG2``, a bundle2 will be returned. The bundle2 data may contain |
|
750 | 750 | additional repository data, such as ``pushkey`` namespace values. |
|
751 | 751 | |
|
752 | 752 | heads |
|
753 | 753 | ----- |
|
754 | 754 | |
|
755 | 755 | Returns a list of space-delimited hex nodes of repository heads followed |
|
756 | 756 | by a newline. e.g. |
|
757 | 757 | ``a9eeb3adc7ddb5006c088e9eda61791c777cbf7c 31f91a3da534dc849f0d6bfc00a395a97cf218a1\n`` |
|
758 | 758 | |
|
759 | 759 | This command does not accept any arguments. The return type is a ``string``. |
|
760 | 760 | |
|
761 | 761 | hello |
|
762 | 762 | ----- |
|
763 | 763 | |
|
764 | 764 | Returns lines describing interesting things about the server in an RFC-822 |
|
765 | 765 | like format. |
|
766 | 766 | |
|
767 | 767 | Currently, the only line defines the server capabilities. It has the form:: |
|
768 | 768 | |
|
769 | 769 | capabilities: <value> |
|
770 | 770 | |
|
771 | 771 | See above for more about the capabilities string. |
|
772 | 772 | |
|
773 | 773 | SSH clients typically issue this command as soon as a connection is |
|
774 | 774 | established. |
|
775 | 775 | |
|
776 | 776 | This command does not accept any arguments. The return type is a ``string``. |
|
777 | 777 | |
|
778 | 778 | listkeys |
|
779 | 779 | -------- |
|
780 | 780 | |
|
781 | 781 | List values in a specified ``pushkey`` namespace. |
|
782 | 782 | |
|
783 | 783 | The ``namespace`` argument defines the pushkey namespace to operate on. |
|
784 | 784 | |
|
785 | 785 | The return type is a ``string``. The value is an encoded dictionary of keys. |
|
786 | 786 | |
|
787 | 787 | Key-value pairs are delimited by newlines (``\n``). Within each line, keys and |
|
788 | 788 | values are separated by a tab (``\t``). Keys and values are both strings. |
|
789 | 789 | |
|
790 | 790 | lookup |
|
791 | 791 | ------ |
|
792 | 792 | |
|
793 | 793 | Try to resolve a value to a known repository revision. |
|
794 | 794 | |
|
795 | 795 | The ``key`` argument is converted from bytes to an |
|
796 | 796 | ``encoding.localstr`` instance then passed into |
|
797 | 797 | ``localrepository.__getitem__`` in an attempt to resolve it. |
|
798 | 798 | |
|
799 | 799 | The return type is a ``string``. |
|
800 | 800 | |
|
801 | 801 | Upon successful resolution, returns ``1 <hex node>\n``. On failure, |
|
802 | 802 | returns ``0 <error string>\n``. e.g.:: |
|
803 | 803 | |
|
804 | 804 | 1 273ce12ad8f155317b2c078ec75a4eba507f1fba\n |
|
805 | 805 | |
|
806 | 806 | 0 unknown revision 'foo'\n |
|
807 | 807 | |
|
808 | 808 | known |
|
809 | 809 | ----- |
|
810 | 810 | |
|
811 | 811 | Determine whether multiple nodes are known. |
|
812 | 812 | |
|
813 | 813 | The ``nodes`` argument is a list of space-delimited hex nodes to check |
|
814 | 814 | for existence. |
|
815 | 815 | |
|
816 | 816 | The return type is ``string``. |
|
817 | 817 | |
|
818 | 818 | Returns a string consisting of ``0``s and ``1``s indicating whether nodes |
|
819 | 819 | are known. If the Nth node specified in the ``nodes`` argument is known, |
|
820 | 820 | a ``1`` will be returned at byte offset N. If the node isn't known, ``0`` |
|
821 | 821 | will be present at byte offset N. |
|
822 | 822 | |
|
823 | 823 | There is no trailing newline. |
|
824 | 824 | |
|
825 | 825 | pushkey |
|
826 | 826 | ------- |
|
827 | 827 | |
|
828 | 828 | Set a value using the ``pushkey`` protocol. |
|
829 | 829 | |
|
830 | 830 | Accepts arguments ``namespace``, ``key``, ``old``, and ``new``, which |
|
831 | 831 | correspond to the pushkey namespace to operate on, the key within that |
|
832 | 832 | namespace to change, the old value (which may be empty), and the new value. |
|
833 | 833 | All arguments are string types. |
|
834 | 834 | |
|
835 | 835 | The return type is a ``string``. The value depends on the transport protocol. |
|
836 | 836 | |
|
837 | 837 | The SSH transport sends a string encoded integer followed by a newline |
|
838 | 838 | (``\n``) which indicates operation result. The server may send additional |
|
839 | 839 | output on the ``stderr`` stream that should be displayed to the user. |
|
840 | 840 | |
|
841 | 841 | The HTTP transport sends a string encoded integer followed by a newline |
|
842 | 842 | followed by additional server output that should be displayed to the user. |
|
843 | 843 | This may include output from hooks, etc. |
|
844 | 844 | |
|
845 | 845 | The integer result varies by namespace. ``0`` means an error has occurred |
|
846 | 846 | and there should be additional output to display to the user. |
|
847 | 847 | |
|
848 | 848 | stream_out |
|
849 | 849 | ---------- |
|
850 | 850 | |
|
851 | 851 | Obtain *streaming clone* data. |
|
852 | 852 | |
|
853 | 853 | The return type is either a ``string`` or a ``stream``, depending on |
|
854 | 854 | whether the request was fulfilled properly. |
|
855 | 855 | |
|
856 | 856 | A return value of ``1\n`` indicates the server is not configured to serve |
|
857 | 857 | this data. If this is seen by the client, they may not have verified the |
|
858 | 858 | ``stream`` capability is set before making the request. |
|
859 | 859 | |
|
860 | 860 | A return value of ``2\n`` indicates the server was unable to lock the |
|
861 | 861 | repository to generate data. |
|
862 | 862 | |
|
863 | 863 | All other responses are a ``stream`` of bytes. The first line of this data |
|
864 | 864 | contains 2 space-delimited integers corresponding to the path count and |
|
865 | 865 | payload size, respectively:: |
|
866 | 866 | |
|
867 | 867 | <path count> <payload size>\n |
|
868 | 868 | |
|
869 | 869 | The ``<payload size>`` is the total size of path data: it does not include |
|
870 | 870 | the size of the per-path header lines. |
|
871 | 871 | |
|
872 | 872 | Following that header are ``<path count>`` entries. Each entry consists of a |
|
873 | 873 | line with metadata followed by raw revlog data. The line consists of:: |
|
874 | 874 | |
|
875 | 875 | <store path>\0<size>\n |
|
876 | 876 | |
|
877 | 877 | The ``<store path>`` is the encoded store path of the data that follows. |
|
878 | 878 | ``<size>`` is the amount of data for this store path/revlog that follows the |
|
879 | 879 | newline. |
|
880 | 880 | |
|
881 | 881 | There is no trailer to indicate end of data. Instead, the client should stop |
|
882 | 882 | reading after ``<path count>`` entries are consumed. |
|
883 | 883 | |
|
884 | 884 | unbundle |
|
885 | 885 | -------- |
|
886 | 886 | |
|
887 | 887 | Send a bundle containing data (usually changegroup data) to the server. |
|
888 | 888 | |
|
889 | 889 | Accepts the argument ``heads``, which is a space-delimited list of hex nodes |
|
890 | 890 | corresponding to server repository heads observed by the client. This is used |
|
891 | 891 | to detect race conditions and abort push operations before a server performs |
|
892 | 892 | too much work or a client transfers too much data. |
|
893 | 893 | |
|
894 | 894 | The request payload consists of a bundle to be applied to the repository, |
|
895 | 895 | similarly to as if :hg:`unbundle` were called. |
|
896 | 896 | |
|
897 | 897 | In most scenarios, a special ``push response`` type is returned. This type |
|
898 | 898 | contains an integer describing the change in heads as a result of the |
|
899 | 899 | operation. A value of ``0`` indicates nothing changed. ``1`` means the number |
|
900 | 900 | of heads remained the same. Values ``2`` and larger indicate the number of |
|
901 | 901 | added heads minus 1. e.g. ``3`` means 2 heads were added. Negative values |
|
902 | 902 | indicate the number of fewer heads, also off by 1. e.g. ``-2`` means there |
|
903 | 903 | is 1 fewer head. |
|
904 | 904 | |
|
905 | 905 | The encoding of the ``push response`` type varies by transport. |
|
906 | 906 | |
|
907 | 907 | For the SSH transport, this type is composed of 2 ``string`` responses: an |
|
908 | 908 | empty response (``0\n``) followed by the integer result value. e.g. |
|
909 | 909 | ``1\n2``. So the full response might be ``0\n1\n2``. |
|
910 | 910 | |
|
911 | 911 | For the HTTP transport, the response is a ``string`` type composed of an |
|
912 | 912 | integer result value followed by a newline (``\n``) followed by string |
|
913 | 913 | content holding server output that should be displayed on the client (output |
|
914 | 914 | hooks, etc). |
|
915 | 915 | |
|
916 | 916 | In some cases, the server may respond with a ``bundle2`` bundle. In this |
|
917 | 917 | case, the response type is ``stream``. For the HTTP transport, the response |
|
918 | 918 | is zlib compressed. |
|
919 | 919 | |
|
920 | 920 | The server may also respond with a generic error type, which contains a string |
|
921 | 921 | indicating the failure. |
@@ -1,161 +1,170 b'' | |||
|
1 | 1 | #require serve |
|
2 | 2 | |
|
3 | 3 | Initialize repository |
|
4 | 4 | the status call is to check for issue5130 |
|
5 | 5 | |
|
6 | 6 | $ hg init server |
|
7 | 7 | $ cd server |
|
8 | 8 | $ touch foo |
|
9 | 9 | $ hg -q commit -A -m initial |
|
10 | 10 | >>> for i in range(1024): |
|
11 | 11 | ... with open(str(i), 'wb') as fh: |
|
12 | 12 | ... fh.write(str(i)) |
|
13 | 13 | $ hg -q commit -A -m 'add a lot of files' |
|
14 | 14 | $ hg st |
|
15 | 15 | $ hg serve -p $HGPORT -d --pid-file=hg.pid |
|
16 | 16 | $ cat hg.pid >> $DAEMON_PIDS |
|
17 | 17 | $ cd .. |
|
18 | 18 | |
|
19 | 19 | Basic clone |
|
20 | 20 | |
|
21 |
$ hg clone -- |
|
|
21 | $ hg clone --stream -U http://localhost:$HGPORT clone1 | |
|
22 | streaming all changes | |
|
23 | 1027 files to transfer, 96.3 KB of data | |
|
24 | transferred 96.3 KB in * seconds (*/sec) (glob) | |
|
25 | searching for changes | |
|
26 | no changes found | |
|
27 | ||
|
28 | --uncompressed is an alias to --stream | |
|
29 | ||
|
30 | $ hg clone --uncompressed -U http://localhost:$HGPORT clone1-uncompressed | |
|
22 | 31 | streaming all changes |
|
23 | 32 | 1027 files to transfer, 96.3 KB of data |
|
24 | 33 | transferred 96.3 KB in * seconds (*/sec) (glob) |
|
25 | 34 | searching for changes |
|
26 | 35 | no changes found |
|
27 | 36 | |
|
28 | 37 | Clone with background file closing enabled |
|
29 | 38 | |
|
30 |
$ hg --debug --config worker.backgroundclose=true --config worker.backgroundcloseminfilecount=1 clone -- |
|
|
39 | $ hg --debug --config worker.backgroundclose=true --config worker.backgroundcloseminfilecount=1 clone --stream -U http://localhost:$HGPORT clone-background | grep -v adding | |
|
31 | 40 | using http://localhost:$HGPORT/ |
|
32 | 41 | sending capabilities command |
|
33 | 42 | sending branchmap command |
|
34 | 43 | streaming all changes |
|
35 | 44 | sending stream_out command |
|
36 | 45 | 1027 files to transfer, 96.3 KB of data |
|
37 | 46 | starting 4 threads for background file closing |
|
38 | 47 | transferred 96.3 KB in * seconds (*/sec) (glob) |
|
39 | 48 | query 1; heads |
|
40 | 49 | sending batch command |
|
41 | 50 | searching for changes |
|
42 | 51 | all remote heads known locally |
|
43 | 52 | no changes found |
|
44 | 53 | sending getbundle command |
|
45 | 54 | bundle2-input-bundle: with-transaction |
|
46 | 55 | bundle2-input-part: "listkeys" (params: 1 mandatory) supported |
|
47 | 56 | bundle2-input-part: "phase-heads" supported |
|
48 | 57 | bundle2-input-part: total payload size 24 |
|
49 | 58 | bundle2-input-bundle: 1 parts total |
|
50 | 59 | checking for updated bookmarks |
|
51 | 60 | |
|
52 | 61 | Cannot stream clone when there are secret changesets |
|
53 | 62 | |
|
54 | 63 | $ hg -R server phase --force --secret -r tip |
|
55 |
$ hg clone -- |
|
|
64 | $ hg clone --stream -U http://localhost:$HGPORT secret-denied | |
|
56 | 65 | warning: stream clone requested but server has them disabled |
|
57 | 66 | requesting all changes |
|
58 | 67 | adding changesets |
|
59 | 68 | adding manifests |
|
60 | 69 | adding file changes |
|
61 | 70 | added 1 changesets with 1 changes to 1 files |
|
62 | 71 | |
|
63 | 72 | $ killdaemons.py |
|
64 | 73 | |
|
65 | 74 | Streaming of secrets can be overridden by server config |
|
66 | 75 | |
|
67 | 76 | $ cd server |
|
68 | 77 | $ hg --config server.uncompressedallowsecret=true serve -p $HGPORT -d --pid-file=hg.pid |
|
69 | 78 | $ cat hg.pid > $DAEMON_PIDS |
|
70 | 79 | $ cd .. |
|
71 | 80 | |
|
72 |
$ hg clone -- |
|
|
81 | $ hg clone --stream -U http://localhost:$HGPORT secret-allowed | |
|
73 | 82 | streaming all changes |
|
74 | 83 | 1027 files to transfer, 96.3 KB of data |
|
75 | 84 | transferred 96.3 KB in * seconds (*/sec) (glob) |
|
76 | 85 | searching for changes |
|
77 | 86 | no changes found |
|
78 | 87 | |
|
79 | 88 | $ killdaemons.py |
|
80 | 89 | |
|
81 | 90 | Verify interaction between preferuncompressed and secret presence |
|
82 | 91 | |
|
83 | 92 | $ cd server |
|
84 | 93 | $ hg --config server.preferuncompressed=true serve -p $HGPORT -d --pid-file=hg.pid |
|
85 | 94 | $ cat hg.pid > $DAEMON_PIDS |
|
86 | 95 | $ cd .. |
|
87 | 96 | |
|
88 | 97 | $ hg clone -U http://localhost:$HGPORT preferuncompressed-secret |
|
89 | 98 | requesting all changes |
|
90 | 99 | adding changesets |
|
91 | 100 | adding manifests |
|
92 | 101 | adding file changes |
|
93 | 102 | added 1 changesets with 1 changes to 1 files |
|
94 | 103 | |
|
95 | 104 | $ killdaemons.py |
|
96 | 105 | |
|
97 | 106 | Clone not allowed when full bundles disabled and can't serve secrets |
|
98 | 107 | |
|
99 | 108 | $ cd server |
|
100 | 109 | $ hg --config server.disablefullbundle=true serve -p $HGPORT -d --pid-file=hg.pid |
|
101 | 110 | $ cat hg.pid > $DAEMON_PIDS |
|
102 | 111 | $ cd .. |
|
103 | 112 | |
|
104 |
$ hg clone -- |
|
|
113 | $ hg clone --stream http://localhost:$HGPORT secret-full-disabled | |
|
105 | 114 | warning: stream clone requested but server has them disabled |
|
106 | 115 | requesting all changes |
|
107 | 116 | remote: abort: server has pull-based clones disabled |
|
108 | 117 | abort: pull failed on remote |
|
109 | 118 | (remove --pull if specified or upgrade Mercurial) |
|
110 | 119 | [255] |
|
111 | 120 | |
|
112 | 121 | Local stream clone with secrets involved |
|
113 | 122 | (This is just a test over behavior: if you have access to the repo's files, |
|
114 | 123 | there is no security so it isn't important to prevent a clone here.) |
|
115 | 124 | |
|
116 |
$ hg clone -U -- |
|
|
125 | $ hg clone -U --stream server local-secret | |
|
117 | 126 | warning: stream clone requested but server has them disabled |
|
118 | 127 | requesting all changes |
|
119 | 128 | adding changesets |
|
120 | 129 | adding manifests |
|
121 | 130 | adding file changes |
|
122 | 131 | added 1 changesets with 1 changes to 1 files |
|
123 | 132 | |
|
124 | 133 | Stream clone while repo is changing: |
|
125 | 134 | |
|
126 | 135 | $ mkdir changing |
|
127 | 136 | $ cd changing |
|
128 | 137 | |
|
129 | 138 | extension for delaying the server process so we reliably can modify the repo |
|
130 | 139 | while cloning |
|
131 | 140 | |
|
132 | 141 | $ cat > delayer.py <<EOF |
|
133 | 142 | > import time |
|
134 | 143 | > from mercurial import extensions, vfs |
|
135 | 144 | > def __call__(orig, self, path, *args, **kwargs): |
|
136 | 145 | > if path == 'data/f1.i': |
|
137 | 146 | > time.sleep(2) |
|
138 | 147 | > return orig(self, path, *args, **kwargs) |
|
139 | 148 | > extensions.wrapfunction(vfs.vfs, '__call__', __call__) |
|
140 | 149 | > EOF |
|
141 | 150 | |
|
142 | 151 | prepare repo with small and big file to cover both code paths in emitrevlogdata |
|
143 | 152 | |
|
144 | 153 | $ hg init repo |
|
145 | 154 | $ touch repo/f1 |
|
146 | 155 | $ $TESTDIR/seq.py 50000 > repo/f2 |
|
147 | 156 | $ hg -R repo ci -Aqm "0" |
|
148 | 157 | $ hg -R repo serve -p $HGPORT1 -d --pid-file=hg.pid --config extensions.delayer=delayer.py |
|
149 | 158 | $ cat hg.pid >> $DAEMON_PIDS |
|
150 | 159 | |
|
151 | 160 | clone while modifying the repo between stating file with write lock and |
|
152 | 161 | actually serving file content |
|
153 | 162 | |
|
154 |
$ hg clone -q -- |
|
|
163 | $ hg clone -q --stream -U http://localhost:$HGPORT1 clone & | |
|
155 | 164 | $ sleep 1 |
|
156 | 165 | $ echo >> repo/f1 |
|
157 | 166 | $ echo >> repo/f2 |
|
158 | 167 | $ hg -R repo ci -m "1" |
|
159 | 168 | $ wait |
|
160 | 169 | $ hg -R clone id |
|
161 | 170 | 000000000000 |
@@ -1,511 +1,511 b'' | |||
|
1 | 1 | Set up a server |
|
2 | 2 | |
|
3 | 3 | $ cat >> $HGRCPATH << EOF |
|
4 | 4 | > [format] |
|
5 | 5 | > usegeneraldelta=yes |
|
6 | 6 | > EOF |
|
7 | 7 | $ hg init server |
|
8 | 8 | $ cd server |
|
9 | 9 | $ cat >> .hg/hgrc << EOF |
|
10 | 10 | > [extensions] |
|
11 | 11 | > clonebundles = |
|
12 | 12 | > EOF |
|
13 | 13 | |
|
14 | 14 | $ touch foo |
|
15 | 15 | $ hg -q commit -A -m 'add foo' |
|
16 | 16 | $ touch bar |
|
17 | 17 | $ hg -q commit -A -m 'add bar' |
|
18 | 18 | |
|
19 | 19 | $ hg serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log |
|
20 | 20 | $ cat hg.pid >> $DAEMON_PIDS |
|
21 | 21 | $ cd .. |
|
22 | 22 | |
|
23 | 23 | Missing manifest should not result in server lookup |
|
24 | 24 | |
|
25 | 25 | $ hg --verbose clone -U http://localhost:$HGPORT no-manifest |
|
26 | 26 | requesting all changes |
|
27 | 27 | adding changesets |
|
28 | 28 | adding manifests |
|
29 | 29 | adding file changes |
|
30 | 30 | added 2 changesets with 2 changes to 2 files |
|
31 | 31 | |
|
32 | 32 | $ cat server/access.log |
|
33 | 33 | * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) |
|
34 | 34 | * - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
35 | 35 | * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae7877e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
36 | 36 | |
|
37 | 37 | Empty manifest file results in retrieval |
|
38 | 38 | (the extension only checks if the manifest file exists) |
|
39 | 39 | |
|
40 | 40 | $ touch server/.hg/clonebundles.manifest |
|
41 | 41 | $ hg --verbose clone -U http://localhost:$HGPORT empty-manifest |
|
42 | 42 | no clone bundles available on remote; falling back to regular clone |
|
43 | 43 | requesting all changes |
|
44 | 44 | adding changesets |
|
45 | 45 | adding manifests |
|
46 | 46 | adding file changes |
|
47 | 47 | added 2 changesets with 2 changes to 2 files |
|
48 | 48 | |
|
49 | 49 | Manifest file with invalid URL aborts |
|
50 | 50 | |
|
51 | 51 | $ echo 'http://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest |
|
52 | 52 | $ hg clone http://localhost:$HGPORT 404-url |
|
53 | 53 | applying clone bundle from http://does.not.exist/bundle.hg |
|
54 | 54 | error fetching bundle: (.* not known|No address associated with hostname) (re) (no-windows !) |
|
55 | 55 | error fetching bundle: [Errno 11004] getaddrinfo failed (windows !) |
|
56 | 56 | abort: error applying bundle |
|
57 | 57 | (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false") |
|
58 | 58 | [255] |
|
59 | 59 | |
|
60 | 60 | Server is not running aborts |
|
61 | 61 | |
|
62 | 62 | $ echo "http://localhost:$HGPORT1/bundle.hg" > server/.hg/clonebundles.manifest |
|
63 | 63 | $ hg clone http://localhost:$HGPORT server-not-runner |
|
64 | 64 | applying clone bundle from http://localhost:$HGPORT1/bundle.hg |
|
65 | 65 | error fetching bundle: (.* refused.*|Protocol not supported|(.* )?Cannot assign requested address) (re) |
|
66 | 66 | abort: error applying bundle |
|
67 | 67 | (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false") |
|
68 | 68 | [255] |
|
69 | 69 | |
|
70 | 70 | Server returns 404 |
|
71 | 71 | |
|
72 | 72 | $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid |
|
73 | 73 | $ cat http.pid >> $DAEMON_PIDS |
|
74 | 74 | $ hg clone http://localhost:$HGPORT running-404 |
|
75 | 75 | applying clone bundle from http://localhost:$HGPORT1/bundle.hg |
|
76 | 76 | HTTP error fetching bundle: HTTP Error 404: File not found |
|
77 | 77 | abort: error applying bundle |
|
78 | 78 | (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false") |
|
79 | 79 | [255] |
|
80 | 80 | |
|
81 | 81 | We can override failure to fall back to regular clone |
|
82 | 82 | |
|
83 | 83 | $ hg --config ui.clonebundlefallback=true clone -U http://localhost:$HGPORT 404-fallback |
|
84 | 84 | applying clone bundle from http://localhost:$HGPORT1/bundle.hg |
|
85 | 85 | HTTP error fetching bundle: HTTP Error 404: File not found |
|
86 | 86 | falling back to normal clone |
|
87 | 87 | requesting all changes |
|
88 | 88 | adding changesets |
|
89 | 89 | adding manifests |
|
90 | 90 | adding file changes |
|
91 | 91 | added 2 changesets with 2 changes to 2 files |
|
92 | 92 | |
|
93 | 93 | Bundle with partial content works |
|
94 | 94 | |
|
95 | 95 | $ hg -R server bundle --type gzip-v1 --base null -r 53245c60e682 partial.hg |
|
96 | 96 | 1 changesets found |
|
97 | 97 | |
|
98 | 98 | We verify exact bundle content as an extra check against accidental future |
|
99 | 99 | changes. If this output changes, we could break old clients. |
|
100 | 100 | |
|
101 | 101 | $ f --size --hexdump partial.hg |
|
102 | 102 | partial.hg: size=207 |
|
103 | 103 | 0000: 48 47 31 30 47 5a 78 9c 63 60 60 98 17 ac 12 93 |HG10GZx.c``.....| |
|
104 | 104 | 0010: f0 ac a9 23 45 70 cb bf 0d 5f 59 4e 4a 7f 79 21 |...#Ep..._YNJ.y!| |
|
105 | 105 | 0020: 9b cc 40 24 20 a0 d7 ce 2c d1 38 25 cd 24 25 d5 |..@$ ...,.8%.$%.| |
|
106 | 106 | 0030: d8 c2 22 cd 38 d9 24 cd 22 d5 c8 22 cd 24 cd 32 |..".8.$."..".$.2| |
|
107 | 107 | 0040: d1 c2 d0 c4 c8 d2 32 d1 38 39 29 c9 34 cd d4 80 |......2.89).4...| |
|
108 | 108 | 0050: ab 24 b5 b8 84 cb 40 c1 80 2b 2d 3f 9f 8b 2b 31 |.$....@..+-?..+1| |
|
109 | 109 | 0060: 25 45 01 c8 80 9a d2 9b 65 fb e5 9e 45 bf 8d 7f |%E......e...E...| |
|
110 | 110 | 0070: 9f c6 97 9f 2b 44 34 67 d9 ec 8e 0f a0 92 0b 75 |....+D4g.......u| |
|
111 | 111 | 0080: 41 d6 24 59 18 a4 a4 9a a6 18 1a 5b 98 9b 5a 98 |A.$Y.......[..Z.| |
|
112 | 112 | 0090: 9a 18 26 9b a6 19 98 1a 99 99 26 a6 18 9a 98 24 |..&.......&....$| |
|
113 | 113 | 00a0: 26 59 a6 25 5a 98 a5 18 a6 24 71 41 35 b1 43 dc |&Y.%Z....$qA5.C.| |
|
114 | 114 | 00b0: 16 b2 83 f7 e9 45 8b d2 56 c7 a3 1f 82 52 d7 8a |.....E..V....R..| |
|
115 | 115 | 00c0: 78 ed fc d5 76 f1 36 35 dc 05 00 36 ed 5e c7 |x...v.65...6.^.| |
|
116 | 116 | |
|
117 | 117 | $ echo "http://localhost:$HGPORT1/partial.hg" > server/.hg/clonebundles.manifest |
|
118 | 118 | $ hg clone -U http://localhost:$HGPORT partial-bundle |
|
119 | 119 | applying clone bundle from http://localhost:$HGPORT1/partial.hg |
|
120 | 120 | adding changesets |
|
121 | 121 | adding manifests |
|
122 | 122 | adding file changes |
|
123 | 123 | added 1 changesets with 1 changes to 1 files |
|
124 | 124 | finished applying clone bundle |
|
125 | 125 | searching for changes |
|
126 | 126 | adding changesets |
|
127 | 127 | adding manifests |
|
128 | 128 | adding file changes |
|
129 | 129 | added 1 changesets with 1 changes to 1 files |
|
130 | 130 | |
|
131 | 131 | Incremental pull doesn't fetch bundle |
|
132 | 132 | |
|
133 | 133 | $ hg clone -r 53245c60e682 -U http://localhost:$HGPORT partial-clone |
|
134 | 134 | adding changesets |
|
135 | 135 | adding manifests |
|
136 | 136 | adding file changes |
|
137 | 137 | added 1 changesets with 1 changes to 1 files |
|
138 | 138 | |
|
139 | 139 | $ cd partial-clone |
|
140 | 140 | $ hg pull |
|
141 | 141 | pulling from http://localhost:$HGPORT/ |
|
142 | 142 | searching for changes |
|
143 | 143 | adding changesets |
|
144 | 144 | adding manifests |
|
145 | 145 | adding file changes |
|
146 | 146 | added 1 changesets with 1 changes to 1 files |
|
147 | 147 | (run 'hg update' to get a working copy) |
|
148 | 148 | $ cd .. |
|
149 | 149 | |
|
150 | 150 | Bundle with full content works |
|
151 | 151 | |
|
152 | 152 | $ hg -R server bundle --type gzip-v2 --base null -r tip full.hg |
|
153 | 153 | 2 changesets found |
|
154 | 154 | |
|
155 | 155 | Again, we perform an extra check against bundle content changes. If this content |
|
156 | 156 | changes, clone bundles produced by new Mercurial versions may not be readable |
|
157 | 157 | by old clients. |
|
158 | 158 | |
|
159 | 159 | $ f --size --hexdump full.hg |
|
160 | 160 | full.hg: size=396 |
|
161 | 161 | 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress| |
|
162 | 162 | 0010: 69 6f 6e 3d 47 5a 78 9c 63 60 60 d0 e4 76 f6 70 |ion=GZx.c``..v.p| |
|
163 | 163 | 0020: f4 73 77 75 0f f2 0f 0d 60 00 02 46 46 76 26 4e |.swu....`..FFv&N| |
|
164 | 164 | 0030: c6 b2 d4 a2 e2 cc fc 3c 03 a3 bc a4 e4 8c c4 bc |.......<........| |
|
165 | 165 | 0040: f4 d4 62 23 06 06 e6 19 40 f9 4d c1 2a 31 09 cf |..b#....@.M.*1..| |
|
166 | 166 | 0050: 9a 3a 52 04 b7 fc db f0 95 e5 a4 f4 97 17 b2 c9 |.:R.............| |
|
167 | 167 | 0060: 0c 14 00 02 e6 d9 99 25 1a a7 a4 99 a4 a4 1a 5b |.......%.......[| |
|
168 | 168 | 0070: 58 a4 19 27 9b a4 59 a4 1a 59 a4 99 a4 59 26 5a |X..'..Y..Y...Y&Z| |
|
169 | 169 | 0080: 18 9a 18 59 5a 26 1a 27 27 25 99 a6 99 1a 70 95 |...YZ&.''%....p.| |
|
170 | 170 | 0090: a4 16 97 70 19 28 18 70 a5 e5 e7 73 71 25 a6 a4 |...p.(.p...sq%..| |
|
171 | 171 | 00a0: 28 00 19 20 17 af fa df ab ff 7b 3f fb 92 dc 8b |(.. ......{?....| |
|
172 | 172 | 00b0: 1f 62 bb 9e b7 d7 d9 87 3d 5a 44 89 2f b0 99 87 |.b......=ZD./...| |
|
173 | 173 | 00c0: ec e2 54 63 43 e3 b4 64 43 73 23 33 43 53 0b 63 |..TcC..dCs#3CS.c| |
|
174 | 174 | 00d0: d3 14 23 03 a0 fb 2c 2c 0c d3 80 1e 30 49 49 b1 |..#...,,....0II.| |
|
175 | 175 | 00e0: 4c 4a 32 48 33 30 b0 34 42 b8 38 29 b1 08 e2 62 |LJ2H30.4B.8)...b| |
|
176 | 176 | 00f0: 20 03 6a ca c2 2c db 2f f7 2c fa 6d fc fb 34 be | .j..,./.,.m..4.| |
|
177 | 177 | 0100: fc 5c 21 a2 39 cb 66 77 7c 00 0d c3 59 17 14 58 |.\!.9.fw|...Y..X| |
|
178 | 178 | 0110: 49 16 06 29 a9 a6 29 86 c6 16 e6 a6 16 a6 26 86 |I..)..).......&.| |
|
179 | 179 | 0120: c9 a6 69 06 a6 46 66 a6 89 29 86 26 26 89 49 96 |..i..Ff..).&&.I.| |
|
180 | 180 | 0130: 69 89 16 66 29 86 29 49 5c 20 07 3e 16 fe 23 ae |i..f).)I\ .>..#.| |
|
181 | 181 | 0140: 26 da 1c ab 10 1f d1 f8 e3 b3 ef cd dd fc 0c 93 |&...............| |
|
182 | 182 | 0150: 88 75 34 36 75 04 82 55 17 14 36 a4 38 10 04 d8 |.u46u..U..6.8...| |
|
183 | 183 | 0160: 21 01 9a b1 83 f7 e9 45 8b d2 56 c7 a3 1f 82 52 |!......E..V....R| |
|
184 | 184 | 0170: d7 8a 78 ed fc d5 76 f1 36 25 81 89 c7 ad ec 90 |..x...v.6%......| |
|
185 | 185 | 0180: 54 47 75 2b 89 49 b1 00 d2 8a eb 92 |TGu+.I......| |
|
186 | 186 | |
|
187 | 187 | $ echo "http://localhost:$HGPORT1/full.hg" > server/.hg/clonebundles.manifest |
|
188 | 188 | $ hg clone -U http://localhost:$HGPORT full-bundle |
|
189 | 189 | applying clone bundle from http://localhost:$HGPORT1/full.hg |
|
190 | 190 | adding changesets |
|
191 | 191 | adding manifests |
|
192 | 192 | adding file changes |
|
193 | 193 | added 2 changesets with 2 changes to 2 files |
|
194 | 194 | finished applying clone bundle |
|
195 | 195 | searching for changes |
|
196 | 196 | no changes found |
|
197 | 197 | |
|
198 | 198 | Feature works over SSH |
|
199 | 199 | |
|
200 | 200 | $ hg clone -U -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/server ssh-full-clone |
|
201 | 201 | applying clone bundle from http://localhost:$HGPORT1/full.hg |
|
202 | 202 | adding changesets |
|
203 | 203 | adding manifests |
|
204 | 204 | adding file changes |
|
205 | 205 | added 2 changesets with 2 changes to 2 files |
|
206 | 206 | finished applying clone bundle |
|
207 | 207 | searching for changes |
|
208 | 208 | no changes found |
|
209 | 209 | |
|
210 | 210 | Entry with unknown BUNDLESPEC is filtered and not used |
|
211 | 211 | |
|
212 | 212 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
213 | 213 | > http://bad.entry1 BUNDLESPEC=UNKNOWN |
|
214 | 214 | > http://bad.entry2 BUNDLESPEC=xz-v1 |
|
215 | 215 | > http://bad.entry3 BUNDLESPEC=none-v100 |
|
216 | 216 | > http://localhost:$HGPORT1/full.hg BUNDLESPEC=gzip-v2 |
|
217 | 217 | > EOF |
|
218 | 218 | |
|
219 | 219 | $ hg clone -U http://localhost:$HGPORT filter-unknown-type |
|
220 | 220 | applying clone bundle from http://localhost:$HGPORT1/full.hg |
|
221 | 221 | adding changesets |
|
222 | 222 | adding manifests |
|
223 | 223 | adding file changes |
|
224 | 224 | added 2 changesets with 2 changes to 2 files |
|
225 | 225 | finished applying clone bundle |
|
226 | 226 | searching for changes |
|
227 | 227 | no changes found |
|
228 | 228 | |
|
229 | 229 | Automatic fallback when all entries are filtered |
|
230 | 230 | |
|
231 | 231 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
232 | 232 | > http://bad.entry BUNDLESPEC=UNKNOWN |
|
233 | 233 | > EOF |
|
234 | 234 | |
|
235 | 235 | $ hg clone -U http://localhost:$HGPORT filter-all |
|
236 | 236 | no compatible clone bundles available on server; falling back to regular clone |
|
237 | 237 | (you may want to report this to the server operator) |
|
238 | 238 | requesting all changes |
|
239 | 239 | adding changesets |
|
240 | 240 | adding manifests |
|
241 | 241 | adding file changes |
|
242 | 242 | added 2 changesets with 2 changes to 2 files |
|
243 | 243 | |
|
244 | 244 | URLs requiring SNI are filtered in Python <2.7.9 |
|
245 | 245 | |
|
246 | 246 | $ cp full.hg sni.hg |
|
247 | 247 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
248 | 248 | > http://localhost:$HGPORT1/sni.hg REQUIRESNI=true |
|
249 | 249 | > http://localhost:$HGPORT1/full.hg |
|
250 | 250 | > EOF |
|
251 | 251 | |
|
252 | 252 | #if sslcontext |
|
253 | 253 | Python 2.7.9+ support SNI |
|
254 | 254 | |
|
255 | 255 | $ hg clone -U http://localhost:$HGPORT sni-supported |
|
256 | 256 | applying clone bundle from http://localhost:$HGPORT1/sni.hg |
|
257 | 257 | adding changesets |
|
258 | 258 | adding manifests |
|
259 | 259 | adding file changes |
|
260 | 260 | added 2 changesets with 2 changes to 2 files |
|
261 | 261 | finished applying clone bundle |
|
262 | 262 | searching for changes |
|
263 | 263 | no changes found |
|
264 | 264 | #else |
|
265 | 265 | Python <2.7.9 will filter SNI URLs |
|
266 | 266 | |
|
267 | 267 | $ hg clone -U http://localhost:$HGPORT sni-unsupported |
|
268 | 268 | applying clone bundle from http://localhost:$HGPORT1/full.hg |
|
269 | 269 | adding changesets |
|
270 | 270 | adding manifests |
|
271 | 271 | adding file changes |
|
272 | 272 | added 2 changesets with 2 changes to 2 files |
|
273 | 273 | finished applying clone bundle |
|
274 | 274 | searching for changes |
|
275 | 275 | no changes found |
|
276 | 276 | #endif |
|
277 | 277 | |
|
278 | 278 | Stream clone bundles are supported |
|
279 | 279 | |
|
280 | 280 | $ hg -R server debugcreatestreamclonebundle packed.hg |
|
281 | 281 | writing 613 bytes for 4 files |
|
282 | 282 | bundle requirements: generaldelta, revlogv1 |
|
283 | 283 | |
|
284 | 284 | No bundle spec should work |
|
285 | 285 | |
|
286 | 286 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
287 | 287 | > http://localhost:$HGPORT1/packed.hg |
|
288 | 288 | > EOF |
|
289 | 289 | |
|
290 | 290 | $ hg clone -U http://localhost:$HGPORT stream-clone-no-spec |
|
291 | 291 | applying clone bundle from http://localhost:$HGPORT1/packed.hg |
|
292 | 292 | 4 files to transfer, 613 bytes of data |
|
293 | 293 | transferred 613 bytes in *.* seconds (*) (glob) |
|
294 | 294 | finished applying clone bundle |
|
295 | 295 | searching for changes |
|
296 | 296 | no changes found |
|
297 | 297 | |
|
298 | 298 | Bundle spec without parameters should work |
|
299 | 299 | |
|
300 | 300 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
301 | 301 | > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1 |
|
302 | 302 | > EOF |
|
303 | 303 | |
|
304 | 304 | $ hg clone -U http://localhost:$HGPORT stream-clone-vanilla-spec |
|
305 | 305 | applying clone bundle from http://localhost:$HGPORT1/packed.hg |
|
306 | 306 | 4 files to transfer, 613 bytes of data |
|
307 | 307 | transferred 613 bytes in *.* seconds (*) (glob) |
|
308 | 308 | finished applying clone bundle |
|
309 | 309 | searching for changes |
|
310 | 310 | no changes found |
|
311 | 311 | |
|
312 | 312 | Bundle spec with format requirements should work |
|
313 | 313 | |
|
314 | 314 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
315 | 315 | > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1 |
|
316 | 316 | > EOF |
|
317 | 317 | |
|
318 | 318 | $ hg clone -U http://localhost:$HGPORT stream-clone-supported-requirements |
|
319 | 319 | applying clone bundle from http://localhost:$HGPORT1/packed.hg |
|
320 | 320 | 4 files to transfer, 613 bytes of data |
|
321 | 321 | transferred 613 bytes in *.* seconds (*) (glob) |
|
322 | 322 | finished applying clone bundle |
|
323 | 323 | searching for changes |
|
324 | 324 | no changes found |
|
325 | 325 | |
|
326 | 326 | Stream bundle spec with unknown requirements should be filtered out |
|
327 | 327 | |
|
328 | 328 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
329 | 329 | > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42 |
|
330 | 330 | > EOF |
|
331 | 331 | |
|
332 | 332 | $ hg clone -U http://localhost:$HGPORT stream-clone-unsupported-requirements |
|
333 | 333 | no compatible clone bundles available on server; falling back to regular clone |
|
334 | 334 | (you may want to report this to the server operator) |
|
335 | 335 | requesting all changes |
|
336 | 336 | adding changesets |
|
337 | 337 | adding manifests |
|
338 | 338 | adding file changes |
|
339 | 339 | added 2 changesets with 2 changes to 2 files |
|
340 | 340 | |
|
341 | 341 | Set up manifest for testing preferences |
|
342 | 342 | (Remember, the TYPE does not have to match reality - the URL is |
|
343 | 343 | important) |
|
344 | 344 | |
|
345 | 345 | $ cp full.hg gz-a.hg |
|
346 | 346 | $ cp full.hg gz-b.hg |
|
347 | 347 | $ cp full.hg bz2-a.hg |
|
348 | 348 | $ cp full.hg bz2-b.hg |
|
349 | 349 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
350 | 350 | > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 extra=a |
|
351 | 351 | > http://localhost:$HGPORT1/bz2-a.hg BUNDLESPEC=bzip2-v2 extra=a |
|
352 | 352 | > http://localhost:$HGPORT1/gz-b.hg BUNDLESPEC=gzip-v2 extra=b |
|
353 | 353 | > http://localhost:$HGPORT1/bz2-b.hg BUNDLESPEC=bzip2-v2 extra=b |
|
354 | 354 | > EOF |
|
355 | 355 | |
|
356 | 356 | Preferring an undefined attribute will take first entry |
|
357 | 357 | |
|
358 | 358 | $ hg --config ui.clonebundleprefers=foo=bar clone -U http://localhost:$HGPORT prefer-foo |
|
359 | 359 | applying clone bundle from http://localhost:$HGPORT1/gz-a.hg |
|
360 | 360 | adding changesets |
|
361 | 361 | adding manifests |
|
362 | 362 | adding file changes |
|
363 | 363 | added 2 changesets with 2 changes to 2 files |
|
364 | 364 | finished applying clone bundle |
|
365 | 365 | searching for changes |
|
366 | 366 | no changes found |
|
367 | 367 | |
|
368 | 368 | Preferring bz2 type will download first entry of that type |
|
369 | 369 | |
|
370 | 370 | $ hg --config ui.clonebundleprefers=COMPRESSION=bzip2 clone -U http://localhost:$HGPORT prefer-bz |
|
371 | 371 | applying clone bundle from http://localhost:$HGPORT1/bz2-a.hg |
|
372 | 372 | adding changesets |
|
373 | 373 | adding manifests |
|
374 | 374 | adding file changes |
|
375 | 375 | added 2 changesets with 2 changes to 2 files |
|
376 | 376 | finished applying clone bundle |
|
377 | 377 | searching for changes |
|
378 | 378 | no changes found |
|
379 | 379 | |
|
380 | 380 | Preferring multiple values of an option works |
|
381 | 381 | |
|
382 | 382 | $ hg --config ui.clonebundleprefers=COMPRESSION=unknown,COMPRESSION=bzip2 clone -U http://localhost:$HGPORT prefer-multiple-bz |
|
383 | 383 | applying clone bundle from http://localhost:$HGPORT1/bz2-a.hg |
|
384 | 384 | adding changesets |
|
385 | 385 | adding manifests |
|
386 | 386 | adding file changes |
|
387 | 387 | added 2 changesets with 2 changes to 2 files |
|
388 | 388 | finished applying clone bundle |
|
389 | 389 | searching for changes |
|
390 | 390 | no changes found |
|
391 | 391 | |
|
392 | 392 | Sorting multiple values should get us back to original first entry |
|
393 | 393 | |
|
394 | 394 | $ hg --config ui.clonebundleprefers=BUNDLESPEC=unknown,BUNDLESPEC=gzip-v2,BUNDLESPEC=bzip2-v2 clone -U http://localhost:$HGPORT prefer-multiple-gz |
|
395 | 395 | applying clone bundle from http://localhost:$HGPORT1/gz-a.hg |
|
396 | 396 | adding changesets |
|
397 | 397 | adding manifests |
|
398 | 398 | adding file changes |
|
399 | 399 | added 2 changesets with 2 changes to 2 files |
|
400 | 400 | finished applying clone bundle |
|
401 | 401 | searching for changes |
|
402 | 402 | no changes found |
|
403 | 403 | |
|
404 | 404 | Preferring multiple attributes has correct order |
|
405 | 405 | |
|
406 | 406 | $ hg --config ui.clonebundleprefers=extra=b,BUNDLESPEC=bzip2-v2 clone -U http://localhost:$HGPORT prefer-separate-attributes |
|
407 | 407 | applying clone bundle from http://localhost:$HGPORT1/bz2-b.hg |
|
408 | 408 | adding changesets |
|
409 | 409 | adding manifests |
|
410 | 410 | adding file changes |
|
411 | 411 | added 2 changesets with 2 changes to 2 files |
|
412 | 412 | finished applying clone bundle |
|
413 | 413 | searching for changes |
|
414 | 414 | no changes found |
|
415 | 415 | |
|
416 | 416 | Test where attribute is missing from some entries |
|
417 | 417 | |
|
418 | 418 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
419 | 419 | > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 |
|
420 | 420 | > http://localhost:$HGPORT1/bz2-a.hg BUNDLESPEC=bzip2-v2 |
|
421 | 421 | > http://localhost:$HGPORT1/gz-b.hg BUNDLESPEC=gzip-v2 extra=b |
|
422 | 422 | > http://localhost:$HGPORT1/bz2-b.hg BUNDLESPEC=bzip2-v2 extra=b |
|
423 | 423 | > EOF |
|
424 | 424 | |
|
425 | 425 | $ hg --config ui.clonebundleprefers=extra=b clone -U http://localhost:$HGPORT prefer-partially-defined-attribute |
|
426 | 426 | applying clone bundle from http://localhost:$HGPORT1/gz-b.hg |
|
427 | 427 | adding changesets |
|
428 | 428 | adding manifests |
|
429 | 429 | adding file changes |
|
430 | 430 | added 2 changesets with 2 changes to 2 files |
|
431 | 431 | finished applying clone bundle |
|
432 | 432 | searching for changes |
|
433 | 433 | no changes found |
|
434 | 434 | |
|
435 |
Test interaction between clone bundles and -- |
|
|
435 | Test interaction between clone bundles and --stream | |
|
436 | 436 | |
|
437 | 437 | A manifest with just a gzip bundle |
|
438 | 438 | |
|
439 | 439 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
440 | 440 | > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 |
|
441 | 441 | > EOF |
|
442 | 442 | |
|
443 |
$ hg clone -U -- |
|
|
443 | $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip | |
|
444 | 444 | no compatible clone bundles available on server; falling back to regular clone |
|
445 | 445 | (you may want to report this to the server operator) |
|
446 | 446 | streaming all changes |
|
447 | 447 | 4 files to transfer, 613 bytes of data |
|
448 | 448 | transferred 613 bytes in * seconds (*) (glob) |
|
449 | 449 | searching for changes |
|
450 | 450 | no changes found |
|
451 | 451 | |
|
452 | 452 | A manifest with a stream clone but no BUNDLESPEC |
|
453 | 453 | |
|
454 | 454 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
455 | 455 | > http://localhost:$HGPORT1/packed.hg |
|
456 | 456 | > EOF |
|
457 | 457 | |
|
458 |
$ hg clone -U -- |
|
|
458 | $ hg clone -U --stream http://localhost:$HGPORT uncompressed-no-bundlespec | |
|
459 | 459 | no compatible clone bundles available on server; falling back to regular clone |
|
460 | 460 | (you may want to report this to the server operator) |
|
461 | 461 | streaming all changes |
|
462 | 462 | 4 files to transfer, 613 bytes of data |
|
463 | 463 | transferred 613 bytes in * seconds (*) (glob) |
|
464 | 464 | searching for changes |
|
465 | 465 | no changes found |
|
466 | 466 | |
|
467 | 467 | A manifest with a gzip bundle and a stream clone |
|
468 | 468 | |
|
469 | 469 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
470 | 470 | > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 |
|
471 | 471 | > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1 |
|
472 | 472 | > EOF |
|
473 | 473 | |
|
474 |
$ hg clone -U -- |
|
|
474 | $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed | |
|
475 | 475 | applying clone bundle from http://localhost:$HGPORT1/packed.hg |
|
476 | 476 | 4 files to transfer, 613 bytes of data |
|
477 | 477 | transferred 613 bytes in * seconds (*) (glob) |
|
478 | 478 | finished applying clone bundle |
|
479 | 479 | searching for changes |
|
480 | 480 | no changes found |
|
481 | 481 | |
|
482 | 482 | A manifest with a gzip bundle and stream clone with supported requirements |
|
483 | 483 | |
|
484 | 484 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
485 | 485 | > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 |
|
486 | 486 | > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1 |
|
487 | 487 | > EOF |
|
488 | 488 | |
|
489 |
$ hg clone -U -- |
|
|
489 | $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed-requirements | |
|
490 | 490 | applying clone bundle from http://localhost:$HGPORT1/packed.hg |
|
491 | 491 | 4 files to transfer, 613 bytes of data |
|
492 | 492 | transferred 613 bytes in * seconds (*) (glob) |
|
493 | 493 | finished applying clone bundle |
|
494 | 494 | searching for changes |
|
495 | 495 | no changes found |
|
496 | 496 | |
|
497 | 497 | A manifest with a gzip bundle and a stream clone with unsupported requirements |
|
498 | 498 | |
|
499 | 499 | $ cat > server/.hg/clonebundles.manifest << EOF |
|
500 | 500 | > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 |
|
501 | 501 | > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42 |
|
502 | 502 | > EOF |
|
503 | 503 | |
|
504 |
$ hg clone -U -- |
|
|
504 | $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed-unsupported-requirements | |
|
505 | 505 | no compatible clone bundles available on server; falling back to regular clone |
|
506 | 506 | (you may want to report this to the server operator) |
|
507 | 507 | streaming all changes |
|
508 | 508 | 4 files to transfer, 613 bytes of data |
|
509 | 509 | transferred 613 bytes in * seconds (*) (glob) |
|
510 | 510 | searching for changes |
|
511 | 511 | no changes found |
@@ -1,383 +1,383 b'' | |||
|
1 | 1 | Show all commands except debug commands |
|
2 | 2 | $ hg debugcomplete |
|
3 | 3 | add |
|
4 | 4 | addremove |
|
5 | 5 | annotate |
|
6 | 6 | archive |
|
7 | 7 | backout |
|
8 | 8 | bisect |
|
9 | 9 | bookmarks |
|
10 | 10 | branch |
|
11 | 11 | branches |
|
12 | 12 | bundle |
|
13 | 13 | cat |
|
14 | 14 | clone |
|
15 | 15 | commit |
|
16 | 16 | config |
|
17 | 17 | copy |
|
18 | 18 | diff |
|
19 | 19 | export |
|
20 | 20 | files |
|
21 | 21 | forget |
|
22 | 22 | graft |
|
23 | 23 | grep |
|
24 | 24 | heads |
|
25 | 25 | help |
|
26 | 26 | identify |
|
27 | 27 | import |
|
28 | 28 | incoming |
|
29 | 29 | init |
|
30 | 30 | locate |
|
31 | 31 | log |
|
32 | 32 | manifest |
|
33 | 33 | merge |
|
34 | 34 | outgoing |
|
35 | 35 | parents |
|
36 | 36 | paths |
|
37 | 37 | phase |
|
38 | 38 | pull |
|
39 | 39 | push |
|
40 | 40 | recover |
|
41 | 41 | remove |
|
42 | 42 | rename |
|
43 | 43 | resolve |
|
44 | 44 | revert |
|
45 | 45 | rollback |
|
46 | 46 | root |
|
47 | 47 | serve |
|
48 | 48 | status |
|
49 | 49 | summary |
|
50 | 50 | tag |
|
51 | 51 | tags |
|
52 | 52 | tip |
|
53 | 53 | unbundle |
|
54 | 54 | update |
|
55 | 55 | verify |
|
56 | 56 | version |
|
57 | 57 | |
|
58 | 58 | Show all commands that start with "a" |
|
59 | 59 | $ hg debugcomplete a |
|
60 | 60 | add |
|
61 | 61 | addremove |
|
62 | 62 | annotate |
|
63 | 63 | archive |
|
64 | 64 | |
|
65 | 65 | Do not show debug commands if there are other candidates |
|
66 | 66 | $ hg debugcomplete d |
|
67 | 67 | diff |
|
68 | 68 | |
|
69 | 69 | Show debug commands if there are no other candidates |
|
70 | 70 | $ hg debugcomplete debug |
|
71 | 71 | debugancestor |
|
72 | 72 | debugapplystreamclonebundle |
|
73 | 73 | debugbuilddag |
|
74 | 74 | debugbundle |
|
75 | 75 | debugcheckstate |
|
76 | 76 | debugcolor |
|
77 | 77 | debugcommands |
|
78 | 78 | debugcomplete |
|
79 | 79 | debugconfig |
|
80 | 80 | debugcreatestreamclonebundle |
|
81 | 81 | debugdag |
|
82 | 82 | debugdata |
|
83 | 83 | debugdate |
|
84 | 84 | debugdeltachain |
|
85 | 85 | debugdirstate |
|
86 | 86 | debugdiscovery |
|
87 | 87 | debugextensions |
|
88 | 88 | debugfileset |
|
89 | 89 | debugfsinfo |
|
90 | 90 | debuggetbundle |
|
91 | 91 | debugignore |
|
92 | 92 | debugindex |
|
93 | 93 | debugindexdot |
|
94 | 94 | debuginstall |
|
95 | 95 | debugknown |
|
96 | 96 | debuglabelcomplete |
|
97 | 97 | debuglocks |
|
98 | 98 | debugmergestate |
|
99 | 99 | debugnamecomplete |
|
100 | 100 | debugobsolete |
|
101 | 101 | debugpathcomplete |
|
102 | 102 | debugpickmergetool |
|
103 | 103 | debugpushkey |
|
104 | 104 | debugpvec |
|
105 | 105 | debugrebuilddirstate |
|
106 | 106 | debugrebuildfncache |
|
107 | 107 | debugrename |
|
108 | 108 | debugrevlog |
|
109 | 109 | debugrevspec |
|
110 | 110 | debugsetparents |
|
111 | 111 | debugssl |
|
112 | 112 | debugsub |
|
113 | 113 | debugsuccessorssets |
|
114 | 114 | debugtemplate |
|
115 | 115 | debugupdatecaches |
|
116 | 116 | debugupgraderepo |
|
117 | 117 | debugwalk |
|
118 | 118 | debugwireargs |
|
119 | 119 | |
|
120 | 120 | Do not show the alias of a debug command if there are other candidates |
|
121 | 121 | (this should hide rawcommit) |
|
122 | 122 | $ hg debugcomplete r |
|
123 | 123 | recover |
|
124 | 124 | remove |
|
125 | 125 | rename |
|
126 | 126 | resolve |
|
127 | 127 | revert |
|
128 | 128 | rollback |
|
129 | 129 | root |
|
130 | 130 | Show the alias of a debug command if there are no other candidates |
|
131 | 131 | $ hg debugcomplete rawc |
|
132 | 132 | |
|
133 | 133 | |
|
134 | 134 | Show the global options |
|
135 | 135 | $ hg debugcomplete --options | sort |
|
136 | 136 | --color |
|
137 | 137 | --config |
|
138 | 138 | --cwd |
|
139 | 139 | --debug |
|
140 | 140 | --debugger |
|
141 | 141 | --encoding |
|
142 | 142 | --encodingmode |
|
143 | 143 | --help |
|
144 | 144 | --hidden |
|
145 | 145 | --noninteractive |
|
146 | 146 | --pager |
|
147 | 147 | --profile |
|
148 | 148 | --quiet |
|
149 | 149 | --repository |
|
150 | 150 | --time |
|
151 | 151 | --traceback |
|
152 | 152 | --verbose |
|
153 | 153 | --version |
|
154 | 154 | -R |
|
155 | 155 | -h |
|
156 | 156 | -q |
|
157 | 157 | -v |
|
158 | 158 | -y |
|
159 | 159 | |
|
160 | 160 | Show the options for the "serve" command |
|
161 | 161 | $ hg debugcomplete --options serve | sort |
|
162 | 162 | --accesslog |
|
163 | 163 | --address |
|
164 | 164 | --certificate |
|
165 | 165 | --cmdserver |
|
166 | 166 | --color |
|
167 | 167 | --config |
|
168 | 168 | --cwd |
|
169 | 169 | --daemon |
|
170 | 170 | --daemon-postexec |
|
171 | 171 | --debug |
|
172 | 172 | --debugger |
|
173 | 173 | --encoding |
|
174 | 174 | --encodingmode |
|
175 | 175 | --errorlog |
|
176 | 176 | --help |
|
177 | 177 | --hidden |
|
178 | 178 | --ipv6 |
|
179 | 179 | --name |
|
180 | 180 | --noninteractive |
|
181 | 181 | --pager |
|
182 | 182 | --pid-file |
|
183 | 183 | --port |
|
184 | 184 | --prefix |
|
185 | 185 | --profile |
|
186 | 186 | --quiet |
|
187 | 187 | --repository |
|
188 | 188 | --stdio |
|
189 | 189 | --style |
|
190 | 190 | --subrepos |
|
191 | 191 | --templates |
|
192 | 192 | --time |
|
193 | 193 | --traceback |
|
194 | 194 | --verbose |
|
195 | 195 | --version |
|
196 | 196 | --web-conf |
|
197 | 197 | -6 |
|
198 | 198 | -A |
|
199 | 199 | -E |
|
200 | 200 | -R |
|
201 | 201 | -S |
|
202 | 202 | -a |
|
203 | 203 | -d |
|
204 | 204 | -h |
|
205 | 205 | -n |
|
206 | 206 | -p |
|
207 | 207 | -q |
|
208 | 208 | -t |
|
209 | 209 | -v |
|
210 | 210 | -y |
|
211 | 211 | |
|
212 | 212 | Show an error if we use --options with an ambiguous abbreviation |
|
213 | 213 | $ hg debugcomplete --options s |
|
214 | 214 | hg: command 's' is ambiguous: |
|
215 | 215 | serve showconfig status summary |
|
216 | 216 | [255] |
|
217 | 217 | |
|
218 | 218 | Show all commands + options |
|
219 | 219 | $ hg debugcommands |
|
220 | 220 | add: include, exclude, subrepos, dry-run |
|
221 | 221 | annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template |
|
222 | clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure | |
|
222 | clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure | |
|
223 | 223 | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos |
|
224 | 224 | diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos |
|
225 | 225 | export: output, switch-parent, rev, text, git, binary, nodates |
|
226 | 226 | forget: include, exclude |
|
227 | 227 | init: ssh, remotecmd, insecure |
|
228 | 228 | log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude |
|
229 | 229 | merge: force, rev, preview, tool |
|
230 | 230 | pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure |
|
231 | 231 | push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure |
|
232 | 232 | remove: after, force, subrepos, include, exclude |
|
233 | 233 | serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos |
|
234 | 234 | status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template |
|
235 | 235 | summary: remote |
|
236 | 236 | update: clean, check, merge, date, rev, tool |
|
237 | 237 | addremove: similarity, subrepos, include, exclude, dry-run |
|
238 | 238 | archive: no-decode, prefix, rev, type, subrepos, include, exclude |
|
239 | 239 | backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user |
|
240 | 240 | bisect: reset, good, bad, skip, extend, command, noupdate |
|
241 | 241 | bookmarks: force, rev, delete, rename, inactive, template |
|
242 | 242 | branch: force, clean |
|
243 | 243 | branches: active, closed, template |
|
244 | 244 | bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure |
|
245 | 245 | cat: output, rev, decode, include, exclude, template |
|
246 | 246 | config: untrusted, edit, local, global, template |
|
247 | 247 | copy: after, force, include, exclude, dry-run |
|
248 | 248 | debugancestor: |
|
249 | 249 | debugapplystreamclonebundle: |
|
250 | 250 | debugbuilddag: mergeable-file, overwritten-file, new-file |
|
251 | 251 | debugbundle: all, part-type, spec |
|
252 | 252 | debugcheckstate: |
|
253 | 253 | debugcolor: style |
|
254 | 254 | debugcommands: |
|
255 | 255 | debugcomplete: options |
|
256 | 256 | debugcreatestreamclonebundle: |
|
257 | 257 | debugdag: tags, branches, dots, spaces |
|
258 | 258 | debugdata: changelog, manifest, dir |
|
259 | 259 | debugdate: extended |
|
260 | 260 | debugdeltachain: changelog, manifest, dir, template |
|
261 | 261 | debugdirstate: nodates, datesort |
|
262 | 262 | debugdiscovery: old, nonheads, ssh, remotecmd, insecure |
|
263 | 263 | debugextensions: template |
|
264 | 264 | debugfileset: rev |
|
265 | 265 | debugfsinfo: |
|
266 | 266 | debuggetbundle: head, common, type |
|
267 | 267 | debugignore: |
|
268 | 268 | debugindex: changelog, manifest, dir, format |
|
269 | 269 | debugindexdot: changelog, manifest, dir |
|
270 | 270 | debuginstall: template |
|
271 | 271 | debugknown: |
|
272 | 272 | debuglabelcomplete: |
|
273 | 273 | debuglocks: force-lock, force-wlock |
|
274 | 274 | debugmergestate: |
|
275 | 275 | debugnamecomplete: |
|
276 | 276 | debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template |
|
277 | 277 | debugpathcomplete: full, normal, added, removed |
|
278 | 278 | debugpickmergetool: rev, changedelete, include, exclude, tool |
|
279 | 279 | debugpushkey: |
|
280 | 280 | debugpvec: |
|
281 | 281 | debugrebuilddirstate: rev, minimal |
|
282 | 282 | debugrebuildfncache: |
|
283 | 283 | debugrename: rev |
|
284 | 284 | debugrevlog: changelog, manifest, dir, dump |
|
285 | 285 | debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized |
|
286 | 286 | debugsetparents: |
|
287 | 287 | debugssl: |
|
288 | 288 | debugsub: rev |
|
289 | 289 | debugsuccessorssets: closest |
|
290 | 290 | debugtemplate: rev, define |
|
291 | 291 | debugupdatecaches: |
|
292 | 292 | debugupgraderepo: optimize, run |
|
293 | 293 | debugwalk: include, exclude |
|
294 | 294 | debugwireargs: three, four, five, ssh, remotecmd, insecure |
|
295 | 295 | files: rev, print0, include, exclude, template, subrepos |
|
296 | 296 | graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run |
|
297 | 297 | grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, template, include, exclude |
|
298 | 298 | heads: rev, topo, active, closed, style, template |
|
299 | 299 | help: extension, command, keyword, system |
|
300 | 300 | identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template |
|
301 | 301 | import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity |
|
302 | 302 | incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos |
|
303 | 303 | locate: rev, print0, fullpath, include, exclude |
|
304 | 304 | manifest: rev, all, template |
|
305 | 305 | outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos |
|
306 | 306 | parents: rev, style, template |
|
307 | 307 | paths: template |
|
308 | 308 | phase: public, draft, secret, force, rev |
|
309 | 309 | recover: |
|
310 | 310 | rename: after, force, include, exclude, dry-run |
|
311 | 311 | resolve: all, list, mark, unmark, no-status, tool, include, exclude, template |
|
312 | 312 | revert: all, date, rev, no-backup, interactive, include, exclude, dry-run |
|
313 | 313 | rollback: dry-run, force |
|
314 | 314 | root: |
|
315 | 315 | tag: force, local, rev, remove, edit, message, date, user |
|
316 | 316 | tags: template |
|
317 | 317 | tip: patch, git, style, template |
|
318 | 318 | unbundle: update |
|
319 | 319 | verify: |
|
320 | 320 | version: template |
|
321 | 321 | |
|
322 | 322 | $ hg init a |
|
323 | 323 | $ cd a |
|
324 | 324 | $ echo fee > fee |
|
325 | 325 | $ hg ci -q -Amfee |
|
326 | 326 | $ hg tag fee |
|
327 | 327 | $ mkdir fie |
|
328 | 328 | $ echo dead > fie/dead |
|
329 | 329 | $ echo live > fie/live |
|
330 | 330 | $ hg bookmark fo |
|
331 | 331 | $ hg branch -q fie |
|
332 | 332 | $ hg ci -q -Amfie |
|
333 | 333 | $ echo fo > fo |
|
334 | 334 | $ hg branch -qf default |
|
335 | 335 | $ hg ci -q -Amfo |
|
336 | 336 | $ echo Fum > Fum |
|
337 | 337 | $ hg ci -q -AmFum |
|
338 | 338 | $ hg bookmark Fum |
|
339 | 339 | |
|
340 | 340 | Test debugpathcomplete |
|
341 | 341 | |
|
342 | 342 | $ hg debugpathcomplete f |
|
343 | 343 | fee |
|
344 | 344 | fie |
|
345 | 345 | fo |
|
346 | 346 | $ hg debugpathcomplete -f f |
|
347 | 347 | fee |
|
348 | 348 | fie/dead |
|
349 | 349 | fie/live |
|
350 | 350 | fo |
|
351 | 351 | |
|
352 | 352 | $ hg rm Fum |
|
353 | 353 | $ hg debugpathcomplete -r F |
|
354 | 354 | Fum |
|
355 | 355 | |
|
356 | 356 | Test debugnamecomplete |
|
357 | 357 | |
|
358 | 358 | $ hg debugnamecomplete |
|
359 | 359 | Fum |
|
360 | 360 | default |
|
361 | 361 | fee |
|
362 | 362 | fie |
|
363 | 363 | fo |
|
364 | 364 | tip |
|
365 | 365 | $ hg debugnamecomplete f |
|
366 | 366 | fee |
|
367 | 367 | fie |
|
368 | 368 | fo |
|
369 | 369 | |
|
370 | 370 | Test debuglabelcomplete, a deprecated name for debugnamecomplete that is still |
|
371 | 371 | used for completions in some shells. |
|
372 | 372 | |
|
373 | 373 | $ hg debuglabelcomplete |
|
374 | 374 | Fum |
|
375 | 375 | default |
|
376 | 376 | fee |
|
377 | 377 | fie |
|
378 | 378 | fo |
|
379 | 379 | tip |
|
380 | 380 | $ hg debuglabelcomplete f |
|
381 | 381 | fee |
|
382 | 382 | fie |
|
383 | 383 | fo |
@@ -1,405 +1,405 b'' | |||
|
1 | 1 | #require serve |
|
2 | 2 | |
|
3 | 3 | This test is a duplicate of 'test-http.t', feel free to factor out |
|
4 | 4 | parts that are not bundle1/bundle2 specific. |
|
5 | 5 | |
|
6 | 6 | $ cat << EOF >> $HGRCPATH |
|
7 | 7 | > [devel] |
|
8 | 8 | > # This test is dedicated to interaction through old bundle |
|
9 | 9 | > legacy.exchange = bundle1 |
|
10 | 10 | > EOF |
|
11 | 11 | |
|
12 | 12 | $ hg init test |
|
13 | 13 | $ cd test |
|
14 | 14 | $ echo foo>foo |
|
15 | 15 | $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg |
|
16 | 16 | $ echo foo>foo.d/foo |
|
17 | 17 | $ echo bar>foo.d/bAr.hg.d/BaR |
|
18 | 18 | $ echo bar>foo.d/baR.d.hg/bAR |
|
19 | 19 | $ hg commit -A -m 1 |
|
20 | 20 | adding foo |
|
21 | 21 | adding foo.d/bAr.hg.d/BaR |
|
22 | 22 | adding foo.d/baR.d.hg/bAR |
|
23 | 23 | adding foo.d/foo |
|
24 | 24 | $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log |
|
25 | 25 | $ hg serve --config server.uncompressed=False -p $HGPORT1 -d --pid-file=../hg2.pid |
|
26 | 26 | |
|
27 | 27 | Test server address cannot be reused |
|
28 | 28 | |
|
29 | 29 | #if windows |
|
30 | 30 | $ hg serve -p $HGPORT1 2>&1 |
|
31 | 31 | abort: cannot start server at 'localhost:$HGPORT1': * (glob) |
|
32 | 32 | [255] |
|
33 | 33 | #else |
|
34 | 34 | $ hg serve -p $HGPORT1 2>&1 |
|
35 | 35 | abort: cannot start server at 'localhost:$HGPORT1': Address already in use |
|
36 | 36 | [255] |
|
37 | 37 | #endif |
|
38 | 38 | $ cd .. |
|
39 | 39 | $ cat hg1.pid hg2.pid >> $DAEMON_PIDS |
|
40 | 40 | |
|
41 | 41 | clone via stream |
|
42 | 42 | |
|
43 |
$ hg clone -- |
|
|
43 | $ hg clone --stream http://localhost:$HGPORT/ copy 2>&1 | |
|
44 | 44 | streaming all changes |
|
45 | 45 | 6 files to transfer, 606 bytes of data |
|
46 | 46 | transferred * bytes in * seconds (*/sec) (glob) |
|
47 | 47 | searching for changes |
|
48 | 48 | no changes found |
|
49 | 49 | updating to branch default |
|
50 | 50 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
51 | 51 | $ hg verify -R copy |
|
52 | 52 | checking changesets |
|
53 | 53 | checking manifests |
|
54 | 54 | crosschecking files in changesets and manifests |
|
55 | 55 | checking files |
|
56 | 56 | 4 files, 1 changesets, 4 total revisions |
|
57 | 57 | |
|
58 | 58 | try to clone via stream, should use pull instead |
|
59 | 59 | |
|
60 |
$ hg clone -- |
|
|
60 | $ hg clone --stream http://localhost:$HGPORT1/ copy2 | |
|
61 | 61 | warning: stream clone requested but server has them disabled |
|
62 | 62 | requesting all changes |
|
63 | 63 | adding changesets |
|
64 | 64 | adding manifests |
|
65 | 65 | adding file changes |
|
66 | 66 | added 1 changesets with 4 changes to 4 files |
|
67 | 67 | updating to branch default |
|
68 | 68 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
69 | 69 | |
|
70 | 70 | try to clone via stream but missing requirements, so should use pull instead |
|
71 | 71 | |
|
72 | 72 | $ cat > $TESTTMP/removesupportedformat.py << EOF |
|
73 | 73 | > from mercurial import localrepo |
|
74 | 74 | > def extsetup(ui): |
|
75 | 75 | > localrepo.localrepository.supportedformats.remove('generaldelta') |
|
76 | 76 | > EOF |
|
77 | 77 | |
|
78 |
$ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py -- |
|
|
78 | $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3 | |
|
79 | 79 | warning: stream clone requested but client is missing requirements: generaldelta |
|
80 | 80 | (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information) |
|
81 | 81 | requesting all changes |
|
82 | 82 | adding changesets |
|
83 | 83 | adding manifests |
|
84 | 84 | adding file changes |
|
85 | 85 | added 1 changesets with 4 changes to 4 files |
|
86 | 86 | updating to branch default |
|
87 | 87 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
88 | 88 | |
|
89 | 89 | clone via pull |
|
90 | 90 | |
|
91 | 91 | $ hg clone http://localhost:$HGPORT1/ copy-pull |
|
92 | 92 | requesting all changes |
|
93 | 93 | adding changesets |
|
94 | 94 | adding manifests |
|
95 | 95 | adding file changes |
|
96 | 96 | added 1 changesets with 4 changes to 4 files |
|
97 | 97 | updating to branch default |
|
98 | 98 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
99 | 99 | $ hg verify -R copy-pull |
|
100 | 100 | checking changesets |
|
101 | 101 | checking manifests |
|
102 | 102 | crosschecking files in changesets and manifests |
|
103 | 103 | checking files |
|
104 | 104 | 4 files, 1 changesets, 4 total revisions |
|
105 | 105 | $ cd test |
|
106 | 106 | $ echo bar > bar |
|
107 | 107 | $ hg commit -A -d '1 0' -m 2 |
|
108 | 108 | adding bar |
|
109 | 109 | $ cd .. |
|
110 | 110 | |
|
111 | 111 | clone over http with --update |
|
112 | 112 | |
|
113 | 113 | $ hg clone http://localhost:$HGPORT1/ updated --update 0 |
|
114 | 114 | requesting all changes |
|
115 | 115 | adding changesets |
|
116 | 116 | adding manifests |
|
117 | 117 | adding file changes |
|
118 | 118 | added 2 changesets with 5 changes to 5 files |
|
119 | 119 | updating to branch default |
|
120 | 120 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
121 | 121 | $ hg log -r . -R updated |
|
122 | 122 | changeset: 0:8b6053c928fe |
|
123 | 123 | user: test |
|
124 | 124 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
125 | 125 | summary: 1 |
|
126 | 126 | |
|
127 | 127 | $ rm -rf updated |
|
128 | 128 | |
|
129 | 129 | incoming via HTTP |
|
130 | 130 | |
|
131 | 131 | $ hg clone http://localhost:$HGPORT1/ --rev 0 partial |
|
132 | 132 | adding changesets |
|
133 | 133 | adding manifests |
|
134 | 134 | adding file changes |
|
135 | 135 | added 1 changesets with 4 changes to 4 files |
|
136 | 136 | updating to branch default |
|
137 | 137 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
138 | 138 | $ cd partial |
|
139 | 139 | $ touch LOCAL |
|
140 | 140 | $ hg ci -qAm LOCAL |
|
141 | 141 | $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n' |
|
142 | 142 | comparing with http://localhost:$HGPORT1/ |
|
143 | 143 | searching for changes |
|
144 | 144 | 2 |
|
145 | 145 | $ cd .. |
|
146 | 146 | |
|
147 | 147 | pull |
|
148 | 148 | |
|
149 | 149 | $ cd copy-pull |
|
150 | 150 | $ cat >> .hg/hgrc <<EOF |
|
151 | 151 | > [hooks] |
|
152 | 152 | > changegroup = sh -c "printenv.py changegroup" |
|
153 | 153 | > EOF |
|
154 | 154 | $ hg pull |
|
155 | 155 | pulling from http://localhost:$HGPORT1/ |
|
156 | 156 | searching for changes |
|
157 | 157 | adding changesets |
|
158 | 158 | adding manifests |
|
159 | 159 | adding file changes |
|
160 | 160 | added 1 changesets with 1 changes to 1 files |
|
161 | 161 | changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=http://localhost:$HGPORT1/ |
|
162 | 162 | (run 'hg update' to get a working copy) |
|
163 | 163 | $ cd .. |
|
164 | 164 | |
|
165 | 165 | clone from invalid URL |
|
166 | 166 | |
|
167 | 167 | $ hg clone http://localhost:$HGPORT/bad |
|
168 | 168 | abort: HTTP Error 404: Not Found |
|
169 | 169 | [255] |
|
170 | 170 | |
|
171 | 171 | test http authentication |
|
172 | 172 | + use the same server to test server side streaming preference |
|
173 | 173 | |
|
174 | 174 | $ cd test |
|
175 | 175 | $ cat << EOT > userpass.py |
|
176 | 176 | > import base64 |
|
177 | 177 | > from mercurial.hgweb import common |
|
178 | 178 | > def perform_authentication(hgweb, req, op): |
|
179 | 179 | > auth = req.env.get('HTTP_AUTHORIZATION') |
|
180 | 180 | > if not auth: |
|
181 | 181 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
|
182 | 182 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
|
183 | 183 | > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: |
|
184 | 184 | > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') |
|
185 | 185 | > def extsetup(): |
|
186 | 186 | > common.permhooks.insert(0, perform_authentication) |
|
187 | 187 | > EOT |
|
188 | 188 | $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \ |
|
189 | 189 | > --config server.preferuncompressed=True \ |
|
190 | 190 | > --config web.push_ssl=False --config web.allow_push=* -A ../access.log |
|
191 | 191 | $ cat pid >> $DAEMON_PIDS |
|
192 | 192 | |
|
193 | 193 | $ cat << EOF > get_pass.py |
|
194 | 194 | > import getpass |
|
195 | 195 | > def newgetpass(arg): |
|
196 | 196 | > return "pass" |
|
197 | 197 | > getpass.getpass = newgetpass |
|
198 | 198 | > EOF |
|
199 | 199 | |
|
200 | 200 | $ hg id http://localhost:$HGPORT2/ |
|
201 | 201 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
202 | 202 | [255] |
|
203 | 203 | $ hg id http://localhost:$HGPORT2/ |
|
204 | 204 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
205 | 205 | [255] |
|
206 | 206 | $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/ |
|
207 | 207 | http authorization required for http://localhost:$HGPORT2/ |
|
208 | 208 | realm: mercurial |
|
209 | 209 | user: user |
|
210 | 210 | password: 5fed3813f7f5 |
|
211 | 211 | $ hg id http://user:pass@localhost:$HGPORT2/ |
|
212 | 212 | 5fed3813f7f5 |
|
213 | 213 | $ echo '[auth]' >> .hg/hgrc |
|
214 | 214 | $ echo 'l.schemes=http' >> .hg/hgrc |
|
215 | 215 | $ echo 'l.prefix=lo' >> .hg/hgrc |
|
216 | 216 | $ echo 'l.username=user' >> .hg/hgrc |
|
217 | 217 | $ echo 'l.password=pass' >> .hg/hgrc |
|
218 | 218 | $ hg id http://localhost:$HGPORT2/ |
|
219 | 219 | 5fed3813f7f5 |
|
220 | 220 | $ hg id http://localhost:$HGPORT2/ |
|
221 | 221 | 5fed3813f7f5 |
|
222 | 222 | $ hg id http://user@localhost:$HGPORT2/ |
|
223 | 223 | 5fed3813f7f5 |
|
224 | 224 | $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1 |
|
225 | 225 | streaming all changes |
|
226 | 226 | 7 files to transfer, 916 bytes of data |
|
227 | 227 | transferred * bytes in * seconds (*/sec) (glob) |
|
228 | 228 | searching for changes |
|
229 | 229 | no changes found |
|
230 | 230 | updating to branch default |
|
231 | 231 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
232 | 232 | --pull should override server's preferuncompressed |
|
233 | 233 | $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1 |
|
234 | 234 | requesting all changes |
|
235 | 235 | adding changesets |
|
236 | 236 | adding manifests |
|
237 | 237 | adding file changes |
|
238 | 238 | added 2 changesets with 5 changes to 5 files |
|
239 | 239 | updating to branch default |
|
240 | 240 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
241 | 241 | |
|
242 | 242 | $ hg id http://user2@localhost:$HGPORT2/ |
|
243 | 243 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
244 | 244 | [255] |
|
245 | 245 | $ hg id http://user:pass2@localhost:$HGPORT2/ |
|
246 | 246 | abort: HTTP Error 403: no |
|
247 | 247 | [255] |
|
248 | 248 | |
|
249 | 249 | $ hg -R dest tag -r tip top |
|
250 | 250 | $ hg -R dest push http://user:pass@localhost:$HGPORT2/ |
|
251 | 251 | pushing to http://user:***@localhost:$HGPORT2/ |
|
252 | 252 | searching for changes |
|
253 | 253 | remote: adding changesets |
|
254 | 254 | remote: adding manifests |
|
255 | 255 | remote: adding file changes |
|
256 | 256 | remote: added 1 changesets with 1 changes to 1 files |
|
257 | 257 | $ hg rollback -q |
|
258 | 258 | |
|
259 | 259 | $ sed 's/.*] "/"/' < ../access.log |
|
260 | 260 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
261 | 261 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
262 | 262 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
263 | 263 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
264 | 264 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
265 | 265 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
266 | 266 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
267 | 267 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
268 | 268 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
269 | 269 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
270 | 270 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
271 | 271 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
272 | 272 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
273 | 273 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
274 | 274 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
275 | 275 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
276 | 276 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
277 | 277 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
278 | 278 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
279 | 279 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
280 | 280 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
281 | 281 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
282 | 282 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
283 | 283 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
284 | 284 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
285 | 285 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
286 | 286 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
287 | 287 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
288 | 288 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
289 | 289 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
290 | 290 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
291 | 291 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
292 | 292 | "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
293 | 293 | "GET /?cmd=stream_out HTTP/1.1" 401 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
294 | 294 | "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
295 | 295 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
296 | 296 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
297 | 297 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
298 | 298 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
299 | 299 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
300 | 300 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
301 | 301 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
302 | 302 | "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
303 | 303 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
304 | 304 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
305 | 305 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
306 | 306 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
307 | 307 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
308 | 308 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
309 | 309 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
310 | 310 | "GET /?cmd=listkeys HTTP/1.1" 403 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
311 | 311 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
312 | 312 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D7f4e523d01f2cc3765ac8934da3d14db775ff872 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
313 | 313 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
314 | 314 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
315 | 315 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
316 | 316 | "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
317 | 317 | "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
318 | 318 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
319 | 319 | "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=686173686564+5eb5abfefeea63c80dd7553bcc3783f37e0c5524* (glob) |
|
320 | 320 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
321 | 321 | |
|
322 | 322 | $ cd .. |
|
323 | 323 | |
|
324 | 324 | clone of serve with repo in root and unserved subrepo (issue2970) |
|
325 | 325 | |
|
326 | 326 | $ hg --cwd test init sub |
|
327 | 327 | $ echo empty > test/sub/empty |
|
328 | 328 | $ hg --cwd test/sub add empty |
|
329 | 329 | $ hg --cwd test/sub commit -qm 'add empty' |
|
330 | 330 | $ hg --cwd test/sub tag -r 0 something |
|
331 | 331 | $ echo sub = sub > test/.hgsub |
|
332 | 332 | $ hg --cwd test add .hgsub |
|
333 | 333 | $ hg --cwd test commit -qm 'add subrepo' |
|
334 | 334 | $ hg clone http://localhost:$HGPORT noslash-clone |
|
335 | 335 | requesting all changes |
|
336 | 336 | adding changesets |
|
337 | 337 | adding manifests |
|
338 | 338 | adding file changes |
|
339 | 339 | added 3 changesets with 7 changes to 7 files |
|
340 | 340 | updating to branch default |
|
341 | 341 | abort: HTTP Error 404: Not Found |
|
342 | 342 | [255] |
|
343 | 343 | $ hg clone http://localhost:$HGPORT/ slash-clone |
|
344 | 344 | requesting all changes |
|
345 | 345 | adding changesets |
|
346 | 346 | adding manifests |
|
347 | 347 | adding file changes |
|
348 | 348 | added 3 changesets with 7 changes to 7 files |
|
349 | 349 | updating to branch default |
|
350 | 350 | abort: HTTP Error 404: Not Found |
|
351 | 351 | [255] |
|
352 | 352 | |
|
353 | 353 | check error log |
|
354 | 354 | |
|
355 | 355 | $ cat error.log |
|
356 | 356 | |
|
357 | 357 | Check error reporting while pulling/cloning |
|
358 | 358 | |
|
359 | 359 | $ $RUNTESTDIR/killdaemons.py |
|
360 | 360 | $ hg -R test serve -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py |
|
361 | 361 | $ cat hg3.pid >> $DAEMON_PIDS |
|
362 | 362 | $ hg clone http://localhost:$HGPORT/ abort-clone |
|
363 | 363 | requesting all changes |
|
364 | 364 | abort: remote error: |
|
365 | 365 | this is an exercise |
|
366 | 366 | [255] |
|
367 | 367 | $ cat error.log |
|
368 | 368 | |
|
369 | 369 | disable pull-based clones |
|
370 | 370 | |
|
371 | 371 | $ hg -R test serve -p $HGPORT1 -d --pid-file=hg4.pid -E error.log --config server.disablefullbundle=True |
|
372 | 372 | $ cat hg4.pid >> $DAEMON_PIDS |
|
373 | 373 | $ hg clone http://localhost:$HGPORT1/ disable-pull-clone |
|
374 | 374 | requesting all changes |
|
375 | 375 | abort: remote error: |
|
376 | 376 | server has pull-based clones disabled |
|
377 | 377 | [255] |
|
378 | 378 | |
|
379 | 379 | ... but keep stream clones working |
|
380 | 380 | |
|
381 |
$ hg clone -- |
|
|
381 | $ hg clone --stream --noupdate http://localhost:$HGPORT1/ test-stream-clone | |
|
382 | 382 | streaming all changes |
|
383 | 383 | * files to transfer, * of data (glob) |
|
384 | 384 | transferred * in * seconds (* KB/sec) (glob) |
|
385 | 385 | searching for changes |
|
386 | 386 | no changes found |
|
387 | 387 | |
|
388 | 388 | ... and also keep partial clones and pulls working |
|
389 | 389 | $ hg clone http://localhost:$HGPORT1 --rev 0 test-partial-clone |
|
390 | 390 | adding changesets |
|
391 | 391 | adding manifests |
|
392 | 392 | adding file changes |
|
393 | 393 | added 1 changesets with 4 changes to 4 files |
|
394 | 394 | updating to branch default |
|
395 | 395 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
396 | 396 | $ hg pull -R test-partial-clone |
|
397 | 397 | pulling from http://localhost:$HGPORT1/ |
|
398 | 398 | searching for changes |
|
399 | 399 | adding changesets |
|
400 | 400 | adding manifests |
|
401 | 401 | adding file changes |
|
402 | 402 | added 2 changesets with 3 changes to 3 files |
|
403 | 403 | (run 'hg update' to get a working copy) |
|
404 | 404 | |
|
405 | 405 | $ cat error.log |
@@ -1,120 +1,120 b'' | |||
|
1 | 1 | #require serve |
|
2 | 2 | |
|
3 | 3 | $ hg init a |
|
4 | 4 | $ cd a |
|
5 | 5 | $ echo a > a |
|
6 | 6 | $ hg ci -Ama -d '1123456789 0' |
|
7 | 7 | adding a |
|
8 | 8 | $ hg serve --config server.uncompressed=True -p $HGPORT -d --pid-file=hg.pid |
|
9 | 9 | $ cat hg.pid >> $DAEMON_PIDS |
|
10 | 10 | $ cd .. |
|
11 | 11 | $ tinyproxy.py $HGPORT1 localhost 2>proxy.log >/dev/null </dev/null & |
|
12 | 12 | $ while [ ! -f proxy.pid ]; do sleep 0; done |
|
13 | 13 | $ cat proxy.pid >> $DAEMON_PIDS |
|
14 | 14 | |
|
15 | 15 | url for proxy, stream |
|
16 | 16 | |
|
17 |
$ http_proxy=http://localhost:$HGPORT1/ hg --config http_proxy.always=True clone -- |
|
|
17 | $ http_proxy=http://localhost:$HGPORT1/ hg --config http_proxy.always=True clone --stream http://localhost:$HGPORT/ b | |
|
18 | 18 | streaming all changes |
|
19 | 19 | 3 files to transfer, 303 bytes of data |
|
20 | 20 | transferred * bytes in * seconds (*/sec) (glob) |
|
21 | 21 | searching for changes |
|
22 | 22 | no changes found |
|
23 | 23 | updating to branch default |
|
24 | 24 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
25 | 25 | $ cd b |
|
26 | 26 | $ hg verify |
|
27 | 27 | checking changesets |
|
28 | 28 | checking manifests |
|
29 | 29 | crosschecking files in changesets and manifests |
|
30 | 30 | checking files |
|
31 | 31 | 1 files, 1 changesets, 1 total revisions |
|
32 | 32 | $ cd .. |
|
33 | 33 | |
|
34 | 34 | url for proxy, pull |
|
35 | 35 | |
|
36 | 36 | $ http_proxy=http://localhost:$HGPORT1/ hg --config http_proxy.always=True clone http://localhost:$HGPORT/ b-pull |
|
37 | 37 | requesting all changes |
|
38 | 38 | adding changesets |
|
39 | 39 | adding manifests |
|
40 | 40 | adding file changes |
|
41 | 41 | added 1 changesets with 1 changes to 1 files |
|
42 | 42 | updating to branch default |
|
43 | 43 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
44 | 44 | $ cd b-pull |
|
45 | 45 | $ hg verify |
|
46 | 46 | checking changesets |
|
47 | 47 | checking manifests |
|
48 | 48 | crosschecking files in changesets and manifests |
|
49 | 49 | checking files |
|
50 | 50 | 1 files, 1 changesets, 1 total revisions |
|
51 | 51 | $ cd .. |
|
52 | 52 | |
|
53 | 53 | host:port for proxy |
|
54 | 54 | |
|
55 | 55 | $ http_proxy=localhost:$HGPORT1 hg clone --config http_proxy.always=True http://localhost:$HGPORT/ c |
|
56 | 56 | requesting all changes |
|
57 | 57 | adding changesets |
|
58 | 58 | adding manifests |
|
59 | 59 | adding file changes |
|
60 | 60 | added 1 changesets with 1 changes to 1 files |
|
61 | 61 | updating to branch default |
|
62 | 62 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
63 | 63 | |
|
64 | 64 | proxy url with user name and password |
|
65 | 65 | |
|
66 | 66 | $ http_proxy=http://user:passwd@localhost:$HGPORT1 hg clone --config http_proxy.always=True http://localhost:$HGPORT/ d |
|
67 | 67 | requesting all changes |
|
68 | 68 | adding changesets |
|
69 | 69 | adding manifests |
|
70 | 70 | adding file changes |
|
71 | 71 | added 1 changesets with 1 changes to 1 files |
|
72 | 72 | updating to branch default |
|
73 | 73 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
74 | 74 | |
|
75 | 75 | url with user name and password |
|
76 | 76 | |
|
77 | 77 | $ http_proxy=http://user:passwd@localhost:$HGPORT1 hg clone --config http_proxy.always=True http://user:passwd@localhost:$HGPORT/ e |
|
78 | 78 | requesting all changes |
|
79 | 79 | adding changesets |
|
80 | 80 | adding manifests |
|
81 | 81 | adding file changes |
|
82 | 82 | added 1 changesets with 1 changes to 1 files |
|
83 | 83 | updating to branch default |
|
84 | 84 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
85 | 85 | |
|
86 | 86 | bad host:port for proxy ("Protocol not supported" can happen on |
|
87 | 87 | misconfigured hosts) |
|
88 | 88 | |
|
89 | 89 | $ http_proxy=localhost:$HGPORT2 hg clone --config http_proxy.always=True http://localhost:$HGPORT/ f |
|
90 | 90 | abort: error: (Connection refused|Protocol not supported|.* actively refused it|Cannot assign requested address) (re) |
|
91 | 91 | [255] |
|
92 | 92 | |
|
93 | 93 | do not use the proxy if it is in the no list |
|
94 | 94 | |
|
95 | 95 | $ http_proxy=localhost:$HGPORT1 hg clone --config http_proxy.no=localhost http://localhost:$HGPORT/ g |
|
96 | 96 | requesting all changes |
|
97 | 97 | adding changesets |
|
98 | 98 | adding manifests |
|
99 | 99 | adding file changes |
|
100 | 100 | added 1 changesets with 1 changes to 1 files |
|
101 | 101 | updating to branch default |
|
102 | 102 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
103 | 103 | $ cat proxy.log |
|
104 | 104 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
105 | 105 | * - - [*] "GET http://localhost:$HGPORT/?cmd=branchmap HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
106 | 106 | * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
107 | 107 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D83180e7845de420a1bb46896fd5fe05294f8d629 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
108 | 108 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=83180e7845de420a1bb46896fd5fe05294f8d629&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
109 | 109 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
110 | 110 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
111 | 111 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
112 | 112 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
113 | 113 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
114 | 114 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
115 | 115 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
116 | 116 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
117 | 117 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
118 | 118 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
119 | 119 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
120 | 120 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
@@ -1,454 +1,454 b'' | |||
|
1 | 1 | #require killdaemons serve |
|
2 | 2 | |
|
3 | 3 | $ hg init test |
|
4 | 4 | $ cd test |
|
5 | 5 | $ echo foo>foo |
|
6 | 6 | $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg |
|
7 | 7 | $ echo foo>foo.d/foo |
|
8 | 8 | $ echo bar>foo.d/bAr.hg.d/BaR |
|
9 | 9 | $ echo bar>foo.d/baR.d.hg/bAR |
|
10 | 10 | $ hg commit -A -m 1 |
|
11 | 11 | adding foo |
|
12 | 12 | adding foo.d/bAr.hg.d/BaR |
|
13 | 13 | adding foo.d/baR.d.hg/bAR |
|
14 | 14 | adding foo.d/foo |
|
15 | 15 | $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log |
|
16 | 16 | $ hg serve --config server.uncompressed=False -p $HGPORT1 -d --pid-file=../hg2.pid |
|
17 | 17 | |
|
18 | 18 | Test server address cannot be reused |
|
19 | 19 | |
|
20 | 20 | #if windows |
|
21 | 21 | $ hg serve -p $HGPORT1 2>&1 |
|
22 | 22 | abort: cannot start server at 'localhost:$HGPORT1': * (glob) |
|
23 | 23 | [255] |
|
24 | 24 | #else |
|
25 | 25 | $ hg serve -p $HGPORT1 2>&1 |
|
26 | 26 | abort: cannot start server at 'localhost:$HGPORT1': Address already in use |
|
27 | 27 | [255] |
|
28 | 28 | #endif |
|
29 | 29 | $ cd .. |
|
30 | 30 | $ cat hg1.pid hg2.pid >> $DAEMON_PIDS |
|
31 | 31 | |
|
32 | 32 | clone via stream |
|
33 | 33 | |
|
34 |
$ hg clone -- |
|
|
34 | $ hg clone --stream http://localhost:$HGPORT/ copy 2>&1 | |
|
35 | 35 | streaming all changes |
|
36 | 36 | 6 files to transfer, 606 bytes of data |
|
37 | 37 | transferred * bytes in * seconds (*/sec) (glob) |
|
38 | 38 | searching for changes |
|
39 | 39 | no changes found |
|
40 | 40 | updating to branch default |
|
41 | 41 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
42 | 42 | $ hg verify -R copy |
|
43 | 43 | checking changesets |
|
44 | 44 | checking manifests |
|
45 | 45 | crosschecking files in changesets and manifests |
|
46 | 46 | checking files |
|
47 | 47 | 4 files, 1 changesets, 4 total revisions |
|
48 | 48 | |
|
49 | 49 | try to clone via stream, should use pull instead |
|
50 | 50 | |
|
51 |
$ hg clone -- |
|
|
51 | $ hg clone --stream http://localhost:$HGPORT1/ copy2 | |
|
52 | 52 | warning: stream clone requested but server has them disabled |
|
53 | 53 | requesting all changes |
|
54 | 54 | adding changesets |
|
55 | 55 | adding manifests |
|
56 | 56 | adding file changes |
|
57 | 57 | added 1 changesets with 4 changes to 4 files |
|
58 | 58 | updating to branch default |
|
59 | 59 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
60 | 60 | |
|
61 | 61 | try to clone via stream but missing requirements, so should use pull instead |
|
62 | 62 | |
|
63 | 63 | $ cat > $TESTTMP/removesupportedformat.py << EOF |
|
64 | 64 | > from mercurial import localrepo |
|
65 | 65 | > def extsetup(ui): |
|
66 | 66 | > localrepo.localrepository.supportedformats.remove('generaldelta') |
|
67 | 67 | > EOF |
|
68 | 68 | |
|
69 |
$ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py -- |
|
|
69 | $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3 | |
|
70 | 70 | warning: stream clone requested but client is missing requirements: generaldelta |
|
71 | 71 | (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information) |
|
72 | 72 | requesting all changes |
|
73 | 73 | adding changesets |
|
74 | 74 | adding manifests |
|
75 | 75 | adding file changes |
|
76 | 76 | added 1 changesets with 4 changes to 4 files |
|
77 | 77 | updating to branch default |
|
78 | 78 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
79 | 79 | |
|
80 | 80 | clone via pull |
|
81 | 81 | |
|
82 | 82 | $ hg clone http://localhost:$HGPORT1/ copy-pull |
|
83 | 83 | requesting all changes |
|
84 | 84 | adding changesets |
|
85 | 85 | adding manifests |
|
86 | 86 | adding file changes |
|
87 | 87 | added 1 changesets with 4 changes to 4 files |
|
88 | 88 | updating to branch default |
|
89 | 89 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
90 | 90 | $ hg verify -R copy-pull |
|
91 | 91 | checking changesets |
|
92 | 92 | checking manifests |
|
93 | 93 | crosschecking files in changesets and manifests |
|
94 | 94 | checking files |
|
95 | 95 | 4 files, 1 changesets, 4 total revisions |
|
96 | 96 | $ cd test |
|
97 | 97 | $ echo bar > bar |
|
98 | 98 | $ hg commit -A -d '1 0' -m 2 |
|
99 | 99 | adding bar |
|
100 | 100 | $ cd .. |
|
101 | 101 | |
|
102 | 102 | clone over http with --update |
|
103 | 103 | |
|
104 | 104 | $ hg clone http://localhost:$HGPORT1/ updated --update 0 |
|
105 | 105 | requesting all changes |
|
106 | 106 | adding changesets |
|
107 | 107 | adding manifests |
|
108 | 108 | adding file changes |
|
109 | 109 | added 2 changesets with 5 changes to 5 files |
|
110 | 110 | updating to branch default |
|
111 | 111 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
112 | 112 | $ hg log -r . -R updated |
|
113 | 113 | changeset: 0:8b6053c928fe |
|
114 | 114 | user: test |
|
115 | 115 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
116 | 116 | summary: 1 |
|
117 | 117 | |
|
118 | 118 | $ rm -rf updated |
|
119 | 119 | |
|
120 | 120 | incoming via HTTP |
|
121 | 121 | |
|
122 | 122 | $ hg clone http://localhost:$HGPORT1/ --rev 0 partial |
|
123 | 123 | adding changesets |
|
124 | 124 | adding manifests |
|
125 | 125 | adding file changes |
|
126 | 126 | added 1 changesets with 4 changes to 4 files |
|
127 | 127 | updating to branch default |
|
128 | 128 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
129 | 129 | $ cd partial |
|
130 | 130 | $ touch LOCAL |
|
131 | 131 | $ hg ci -qAm LOCAL |
|
132 | 132 | $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n' |
|
133 | 133 | comparing with http://localhost:$HGPORT1/ |
|
134 | 134 | searching for changes |
|
135 | 135 | 2 |
|
136 | 136 | $ cd .. |
|
137 | 137 | |
|
138 | 138 | pull |
|
139 | 139 | |
|
140 | 140 | $ cd copy-pull |
|
141 | 141 | $ cat >> .hg/hgrc <<EOF |
|
142 | 142 | > [hooks] |
|
143 | 143 | > changegroup = sh -c "printenv.py changegroup" |
|
144 | 144 | > EOF |
|
145 | 145 | $ hg pull |
|
146 | 146 | pulling from http://localhost:$HGPORT1/ |
|
147 | 147 | searching for changes |
|
148 | 148 | adding changesets |
|
149 | 149 | adding manifests |
|
150 | 150 | adding file changes |
|
151 | 151 | added 1 changesets with 1 changes to 1 files |
|
152 | 152 | changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=http://localhost:$HGPORT1/ |
|
153 | 153 | (run 'hg update' to get a working copy) |
|
154 | 154 | $ cd .. |
|
155 | 155 | |
|
156 | 156 | clone from invalid URL |
|
157 | 157 | |
|
158 | 158 | $ hg clone http://localhost:$HGPORT/bad |
|
159 | 159 | abort: HTTP Error 404: Not Found |
|
160 | 160 | [255] |
|
161 | 161 | |
|
162 | 162 | test http authentication |
|
163 | 163 | + use the same server to test server side streaming preference |
|
164 | 164 | |
|
165 | 165 | $ cd test |
|
166 | 166 | $ cat << EOT > userpass.py |
|
167 | 167 | > import base64 |
|
168 | 168 | > from mercurial.hgweb import common |
|
169 | 169 | > def perform_authentication(hgweb, req, op): |
|
170 | 170 | > auth = req.env.get('HTTP_AUTHORIZATION') |
|
171 | 171 | > if not auth: |
|
172 | 172 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
|
173 | 173 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
|
174 | 174 | > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: |
|
175 | 175 | > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') |
|
176 | 176 | > def extsetup(): |
|
177 | 177 | > common.permhooks.insert(0, perform_authentication) |
|
178 | 178 | > EOT |
|
179 | 179 | $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \ |
|
180 | 180 | > --config server.preferuncompressed=True \ |
|
181 | 181 | > --config web.push_ssl=False --config web.allow_push=* -A ../access.log |
|
182 | 182 | $ cat pid >> $DAEMON_PIDS |
|
183 | 183 | |
|
184 | 184 | $ cat << EOF > get_pass.py |
|
185 | 185 | > import getpass |
|
186 | 186 | > def newgetpass(arg): |
|
187 | 187 | > return "pass" |
|
188 | 188 | > getpass.getpass = newgetpass |
|
189 | 189 | > EOF |
|
190 | 190 | |
|
191 | 191 | $ hg id http://localhost:$HGPORT2/ |
|
192 | 192 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
193 | 193 | [255] |
|
194 | 194 | $ hg id http://localhost:$HGPORT2/ |
|
195 | 195 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
196 | 196 | [255] |
|
197 | 197 | $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/ |
|
198 | 198 | http authorization required for http://localhost:$HGPORT2/ |
|
199 | 199 | realm: mercurial |
|
200 | 200 | user: user |
|
201 | 201 | password: 5fed3813f7f5 |
|
202 | 202 | $ hg id http://user:pass@localhost:$HGPORT2/ |
|
203 | 203 | 5fed3813f7f5 |
|
204 | 204 | $ echo '[auth]' >> .hg/hgrc |
|
205 | 205 | $ echo 'l.schemes=http' >> .hg/hgrc |
|
206 | 206 | $ echo 'l.prefix=lo' >> .hg/hgrc |
|
207 | 207 | $ echo 'l.username=user' >> .hg/hgrc |
|
208 | 208 | $ echo 'l.password=pass' >> .hg/hgrc |
|
209 | 209 | $ hg id http://localhost:$HGPORT2/ |
|
210 | 210 | 5fed3813f7f5 |
|
211 | 211 | $ hg id http://localhost:$HGPORT2/ |
|
212 | 212 | 5fed3813f7f5 |
|
213 | 213 | $ hg id http://user@localhost:$HGPORT2/ |
|
214 | 214 | 5fed3813f7f5 |
|
215 | 215 | $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1 |
|
216 | 216 | streaming all changes |
|
217 | 217 | 7 files to transfer, 916 bytes of data |
|
218 | 218 | transferred * bytes in * seconds (*/sec) (glob) |
|
219 | 219 | searching for changes |
|
220 | 220 | no changes found |
|
221 | 221 | updating to branch default |
|
222 | 222 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
223 | 223 | --pull should override server's preferuncompressed |
|
224 | 224 | $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1 |
|
225 | 225 | requesting all changes |
|
226 | 226 | adding changesets |
|
227 | 227 | adding manifests |
|
228 | 228 | adding file changes |
|
229 | 229 | added 2 changesets with 5 changes to 5 files |
|
230 | 230 | updating to branch default |
|
231 | 231 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
232 | 232 | |
|
233 | 233 | $ hg id http://user2@localhost:$HGPORT2/ |
|
234 | 234 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
235 | 235 | [255] |
|
236 | 236 | $ hg id http://user:pass2@localhost:$HGPORT2/ |
|
237 | 237 | abort: HTTP Error 403: no |
|
238 | 238 | [255] |
|
239 | 239 | |
|
240 | 240 | $ hg -R dest tag -r tip top |
|
241 | 241 | $ hg -R dest push http://user:pass@localhost:$HGPORT2/ |
|
242 | 242 | pushing to http://user:***@localhost:$HGPORT2/ |
|
243 | 243 | searching for changes |
|
244 | 244 | remote: adding changesets |
|
245 | 245 | remote: adding manifests |
|
246 | 246 | remote: adding file changes |
|
247 | 247 | remote: added 1 changesets with 1 changes to 1 files |
|
248 | 248 | $ hg rollback -q |
|
249 | 249 | |
|
250 | 250 | $ sed 's/.*] "/"/' < ../access.log |
|
251 | 251 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
252 | 252 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
253 | 253 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
254 | 254 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
255 | 255 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
256 | 256 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
257 | 257 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
258 | 258 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
259 | 259 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
260 | 260 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
261 | 261 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
262 | 262 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
263 | 263 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
264 | 264 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
265 | 265 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
266 | 266 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
267 | 267 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
268 | 268 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
269 | 269 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
270 | 270 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
271 | 271 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
272 | 272 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
273 | 273 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
274 | 274 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
275 | 275 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
276 | 276 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
277 | 277 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
278 | 278 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
279 | 279 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
280 | 280 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
281 | 281 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
282 | 282 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
283 | 283 | "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
284 | 284 | "GET /?cmd=stream_out HTTP/1.1" 401 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
285 | 285 | "GET /?cmd=stream_out HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
286 | 286 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
287 | 287 | "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=0&common=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
288 | 288 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
289 | 289 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
290 | 290 | "GET /?cmd=getbundle HTTP/1.1" 401 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
291 | 291 | "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
292 | 292 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
293 | 293 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
294 | 294 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
295 | 295 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
296 | 296 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
297 | 297 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
298 | 298 | "GET /?cmd=listkeys HTTP/1.1" 403 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
299 | 299 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
300 | 300 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D7f4e523d01f2cc3765ac8934da3d14db775ff872 x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
301 | 301 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
302 | 302 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
303 | 303 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
304 | 304 | "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
305 | 305 | "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
306 | 306 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
307 | 307 | "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=666f726365* (glob) |
|
308 | 308 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob) |
|
309 | 309 | |
|
310 | 310 | $ cd .. |
|
311 | 311 | |
|
312 | 312 | clone of serve with repo in root and unserved subrepo (issue2970) |
|
313 | 313 | |
|
314 | 314 | $ hg --cwd test init sub |
|
315 | 315 | $ echo empty > test/sub/empty |
|
316 | 316 | $ hg --cwd test/sub add empty |
|
317 | 317 | $ hg --cwd test/sub commit -qm 'add empty' |
|
318 | 318 | $ hg --cwd test/sub tag -r 0 something |
|
319 | 319 | $ echo sub = sub > test/.hgsub |
|
320 | 320 | $ hg --cwd test add .hgsub |
|
321 | 321 | $ hg --cwd test commit -qm 'add subrepo' |
|
322 | 322 | $ hg clone http://localhost:$HGPORT noslash-clone |
|
323 | 323 | requesting all changes |
|
324 | 324 | adding changesets |
|
325 | 325 | adding manifests |
|
326 | 326 | adding file changes |
|
327 | 327 | added 3 changesets with 7 changes to 7 files |
|
328 | 328 | updating to branch default |
|
329 | 329 | abort: HTTP Error 404: Not Found |
|
330 | 330 | [255] |
|
331 | 331 | $ hg clone http://localhost:$HGPORT/ slash-clone |
|
332 | 332 | requesting all changes |
|
333 | 333 | adding changesets |
|
334 | 334 | adding manifests |
|
335 | 335 | adding file changes |
|
336 | 336 | added 3 changesets with 7 changes to 7 files |
|
337 | 337 | updating to branch default |
|
338 | 338 | abort: HTTP Error 404: Not Found |
|
339 | 339 | [255] |
|
340 | 340 | |
|
341 | 341 | check error log |
|
342 | 342 | |
|
343 | 343 | $ cat error.log |
|
344 | 344 | |
|
345 | 345 | check abort error reporting while pulling/cloning |
|
346 | 346 | |
|
347 | 347 | $ $RUNTESTDIR/killdaemons.py |
|
348 | 348 | $ hg -R test serve -p $HGPORT -d --pid-file=hg3.pid -E error.log --config extensions.crash=${TESTDIR}/crashgetbundler.py |
|
349 | 349 | $ cat hg3.pid >> $DAEMON_PIDS |
|
350 | 350 | $ hg clone http://localhost:$HGPORT/ abort-clone |
|
351 | 351 | requesting all changes |
|
352 | 352 | remote: abort: this is an exercise |
|
353 | 353 | abort: pull failed on remote |
|
354 | 354 | [255] |
|
355 | 355 | $ cat error.log |
|
356 | 356 | |
|
357 | 357 | disable pull-based clones |
|
358 | 358 | |
|
359 | 359 | $ hg -R test serve -p $HGPORT1 -d --pid-file=hg4.pid -E error.log --config server.disablefullbundle=True |
|
360 | 360 | $ cat hg4.pid >> $DAEMON_PIDS |
|
361 | 361 | $ hg clone http://localhost:$HGPORT1/ disable-pull-clone |
|
362 | 362 | requesting all changes |
|
363 | 363 | remote: abort: server has pull-based clones disabled |
|
364 | 364 | abort: pull failed on remote |
|
365 | 365 | (remove --pull if specified or upgrade Mercurial) |
|
366 | 366 | [255] |
|
367 | 367 | |
|
368 | 368 | ... but keep stream clones working |
|
369 | 369 | |
|
370 |
$ hg clone -- |
|
|
370 | $ hg clone --stream --noupdate http://localhost:$HGPORT1/ test-stream-clone | |
|
371 | 371 | streaming all changes |
|
372 | 372 | * files to transfer, * of data (glob) |
|
373 | 373 | transferred * in * seconds (*/sec) (glob) |
|
374 | 374 | searching for changes |
|
375 | 375 | no changes found |
|
376 | 376 | $ cat error.log |
|
377 | 377 | |
|
378 | 378 | ... and also keep partial clones and pulls working |
|
379 | 379 | $ hg clone http://localhost:$HGPORT1 --rev 0 test-partial-clone |
|
380 | 380 | adding changesets |
|
381 | 381 | adding manifests |
|
382 | 382 | adding file changes |
|
383 | 383 | added 1 changesets with 4 changes to 4 files |
|
384 | 384 | updating to branch default |
|
385 | 385 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
386 | 386 | $ hg pull -R test-partial-clone |
|
387 | 387 | pulling from http://localhost:$HGPORT1/ |
|
388 | 388 | searching for changes |
|
389 | 389 | adding changesets |
|
390 | 390 | adding manifests |
|
391 | 391 | adding file changes |
|
392 | 392 | added 2 changesets with 3 changes to 3 files |
|
393 | 393 | (run 'hg update' to get a working copy) |
|
394 | 394 | |
|
395 | 395 | corrupt cookies file should yield a warning |
|
396 | 396 | |
|
397 | 397 | $ cat > $TESTTMP/cookies.txt << EOF |
|
398 | 398 | > bad format |
|
399 | 399 | > EOF |
|
400 | 400 | |
|
401 | 401 | $ hg --config auth.cookiefile=$TESTTMP/cookies.txt id http://localhost:$HGPORT/ |
|
402 | 402 | (error loading cookie file $TESTTMP/cookies.txt: '*/cookies.txt' does not look like a Netscape format cookies file; continuing without cookies) (glob) |
|
403 | 403 | 56f9bc90cce6 |
|
404 | 404 | |
|
405 | 405 | $ killdaemons.py |
|
406 | 406 | |
|
407 | 407 | Create dummy authentication handler that looks for cookies. It doesn't do anything |
|
408 | 408 | useful. It just raises an HTTP 500 with details about the Cookie request header. |
|
409 | 409 | We raise HTTP 500 because its message is printed in the abort message. |
|
410 | 410 | |
|
411 | 411 | $ cat > cookieauth.py << EOF |
|
412 | 412 | > from mercurial import util |
|
413 | 413 | > from mercurial.hgweb import common |
|
414 | 414 | > def perform_authentication(hgweb, req, op): |
|
415 | 415 | > cookie = req.env.get('HTTP_COOKIE') |
|
416 | 416 | > if not cookie: |
|
417 | 417 | > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'no-cookie') |
|
418 | 418 | > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'Cookie: %s' % cookie) |
|
419 | 419 | > def extsetup(): |
|
420 | 420 | > common.permhooks.insert(0, perform_authentication) |
|
421 | 421 | > EOF |
|
422 | 422 | |
|
423 | 423 | $ hg serve --config extensions.cookieauth=cookieauth.py -R test -p $HGPORT -d --pid-file=pid |
|
424 | 424 | $ cat pid > $DAEMON_PIDS |
|
425 | 425 | |
|
426 | 426 | Request without cookie sent should fail due to lack of cookie |
|
427 | 427 | |
|
428 | 428 | $ hg id http://localhost:$HGPORT |
|
429 | 429 | abort: HTTP Error 500: no-cookie |
|
430 | 430 | [255] |
|
431 | 431 | |
|
432 | 432 | Populate a cookies file |
|
433 | 433 | |
|
434 | 434 | $ cat > cookies.txt << EOF |
|
435 | 435 | > # HTTP Cookie File |
|
436 | 436 | > # Expiration is 2030-01-01 at midnight |
|
437 | 437 | > .example.com TRUE / FALSE 1893456000 hgkey examplevalue |
|
438 | 438 | > EOF |
|
439 | 439 | |
|
440 | 440 | Should not send a cookie for another domain |
|
441 | 441 | |
|
442 | 442 | $ hg --config auth.cookiefile=cookies.txt id http://localhost:$HGPORT/ |
|
443 | 443 | abort: HTTP Error 500: no-cookie |
|
444 | 444 | [255] |
|
445 | 445 | |
|
446 | 446 | Add a cookie entry for our test server and verify it is sent |
|
447 | 447 | |
|
448 | 448 | $ cat >> cookies.txt << EOF |
|
449 | 449 | > localhost.local FALSE / FALSE 1893456000 hgkey localhostvalue |
|
450 | 450 | > EOF |
|
451 | 451 | |
|
452 | 452 | $ hg --config auth.cookiefile=cookies.txt id http://localhost:$HGPORT/ |
|
453 | 453 | abort: HTTP Error 500: Cookie: hgkey=localhostvalue |
|
454 | 454 | [255] |
@@ -1,562 +1,562 b'' | |||
|
1 | 1 | This test is a duplicate of 'test-http.t' feel free to factor out |
|
2 | 2 | parts that are not bundle1/bundle2 specific. |
|
3 | 3 | |
|
4 | 4 | $ cat << EOF >> $HGRCPATH |
|
5 | 5 | > [devel] |
|
6 | 6 | > # This test is dedicated to interaction through old bundle |
|
7 | 7 | > legacy.exchange = bundle1 |
|
8 | 8 | > [format] # temporary settings |
|
9 | 9 | > usegeneraldelta=yes |
|
10 | 10 | > EOF |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | This test tries to exercise the ssh functionality with a dummy script |
|
14 | 14 | |
|
15 | 15 | creating 'remote' repo |
|
16 | 16 | |
|
17 | 17 | $ hg init remote |
|
18 | 18 | $ cd remote |
|
19 | 19 | $ echo this > foo |
|
20 | 20 | $ echo this > fooO |
|
21 | 21 | $ hg ci -A -m "init" foo fooO |
|
22 | 22 | |
|
23 | 23 | insert a closed branch (issue4428) |
|
24 | 24 | |
|
25 | 25 | $ hg up null |
|
26 | 26 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
27 | 27 | $ hg branch closed |
|
28 | 28 | marked working directory as branch closed |
|
29 | 29 | (branches are permanent and global, did you want a bookmark?) |
|
30 | 30 | $ hg ci -mc0 |
|
31 | 31 | $ hg ci --close-branch -mc1 |
|
32 | 32 | $ hg up -q default |
|
33 | 33 | |
|
34 | 34 | configure for serving |
|
35 | 35 | |
|
36 | 36 | $ cat <<EOF > .hg/hgrc |
|
37 | 37 | > [server] |
|
38 | 38 | > uncompressed = True |
|
39 | 39 | > |
|
40 | 40 | > [hooks] |
|
41 | 41 | > changegroup = sh -c "printenv.py changegroup-in-remote 0 ../dummylog" |
|
42 | 42 | > EOF |
|
43 | 43 | $ cd .. |
|
44 | 44 | |
|
45 | 45 | repo not found error |
|
46 | 46 | |
|
47 | 47 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local |
|
48 | 48 | remote: abort: repository nonexistent not found! |
|
49 | 49 | abort: no suitable response from remote hg! |
|
50 | 50 | [255] |
|
51 | 51 | |
|
52 | 52 | non-existent absolute path |
|
53 | 53 | |
|
54 | 54 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy//`pwd`/nonexistent local |
|
55 | 55 | remote: abort: repository /$TESTTMP/nonexistent not found! |
|
56 | 56 | abort: no suitable response from remote hg! |
|
57 | 57 | [255] |
|
58 | 58 | |
|
59 | 59 | clone remote via stream |
|
60 | 60 | |
|
61 |
$ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -- |
|
|
61 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --stream ssh://user@dummy/remote local-stream | |
|
62 | 62 | streaming all changes |
|
63 | 63 | 4 files to transfer, 602 bytes of data |
|
64 | 64 | transferred 602 bytes in * seconds (*) (glob) |
|
65 | 65 | searching for changes |
|
66 | 66 | no changes found |
|
67 | 67 | updating to branch default |
|
68 | 68 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
69 | 69 | $ cd local-stream |
|
70 | 70 | $ hg verify |
|
71 | 71 | checking changesets |
|
72 | 72 | checking manifests |
|
73 | 73 | crosschecking files in changesets and manifests |
|
74 | 74 | checking files |
|
75 | 75 | 2 files, 3 changesets, 2 total revisions |
|
76 | 76 | $ hg branches |
|
77 | 77 | default 0:1160648e36ce |
|
78 | 78 | $ cd .. |
|
79 | 79 | |
|
80 | 80 | clone bookmarks via stream |
|
81 | 81 | |
|
82 | 82 | $ hg -R local-stream book mybook |
|
83 |
$ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -- |
|
|
83 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --stream ssh://user@dummy/local-stream stream2 | |
|
84 | 84 | streaming all changes |
|
85 | 85 | 4 files to transfer, 602 bytes of data |
|
86 | 86 | transferred 602 bytes in * seconds (*) (glob) |
|
87 | 87 | searching for changes |
|
88 | 88 | no changes found |
|
89 | 89 | updating to branch default |
|
90 | 90 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
91 | 91 | $ cd stream2 |
|
92 | 92 | $ hg book |
|
93 | 93 | mybook 0:1160648e36ce |
|
94 | 94 | $ cd .. |
|
95 | 95 | $ rm -rf local-stream stream2 |
|
96 | 96 | |
|
97 | 97 | clone remote via pull |
|
98 | 98 | |
|
99 | 99 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local |
|
100 | 100 | requesting all changes |
|
101 | 101 | adding changesets |
|
102 | 102 | adding manifests |
|
103 | 103 | adding file changes |
|
104 | 104 | added 3 changesets with 2 changes to 2 files |
|
105 | 105 | updating to branch default |
|
106 | 106 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
107 | 107 | |
|
108 | 108 | verify |
|
109 | 109 | |
|
110 | 110 | $ cd local |
|
111 | 111 | $ hg verify |
|
112 | 112 | checking changesets |
|
113 | 113 | checking manifests |
|
114 | 114 | crosschecking files in changesets and manifests |
|
115 | 115 | checking files |
|
116 | 116 | 2 files, 3 changesets, 2 total revisions |
|
117 | 117 | $ cat >> .hg/hgrc <<EOF |
|
118 | 118 | > [hooks] |
|
119 | 119 | > changegroup = sh -c "printenv.py changegroup-in-local 0 ../dummylog" |
|
120 | 120 | > EOF |
|
121 | 121 | |
|
122 | 122 | empty default pull |
|
123 | 123 | |
|
124 | 124 | $ hg paths |
|
125 | 125 | default = ssh://user@dummy/remote |
|
126 | 126 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" |
|
127 | 127 | pulling from ssh://user@dummy/remote |
|
128 | 128 | searching for changes |
|
129 | 129 | no changes found |
|
130 | 130 | |
|
131 | 131 | pull from wrong ssh URL |
|
132 | 132 | |
|
133 | 133 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/doesnotexist |
|
134 | 134 | pulling from ssh://user@dummy/doesnotexist |
|
135 | 135 | remote: abort: repository doesnotexist not found! |
|
136 | 136 | abort: no suitable response from remote hg! |
|
137 | 137 | [255] |
|
138 | 138 | |
|
139 | 139 | local change |
|
140 | 140 | |
|
141 | 141 | $ echo bleah > foo |
|
142 | 142 | $ hg ci -m "add" |
|
143 | 143 | |
|
144 | 144 | updating rc |
|
145 | 145 | |
|
146 | 146 | $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc |
|
147 | 147 | $ echo "[ui]" >> .hg/hgrc |
|
148 | 148 | $ echo "ssh = \"$PYTHON\" \"$TESTDIR/dummyssh\"" >> .hg/hgrc |
|
149 | 149 | |
|
150 | 150 | find outgoing |
|
151 | 151 | |
|
152 | 152 | $ hg out ssh://user@dummy/remote |
|
153 | 153 | comparing with ssh://user@dummy/remote |
|
154 | 154 | searching for changes |
|
155 | 155 | changeset: 3:a28a9d1a809c |
|
156 | 156 | tag: tip |
|
157 | 157 | parent: 0:1160648e36ce |
|
158 | 158 | user: test |
|
159 | 159 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
160 | 160 | summary: add |
|
161 | 161 | |
|
162 | 162 | |
|
163 | 163 | find incoming on the remote side |
|
164 | 164 | |
|
165 | 165 | $ hg incoming -R ../remote -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/local |
|
166 | 166 | comparing with ssh://user@dummy/local |
|
167 | 167 | searching for changes |
|
168 | 168 | changeset: 3:a28a9d1a809c |
|
169 | 169 | tag: tip |
|
170 | 170 | parent: 0:1160648e36ce |
|
171 | 171 | user: test |
|
172 | 172 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
173 | 173 | summary: add |
|
174 | 174 | |
|
175 | 175 | |
|
176 | 176 | find incoming on the remote side (using absolute path) |
|
177 | 177 | |
|
178 | 178 | $ hg incoming -R ../remote -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/`pwd`" |
|
179 | 179 | comparing with ssh://user@dummy/$TESTTMP/local |
|
180 | 180 | searching for changes |
|
181 | 181 | changeset: 3:a28a9d1a809c |
|
182 | 182 | tag: tip |
|
183 | 183 | parent: 0:1160648e36ce |
|
184 | 184 | user: test |
|
185 | 185 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
186 | 186 | summary: add |
|
187 | 187 | |
|
188 | 188 | |
|
189 | 189 | push |
|
190 | 190 | |
|
191 | 191 | $ hg push |
|
192 | 192 | pushing to ssh://user@dummy/remote |
|
193 | 193 | searching for changes |
|
194 | 194 | remote: adding changesets |
|
195 | 195 | remote: adding manifests |
|
196 | 196 | remote: adding file changes |
|
197 | 197 | remote: added 1 changesets with 1 changes to 1 files |
|
198 | 198 | $ cd ../remote |
|
199 | 199 | |
|
200 | 200 | check remote tip |
|
201 | 201 | |
|
202 | 202 | $ hg tip |
|
203 | 203 | changeset: 3:a28a9d1a809c |
|
204 | 204 | tag: tip |
|
205 | 205 | parent: 0:1160648e36ce |
|
206 | 206 | user: test |
|
207 | 207 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
208 | 208 | summary: add |
|
209 | 209 | |
|
210 | 210 | $ hg verify |
|
211 | 211 | checking changesets |
|
212 | 212 | checking manifests |
|
213 | 213 | crosschecking files in changesets and manifests |
|
214 | 214 | checking files |
|
215 | 215 | 2 files, 4 changesets, 3 total revisions |
|
216 | 216 | $ hg cat -r tip foo |
|
217 | 217 | bleah |
|
218 | 218 | $ echo z > z |
|
219 | 219 | $ hg ci -A -m z z |
|
220 | 220 | created new head |
|
221 | 221 | |
|
222 | 222 | test pushkeys and bookmarks |
|
223 | 223 | |
|
224 | 224 | $ cd ../local |
|
225 | 225 | $ hg debugpushkey --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote namespaces |
|
226 | 226 | bookmarks |
|
227 | 227 | namespaces |
|
228 | 228 | phases |
|
229 | 229 | $ hg book foo -r 0 |
|
230 | 230 | $ hg out -B |
|
231 | 231 | comparing with ssh://user@dummy/remote |
|
232 | 232 | searching for changed bookmarks |
|
233 | 233 | foo 1160648e36ce |
|
234 | 234 | $ hg push -B foo |
|
235 | 235 | pushing to ssh://user@dummy/remote |
|
236 | 236 | searching for changes |
|
237 | 237 | no changes found |
|
238 | 238 | exporting bookmark foo |
|
239 | 239 | [1] |
|
240 | 240 | $ hg debugpushkey --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote bookmarks |
|
241 | 241 | foo 1160648e36cec0054048a7edc4110c6f84fde594 |
|
242 | 242 | $ hg book -f foo |
|
243 | 243 | $ hg push --traceback |
|
244 | 244 | pushing to ssh://user@dummy/remote |
|
245 | 245 | searching for changes |
|
246 | 246 | no changes found |
|
247 | 247 | updating bookmark foo |
|
248 | 248 | [1] |
|
249 | 249 | $ hg book -d foo |
|
250 | 250 | $ hg in -B |
|
251 | 251 | comparing with ssh://user@dummy/remote |
|
252 | 252 | searching for changed bookmarks |
|
253 | 253 | foo a28a9d1a809c |
|
254 | 254 | $ hg book -f -r 0 foo |
|
255 | 255 | $ hg pull -B foo |
|
256 | 256 | pulling from ssh://user@dummy/remote |
|
257 | 257 | no changes found |
|
258 | 258 | updating bookmark foo |
|
259 | 259 | $ hg book -d foo |
|
260 | 260 | $ hg push -B foo |
|
261 | 261 | pushing to ssh://user@dummy/remote |
|
262 | 262 | searching for changes |
|
263 | 263 | no changes found |
|
264 | 264 | deleting remote bookmark foo |
|
265 | 265 | [1] |
|
266 | 266 | |
|
267 | 267 | a bad, evil hook that prints to stdout |
|
268 | 268 | |
|
269 | 269 | $ cat <<EOF > $TESTTMP/badhook |
|
270 | 270 | > import sys |
|
271 | 271 | > sys.stdout.write("KABOOM\n") |
|
272 | 272 | > EOF |
|
273 | 273 | |
|
274 | 274 | $ echo '[hooks]' >> ../remote/.hg/hgrc |
|
275 | 275 | $ echo "changegroup.stdout = \"$PYTHON\" $TESTTMP/badhook" >> ../remote/.hg/hgrc |
|
276 | 276 | $ echo r > r |
|
277 | 277 | $ hg ci -A -m z r |
|
278 | 278 | |
|
279 | 279 | push should succeed even though it has an unexpected response |
|
280 | 280 | |
|
281 | 281 | $ hg push |
|
282 | 282 | pushing to ssh://user@dummy/remote |
|
283 | 283 | searching for changes |
|
284 | 284 | remote has heads on branch 'default' that are not known locally: 6c0482d977a3 |
|
285 | 285 | remote: adding changesets |
|
286 | 286 | remote: adding manifests |
|
287 | 287 | remote: adding file changes |
|
288 | 288 | remote: added 1 changesets with 1 changes to 1 files |
|
289 | 289 | remote: KABOOM |
|
290 | 290 | $ hg -R ../remote heads |
|
291 | 291 | changeset: 5:1383141674ec |
|
292 | 292 | tag: tip |
|
293 | 293 | parent: 3:a28a9d1a809c |
|
294 | 294 | user: test |
|
295 | 295 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
296 | 296 | summary: z |
|
297 | 297 | |
|
298 | 298 | changeset: 4:6c0482d977a3 |
|
299 | 299 | parent: 0:1160648e36ce |
|
300 | 300 | user: test |
|
301 | 301 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
302 | 302 | summary: z |
|
303 | 303 | |
|
304 | 304 | |
|
305 | 305 | clone bookmarks |
|
306 | 306 | |
|
307 | 307 | $ hg -R ../remote bookmark test |
|
308 | 308 | $ hg -R ../remote bookmarks |
|
309 | 309 | * test 4:6c0482d977a3 |
|
310 | 310 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local-bookmarks |
|
311 | 311 | requesting all changes |
|
312 | 312 | adding changesets |
|
313 | 313 | adding manifests |
|
314 | 314 | adding file changes |
|
315 | 315 | added 6 changesets with 5 changes to 4 files (+1 heads) |
|
316 | 316 | updating to branch default |
|
317 | 317 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
318 | 318 | $ hg -R local-bookmarks bookmarks |
|
319 | 319 | test 4:6c0482d977a3 |
|
320 | 320 | |
|
321 | 321 | passwords in ssh urls are not supported |
|
322 | 322 | (we use a glob here because different Python versions give different |
|
323 | 323 | results here) |
|
324 | 324 | |
|
325 | 325 | $ hg push ssh://user:erroneouspwd@dummy/remote |
|
326 | 326 | pushing to ssh://user:*@dummy/remote (glob) |
|
327 | 327 | abort: password in URL not supported! |
|
328 | 328 | [255] |
|
329 | 329 | |
|
330 | 330 | $ cd .. |
|
331 | 331 | |
|
332 | 332 | hide outer repo |
|
333 | 333 | $ hg init |
|
334 | 334 | |
|
335 | 335 | Test remote paths with spaces (issue2983): |
|
336 | 336 | |
|
337 | 337 | $ hg init --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" |
|
338 | 338 | $ touch "$TESTTMP/a repo/test" |
|
339 | 339 | $ hg -R 'a repo' commit -A -m "test" |
|
340 | 340 | adding test |
|
341 | 341 | $ hg -R 'a repo' tag tag |
|
342 | 342 | $ hg id --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" |
|
343 | 343 | 73649e48688a |
|
344 | 344 | |
|
345 | 345 | $ hg id --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo#noNoNO" |
|
346 | 346 | abort: unknown revision 'noNoNO'! |
|
347 | 347 | [255] |
|
348 | 348 | |
|
349 | 349 | Test (non-)escaping of remote paths with spaces when cloning (issue3145): |
|
350 | 350 | |
|
351 | 351 | $ hg clone --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" |
|
352 | 352 | destination directory: a repo |
|
353 | 353 | abort: destination 'a repo' is not empty |
|
354 | 354 | [255] |
|
355 | 355 | |
|
356 | 356 | Test hg-ssh using a helper script that will restore PYTHONPATH (which might |
|
357 | 357 | have been cleared by a hg.exe wrapper) and invoke hg-ssh with the right |
|
358 | 358 | parameters: |
|
359 | 359 | |
|
360 | 360 | $ cat > ssh.sh << EOF |
|
361 | 361 | > userhost="\$1" |
|
362 | 362 | > SSH_ORIGINAL_COMMAND="\$2" |
|
363 | 363 | > export SSH_ORIGINAL_COMMAND |
|
364 | 364 | > PYTHONPATH="$PYTHONPATH" |
|
365 | 365 | > export PYTHONPATH |
|
366 | 366 | > "$PYTHON" "$TESTDIR/../contrib/hg-ssh" "$TESTTMP/a repo" |
|
367 | 367 | > EOF |
|
368 | 368 | |
|
369 | 369 | $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a repo" |
|
370 | 370 | 73649e48688a |
|
371 | 371 | |
|
372 | 372 | $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a'repo" |
|
373 | 373 | remote: Illegal repository "$TESTTMP/a'repo" (glob) |
|
374 | 374 | abort: no suitable response from remote hg! |
|
375 | 375 | [255] |
|
376 | 376 | |
|
377 | 377 | $ hg id --ssh "sh ssh.sh" --remotecmd hacking "ssh://user@dummy/a'repo" |
|
378 | 378 | remote: Illegal command "hacking -R 'a'\''repo' serve --stdio" |
|
379 | 379 | abort: no suitable response from remote hg! |
|
380 | 380 | [255] |
|
381 | 381 | |
|
382 | 382 | $ SSH_ORIGINAL_COMMAND="'hg' serve -R 'a'repo' --stdio" $PYTHON "$TESTDIR/../contrib/hg-ssh" |
|
383 | 383 | Illegal command "'hg' serve -R 'a'repo' --stdio": No closing quotation |
|
384 | 384 | [255] |
|
385 | 385 | |
|
386 | 386 | Test hg-ssh in read-only mode: |
|
387 | 387 | |
|
388 | 388 | $ cat > ssh.sh << EOF |
|
389 | 389 | > userhost="\$1" |
|
390 | 390 | > SSH_ORIGINAL_COMMAND="\$2" |
|
391 | 391 | > export SSH_ORIGINAL_COMMAND |
|
392 | 392 | > PYTHONPATH="$PYTHONPATH" |
|
393 | 393 | > export PYTHONPATH |
|
394 | 394 | > "$PYTHON" "$TESTDIR/../contrib/hg-ssh" --read-only "$TESTTMP/remote" |
|
395 | 395 | > EOF |
|
396 | 396 | |
|
397 | 397 | $ hg clone --ssh "sh ssh.sh" "ssh://user@dummy/$TESTTMP/remote" read-only-local |
|
398 | 398 | requesting all changes |
|
399 | 399 | adding changesets |
|
400 | 400 | adding manifests |
|
401 | 401 | adding file changes |
|
402 | 402 | added 6 changesets with 5 changes to 4 files (+1 heads) |
|
403 | 403 | updating to branch default |
|
404 | 404 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
405 | 405 | |
|
406 | 406 | $ cd read-only-local |
|
407 | 407 | $ echo "baz" > bar |
|
408 | 408 | $ hg ci -A -m "unpushable commit" bar |
|
409 | 409 | $ hg push --ssh "sh ../ssh.sh" |
|
410 | 410 | pushing to ssh://user@dummy/*/remote (glob) |
|
411 | 411 | searching for changes |
|
412 | 412 | remote: Permission denied |
|
413 | 413 | remote: abort: pretxnopen.hg-ssh hook failed |
|
414 | 414 | remote: Permission denied |
|
415 | 415 | remote: pushkey-abort: prepushkey.hg-ssh hook failed |
|
416 | 416 | updating 6c0482d977a3 to public failed! |
|
417 | 417 | [1] |
|
418 | 418 | |
|
419 | 419 | $ cd .. |
|
420 | 420 | |
|
421 | 421 | stderr from remote commands should be printed before stdout from local code (issue4336) |
|
422 | 422 | |
|
423 | 423 | $ hg clone remote stderr-ordering |
|
424 | 424 | updating to branch default |
|
425 | 425 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
426 | 426 | $ cd stderr-ordering |
|
427 | 427 | $ cat >> localwrite.py << EOF |
|
428 | 428 | > from mercurial import exchange, extensions |
|
429 | 429 | > |
|
430 | 430 | > def wrappedpush(orig, repo, *args, **kwargs): |
|
431 | 431 | > res = orig(repo, *args, **kwargs) |
|
432 | 432 | > repo.ui.write('local stdout\n') |
|
433 | 433 | > return res |
|
434 | 434 | > |
|
435 | 435 | > def extsetup(ui): |
|
436 | 436 | > extensions.wrapfunction(exchange, 'push', wrappedpush) |
|
437 | 437 | > EOF |
|
438 | 438 | |
|
439 | 439 | $ cat >> .hg/hgrc << EOF |
|
440 | 440 | > [paths] |
|
441 | 441 | > default-push = ssh://user@dummy/remote |
|
442 | 442 | > [ui] |
|
443 | 443 | > ssh = "$PYTHON" "$TESTDIR/dummyssh" |
|
444 | 444 | > [extensions] |
|
445 | 445 | > localwrite = localwrite.py |
|
446 | 446 | > EOF |
|
447 | 447 | |
|
448 | 448 | $ echo localwrite > foo |
|
449 | 449 | $ hg commit -m 'testing localwrite' |
|
450 | 450 | $ hg push |
|
451 | 451 | pushing to ssh://user@dummy/remote |
|
452 | 452 | searching for changes |
|
453 | 453 | remote: adding changesets |
|
454 | 454 | remote: adding manifests |
|
455 | 455 | remote: adding file changes |
|
456 | 456 | remote: added 1 changesets with 1 changes to 1 files |
|
457 | 457 | remote: KABOOM |
|
458 | 458 | local stdout |
|
459 | 459 | |
|
460 | 460 | debug output |
|
461 | 461 | |
|
462 | 462 | $ hg pull --debug ssh://user@dummy/remote |
|
463 | 463 | pulling from ssh://user@dummy/remote |
|
464 | 464 | running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve --stdio('|") (re) |
|
465 | 465 | sending hello command |
|
466 | 466 | sending between command |
|
467 | 467 | remote: 372 |
|
468 | 468 | remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN |
|
469 | 469 | remote: 1 |
|
470 | 470 | preparing listkeys for "bookmarks" |
|
471 | 471 | sending listkeys command |
|
472 | 472 | received listkey for "bookmarks": 45 bytes |
|
473 | 473 | query 1; heads |
|
474 | 474 | sending batch command |
|
475 | 475 | searching for changes |
|
476 | 476 | all remote heads known locally |
|
477 | 477 | no changes found |
|
478 | 478 | preparing listkeys for "phases" |
|
479 | 479 | sending listkeys command |
|
480 | 480 | received listkey for "phases": 15 bytes |
|
481 | 481 | checking for updated bookmarks |
|
482 | 482 | |
|
483 | 483 | $ cd .. |
|
484 | 484 | |
|
485 | 485 | $ cat dummylog |
|
486 | 486 | Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio |
|
487 | 487 | Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio |
|
488 | 488 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
489 | 489 | Got arguments 1:user@dummy 2:hg -R local-stream serve --stdio |
|
490 | 490 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
491 | 491 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
492 | 492 | Got arguments 1:user@dummy 2:hg -R doesnotexist serve --stdio |
|
493 | 493 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
494 | 494 | Got arguments 1:user@dummy 2:hg -R local serve --stdio |
|
495 | 495 | Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio |
|
496 | 496 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
497 | 497 | changegroup-in-remote hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_NODE_LAST=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:ssh:$LOCALIP |
|
498 | 498 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
499 | 499 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
500 | 500 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
501 | 501 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
502 | 502 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
503 | 503 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
504 | 504 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
505 | 505 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
506 | 506 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
507 | 507 | changegroup-in-remote hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_NODE_LAST=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:ssh:$LOCALIP |
|
508 | 508 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
509 | 509 | Got arguments 1:user@dummy 2:hg init 'a repo' |
|
510 | 510 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
511 | 511 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
512 | 512 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
513 | 513 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
514 | 514 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
515 | 515 | changegroup-in-remote hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_NODE_LAST=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:ssh:$LOCALIP |
|
516 | 516 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
517 | 517 | |
|
518 | 518 | remote hook failure is attributed to remote |
|
519 | 519 | |
|
520 | 520 | $ cat > $TESTTMP/failhook << EOF |
|
521 | 521 | > def hook(ui, repo, **kwargs): |
|
522 | 522 | > ui.write('hook failure!\n') |
|
523 | 523 | > ui.flush() |
|
524 | 524 | > return 1 |
|
525 | 525 | > EOF |
|
526 | 526 | |
|
527 | 527 | $ echo "pretxnchangegroup.fail = python:$TESTTMP/failhook:hook" >> remote/.hg/hgrc |
|
528 | 528 | |
|
529 | 529 | $ hg -q --config ui.ssh="\"$PYTHON\" $TESTDIR/dummyssh" clone ssh://user@dummy/remote hookout |
|
530 | 530 | $ cd hookout |
|
531 | 531 | $ touch hookfailure |
|
532 | 532 | $ hg -q commit -A -m 'remote hook failure' |
|
533 | 533 | $ hg --config ui.ssh="\"$PYTHON\" $TESTDIR/dummyssh" push |
|
534 | 534 | pushing to ssh://user@dummy/remote |
|
535 | 535 | searching for changes |
|
536 | 536 | remote: adding changesets |
|
537 | 537 | remote: adding manifests |
|
538 | 538 | remote: adding file changes |
|
539 | 539 | remote: added 1 changesets with 1 changes to 1 files |
|
540 | 540 | remote: hook failure! |
|
541 | 541 | remote: transaction abort! |
|
542 | 542 | remote: rollback completed |
|
543 | 543 | remote: abort: pretxnchangegroup.fail hook failed |
|
544 | 544 | [1] |
|
545 | 545 | |
|
546 | 546 | abort during pull is properly reported as such |
|
547 | 547 | |
|
548 | 548 | $ echo morefoo >> ../remote/foo |
|
549 | 549 | $ hg -R ../remote commit --message "more foo to be pulled" |
|
550 | 550 | $ cat >> ../remote/.hg/hgrc << EOF |
|
551 | 551 | > [extensions] |
|
552 | 552 | > crash = ${TESTDIR}/crashgetbundler.py |
|
553 | 553 | > EOF |
|
554 | 554 | $ hg --config ui.ssh="\"$PYTHON\" $TESTDIR/dummyssh" pull |
|
555 | 555 | pulling from ssh://user@dummy/remote |
|
556 | 556 | searching for changes |
|
557 | 557 | adding changesets |
|
558 | 558 | remote: abort: this is an exercise |
|
559 | 559 | transaction abort! |
|
560 | 560 | rollback completed |
|
561 | 561 | abort: stream ended unexpectedly (got 0 bytes, expected 4) |
|
562 | 562 | [255] |
@@ -1,195 +1,195 b'' | |||
|
1 | 1 | This test tries to exercise the ssh functionality with a dummy script |
|
2 | 2 | |
|
3 | 3 | creating 'remote' repo |
|
4 | 4 | |
|
5 | 5 | $ hg init remote |
|
6 | 6 | $ cd remote |
|
7 | 7 | $ hg unbundle "$TESTDIR/bundles/remote.hg" |
|
8 | 8 | adding changesets |
|
9 | 9 | adding manifests |
|
10 | 10 | adding file changes |
|
11 | 11 | added 9 changesets with 7 changes to 4 files (+1 heads) |
|
12 | 12 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
13 | 13 | $ hg up tip |
|
14 | 14 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
15 | 15 | $ cd .. |
|
16 | 16 | |
|
17 | 17 | clone remote via stream |
|
18 | 18 | |
|
19 | 19 | $ for i in 0 1 2 3 4 5 6 7 8; do |
|
20 |
> hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -- |
|
|
20 | > hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --stream -r "$i" ssh://user@dummy/remote test-"$i" | |
|
21 | 21 | > if cd test-"$i"; then |
|
22 | 22 | > hg verify |
|
23 | 23 | > cd .. |
|
24 | 24 | > fi |
|
25 | 25 | > done |
|
26 | 26 | adding changesets |
|
27 | 27 | adding manifests |
|
28 | 28 | adding file changes |
|
29 | 29 | added 1 changesets with 1 changes to 1 files |
|
30 | 30 | updating to branch default |
|
31 | 31 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
32 | 32 | checking changesets |
|
33 | 33 | checking manifests |
|
34 | 34 | crosschecking files in changesets and manifests |
|
35 | 35 | checking files |
|
36 | 36 | 1 files, 1 changesets, 1 total revisions |
|
37 | 37 | adding changesets |
|
38 | 38 | adding manifests |
|
39 | 39 | adding file changes |
|
40 | 40 | added 2 changesets with 2 changes to 1 files |
|
41 | 41 | updating to branch default |
|
42 | 42 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
43 | 43 | checking changesets |
|
44 | 44 | checking manifests |
|
45 | 45 | crosschecking files in changesets and manifests |
|
46 | 46 | checking files |
|
47 | 47 | 1 files, 2 changesets, 2 total revisions |
|
48 | 48 | adding changesets |
|
49 | 49 | adding manifests |
|
50 | 50 | adding file changes |
|
51 | 51 | added 3 changesets with 3 changes to 1 files |
|
52 | 52 | updating to branch default |
|
53 | 53 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
54 | 54 | checking changesets |
|
55 | 55 | checking manifests |
|
56 | 56 | crosschecking files in changesets and manifests |
|
57 | 57 | checking files |
|
58 | 58 | 1 files, 3 changesets, 3 total revisions |
|
59 | 59 | adding changesets |
|
60 | 60 | adding manifests |
|
61 | 61 | adding file changes |
|
62 | 62 | added 4 changesets with 4 changes to 1 files |
|
63 | 63 | updating to branch default |
|
64 | 64 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
65 | 65 | checking changesets |
|
66 | 66 | checking manifests |
|
67 | 67 | crosschecking files in changesets and manifests |
|
68 | 68 | checking files |
|
69 | 69 | 1 files, 4 changesets, 4 total revisions |
|
70 | 70 | adding changesets |
|
71 | 71 | adding manifests |
|
72 | 72 | adding file changes |
|
73 | 73 | added 2 changesets with 2 changes to 1 files |
|
74 | 74 | updating to branch default |
|
75 | 75 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
76 | 76 | checking changesets |
|
77 | 77 | checking manifests |
|
78 | 78 | crosschecking files in changesets and manifests |
|
79 | 79 | checking files |
|
80 | 80 | 1 files, 2 changesets, 2 total revisions |
|
81 | 81 | adding changesets |
|
82 | 82 | adding manifests |
|
83 | 83 | adding file changes |
|
84 | 84 | added 3 changesets with 3 changes to 1 files |
|
85 | 85 | updating to branch default |
|
86 | 86 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
87 | 87 | checking changesets |
|
88 | 88 | checking manifests |
|
89 | 89 | crosschecking files in changesets and manifests |
|
90 | 90 | checking files |
|
91 | 91 | 1 files, 3 changesets, 3 total revisions |
|
92 | 92 | adding changesets |
|
93 | 93 | adding manifests |
|
94 | 94 | adding file changes |
|
95 | 95 | added 4 changesets with 5 changes to 2 files |
|
96 | 96 | updating to branch default |
|
97 | 97 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
98 | 98 | checking changesets |
|
99 | 99 | checking manifests |
|
100 | 100 | crosschecking files in changesets and manifests |
|
101 | 101 | checking files |
|
102 | 102 | 2 files, 4 changesets, 5 total revisions |
|
103 | 103 | adding changesets |
|
104 | 104 | adding manifests |
|
105 | 105 | adding file changes |
|
106 | 106 | added 5 changesets with 6 changes to 3 files |
|
107 | 107 | updating to branch default |
|
108 | 108 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
109 | 109 | checking changesets |
|
110 | 110 | checking manifests |
|
111 | 111 | crosschecking files in changesets and manifests |
|
112 | 112 | checking files |
|
113 | 113 | 3 files, 5 changesets, 6 total revisions |
|
114 | 114 | adding changesets |
|
115 | 115 | adding manifests |
|
116 | 116 | adding file changes |
|
117 | 117 | added 5 changesets with 5 changes to 2 files |
|
118 | 118 | updating to branch default |
|
119 | 119 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
120 | 120 | checking changesets |
|
121 | 121 | checking manifests |
|
122 | 122 | crosschecking files in changesets and manifests |
|
123 | 123 | checking files |
|
124 | 124 | 2 files, 5 changesets, 5 total revisions |
|
125 | 125 | $ cd test-8 |
|
126 | 126 | $ hg pull ../test-7 |
|
127 | 127 | pulling from ../test-7 |
|
128 | 128 | searching for changes |
|
129 | 129 | adding changesets |
|
130 | 130 | adding manifests |
|
131 | 131 | adding file changes |
|
132 | 132 | added 4 changesets with 2 changes to 3 files (+1 heads) |
|
133 | 133 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
134 | 134 | $ hg verify |
|
135 | 135 | checking changesets |
|
136 | 136 | checking manifests |
|
137 | 137 | crosschecking files in changesets and manifests |
|
138 | 138 | checking files |
|
139 | 139 | 4 files, 9 changesets, 7 total revisions |
|
140 | 140 | $ cd .. |
|
141 | 141 | $ cd test-1 |
|
142 | 142 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -r 4 ssh://user@dummy/remote |
|
143 | 143 | pulling from ssh://user@dummy/remote |
|
144 | 144 | searching for changes |
|
145 | 145 | adding changesets |
|
146 | 146 | adding manifests |
|
147 | 147 | adding file changes |
|
148 | 148 | added 1 changesets with 0 changes to 0 files (+1 heads) |
|
149 | 149 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
150 | 150 | $ hg verify |
|
151 | 151 | checking changesets |
|
152 | 152 | checking manifests |
|
153 | 153 | crosschecking files in changesets and manifests |
|
154 | 154 | checking files |
|
155 | 155 | 1 files, 3 changesets, 2 total revisions |
|
156 | 156 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote |
|
157 | 157 | pulling from ssh://user@dummy/remote |
|
158 | 158 | searching for changes |
|
159 | 159 | adding changesets |
|
160 | 160 | adding manifests |
|
161 | 161 | adding file changes |
|
162 | 162 | added 6 changesets with 5 changes to 4 files |
|
163 | 163 | (run 'hg update' to get a working copy) |
|
164 | 164 | $ cd .. |
|
165 | 165 | $ cd test-2 |
|
166 | 166 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -r 5 ssh://user@dummy/remote |
|
167 | 167 | pulling from ssh://user@dummy/remote |
|
168 | 168 | searching for changes |
|
169 | 169 | adding changesets |
|
170 | 170 | adding manifests |
|
171 | 171 | adding file changes |
|
172 | 172 | added 2 changesets with 0 changes to 0 files (+1 heads) |
|
173 | 173 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
174 | 174 | $ hg verify |
|
175 | 175 | checking changesets |
|
176 | 176 | checking manifests |
|
177 | 177 | crosschecking files in changesets and manifests |
|
178 | 178 | checking files |
|
179 | 179 | 1 files, 5 changesets, 3 total revisions |
|
180 | 180 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote |
|
181 | 181 | pulling from ssh://user@dummy/remote |
|
182 | 182 | searching for changes |
|
183 | 183 | adding changesets |
|
184 | 184 | adding manifests |
|
185 | 185 | adding file changes |
|
186 | 186 | added 4 changesets with 4 changes to 4 files |
|
187 | 187 | (run 'hg update' to get a working copy) |
|
188 | 188 | $ hg verify |
|
189 | 189 | checking changesets |
|
190 | 190 | checking manifests |
|
191 | 191 | crosschecking files in changesets and manifests |
|
192 | 192 | checking files |
|
193 | 193 | 4 files, 9 changesets, 7 total revisions |
|
194 | 194 | |
|
195 | 195 | $ cd .. |
@@ -1,577 +1,577 b'' | |||
|
1 | 1 | |
|
2 | 2 | This test tries to exercise the ssh functionality with a dummy script |
|
3 | 3 | |
|
4 | 4 | $ cat <<EOF >> $HGRCPATH |
|
5 | 5 | > [format] |
|
6 | 6 | > usegeneraldelta=yes |
|
7 | 7 | > EOF |
|
8 | 8 | |
|
9 | 9 | creating 'remote' repo |
|
10 | 10 | |
|
11 | 11 | $ hg init remote |
|
12 | 12 | $ cd remote |
|
13 | 13 | $ echo this > foo |
|
14 | 14 | $ echo this > fooO |
|
15 | 15 | $ hg ci -A -m "init" foo fooO |
|
16 | 16 | |
|
17 | 17 | insert a closed branch (issue4428) |
|
18 | 18 | |
|
19 | 19 | $ hg up null |
|
20 | 20 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
21 | 21 | $ hg branch closed |
|
22 | 22 | marked working directory as branch closed |
|
23 | 23 | (branches are permanent and global, did you want a bookmark?) |
|
24 | 24 | $ hg ci -mc0 |
|
25 | 25 | $ hg ci --close-branch -mc1 |
|
26 | 26 | $ hg up -q default |
|
27 | 27 | |
|
28 | 28 | configure for serving |
|
29 | 29 | |
|
30 | 30 | $ cat <<EOF > .hg/hgrc |
|
31 | 31 | > [server] |
|
32 | 32 | > uncompressed = True |
|
33 | 33 | > |
|
34 | 34 | > [hooks] |
|
35 | 35 | > changegroup = sh -c "printenv.py changegroup-in-remote 0 ../dummylog" |
|
36 | 36 | > EOF |
|
37 | 37 | $ cd .. |
|
38 | 38 | |
|
39 | 39 | repo not found error |
|
40 | 40 | |
|
41 | 41 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local |
|
42 | 42 | remote: abort: repository nonexistent not found! |
|
43 | 43 | abort: no suitable response from remote hg! |
|
44 | 44 | [255] |
|
45 | 45 | |
|
46 | 46 | non-existent absolute path |
|
47 | 47 | |
|
48 | 48 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/`pwd`/nonexistent local |
|
49 | 49 | remote: abort: repository $TESTTMP/nonexistent not found! |
|
50 | 50 | abort: no suitable response from remote hg! |
|
51 | 51 | [255] |
|
52 | 52 | |
|
53 | 53 | clone remote via stream |
|
54 | 54 | |
|
55 |
$ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -- |
|
|
55 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --stream ssh://user@dummy/remote local-stream | |
|
56 | 56 | streaming all changes |
|
57 | 57 | 4 files to transfer, 602 bytes of data |
|
58 | 58 | transferred 602 bytes in * seconds (*) (glob) |
|
59 | 59 | searching for changes |
|
60 | 60 | no changes found |
|
61 | 61 | updating to branch default |
|
62 | 62 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
63 | 63 | $ cd local-stream |
|
64 | 64 | $ hg verify |
|
65 | 65 | checking changesets |
|
66 | 66 | checking manifests |
|
67 | 67 | crosschecking files in changesets and manifests |
|
68 | 68 | checking files |
|
69 | 69 | 2 files, 3 changesets, 2 total revisions |
|
70 | 70 | $ hg branches |
|
71 | 71 | default 0:1160648e36ce |
|
72 | 72 | $ cd .. |
|
73 | 73 | |
|
74 | 74 | clone bookmarks via stream |
|
75 | 75 | |
|
76 | 76 | $ hg -R local-stream book mybook |
|
77 |
$ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -- |
|
|
77 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --stream ssh://user@dummy/local-stream stream2 | |
|
78 | 78 | streaming all changes |
|
79 | 79 | 4 files to transfer, 602 bytes of data |
|
80 | 80 | transferred 602 bytes in * seconds (*) (glob) |
|
81 | 81 | searching for changes |
|
82 | 82 | no changes found |
|
83 | 83 | updating to branch default |
|
84 | 84 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
85 | 85 | $ cd stream2 |
|
86 | 86 | $ hg book |
|
87 | 87 | mybook 0:1160648e36ce |
|
88 | 88 | $ cd .. |
|
89 | 89 | $ rm -rf local-stream stream2 |
|
90 | 90 | |
|
91 | 91 | clone remote via pull |
|
92 | 92 | |
|
93 | 93 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local |
|
94 | 94 | requesting all changes |
|
95 | 95 | adding changesets |
|
96 | 96 | adding manifests |
|
97 | 97 | adding file changes |
|
98 | 98 | added 3 changesets with 2 changes to 2 files |
|
99 | 99 | updating to branch default |
|
100 | 100 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
101 | 101 | |
|
102 | 102 | verify |
|
103 | 103 | |
|
104 | 104 | $ cd local |
|
105 | 105 | $ hg verify |
|
106 | 106 | checking changesets |
|
107 | 107 | checking manifests |
|
108 | 108 | crosschecking files in changesets and manifests |
|
109 | 109 | checking files |
|
110 | 110 | 2 files, 3 changesets, 2 total revisions |
|
111 | 111 | $ cat >> .hg/hgrc <<EOF |
|
112 | 112 | > [hooks] |
|
113 | 113 | > changegroup = sh -c "printenv.py changegroup-in-local 0 ../dummylog" |
|
114 | 114 | > EOF |
|
115 | 115 | |
|
116 | 116 | empty default pull |
|
117 | 117 | |
|
118 | 118 | $ hg paths |
|
119 | 119 | default = ssh://user@dummy/remote |
|
120 | 120 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" |
|
121 | 121 | pulling from ssh://user@dummy/remote |
|
122 | 122 | searching for changes |
|
123 | 123 | no changes found |
|
124 | 124 | |
|
125 | 125 | pull from wrong ssh URL |
|
126 | 126 | |
|
127 | 127 | $ hg pull -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/doesnotexist |
|
128 | 128 | pulling from ssh://user@dummy/doesnotexist |
|
129 | 129 | remote: abort: repository doesnotexist not found! |
|
130 | 130 | abort: no suitable response from remote hg! |
|
131 | 131 | [255] |
|
132 | 132 | |
|
133 | 133 | local change |
|
134 | 134 | |
|
135 | 135 | $ echo bleah > foo |
|
136 | 136 | $ hg ci -m "add" |
|
137 | 137 | |
|
138 | 138 | updating rc |
|
139 | 139 | |
|
140 | 140 | $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc |
|
141 | 141 | $ echo "[ui]" >> .hg/hgrc |
|
142 | 142 | $ echo "ssh = \"$PYTHON\" \"$TESTDIR/dummyssh\"" >> .hg/hgrc |
|
143 | 143 | |
|
144 | 144 | find outgoing |
|
145 | 145 | |
|
146 | 146 | $ hg out ssh://user@dummy/remote |
|
147 | 147 | comparing with ssh://user@dummy/remote |
|
148 | 148 | searching for changes |
|
149 | 149 | changeset: 3:a28a9d1a809c |
|
150 | 150 | tag: tip |
|
151 | 151 | parent: 0:1160648e36ce |
|
152 | 152 | user: test |
|
153 | 153 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
154 | 154 | summary: add |
|
155 | 155 | |
|
156 | 156 | |
|
157 | 157 | find incoming on the remote side |
|
158 | 158 | |
|
159 | 159 | $ hg incoming -R ../remote -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/local |
|
160 | 160 | comparing with ssh://user@dummy/local |
|
161 | 161 | searching for changes |
|
162 | 162 | changeset: 3:a28a9d1a809c |
|
163 | 163 | tag: tip |
|
164 | 164 | parent: 0:1160648e36ce |
|
165 | 165 | user: test |
|
166 | 166 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
167 | 167 | summary: add |
|
168 | 168 | |
|
169 | 169 | |
|
170 | 170 | find incoming on the remote side (using absolute path) |
|
171 | 171 | |
|
172 | 172 | $ hg incoming -R ../remote -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/`pwd`" |
|
173 | 173 | comparing with ssh://user@dummy/$TESTTMP/local |
|
174 | 174 | searching for changes |
|
175 | 175 | changeset: 3:a28a9d1a809c |
|
176 | 176 | tag: tip |
|
177 | 177 | parent: 0:1160648e36ce |
|
178 | 178 | user: test |
|
179 | 179 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
180 | 180 | summary: add |
|
181 | 181 | |
|
182 | 182 | |
|
183 | 183 | push |
|
184 | 184 | |
|
185 | 185 | $ hg push |
|
186 | 186 | pushing to ssh://user@dummy/remote |
|
187 | 187 | searching for changes |
|
188 | 188 | remote: adding changesets |
|
189 | 189 | remote: adding manifests |
|
190 | 190 | remote: adding file changes |
|
191 | 191 | remote: added 1 changesets with 1 changes to 1 files |
|
192 | 192 | $ cd ../remote |
|
193 | 193 | |
|
194 | 194 | check remote tip |
|
195 | 195 | |
|
196 | 196 | $ hg tip |
|
197 | 197 | changeset: 3:a28a9d1a809c |
|
198 | 198 | tag: tip |
|
199 | 199 | parent: 0:1160648e36ce |
|
200 | 200 | user: test |
|
201 | 201 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
202 | 202 | summary: add |
|
203 | 203 | |
|
204 | 204 | $ hg verify |
|
205 | 205 | checking changesets |
|
206 | 206 | checking manifests |
|
207 | 207 | crosschecking files in changesets and manifests |
|
208 | 208 | checking files |
|
209 | 209 | 2 files, 4 changesets, 3 total revisions |
|
210 | 210 | $ hg cat -r tip foo |
|
211 | 211 | bleah |
|
212 | 212 | $ echo z > z |
|
213 | 213 | $ hg ci -A -m z z |
|
214 | 214 | created new head |
|
215 | 215 | |
|
216 | 216 | test pushkeys and bookmarks |
|
217 | 217 | |
|
218 | 218 | $ cd ../local |
|
219 | 219 | $ hg debugpushkey --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote namespaces |
|
220 | 220 | bookmarks |
|
221 | 221 | namespaces |
|
222 | 222 | phases |
|
223 | 223 | $ hg book foo -r 0 |
|
224 | 224 | $ hg out -B |
|
225 | 225 | comparing with ssh://user@dummy/remote |
|
226 | 226 | searching for changed bookmarks |
|
227 | 227 | foo 1160648e36ce |
|
228 | 228 | $ hg push -B foo |
|
229 | 229 | pushing to ssh://user@dummy/remote |
|
230 | 230 | searching for changes |
|
231 | 231 | no changes found |
|
232 | 232 | exporting bookmark foo |
|
233 | 233 | [1] |
|
234 | 234 | $ hg debugpushkey --config ui.ssh="\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote bookmarks |
|
235 | 235 | foo 1160648e36cec0054048a7edc4110c6f84fde594 |
|
236 | 236 | $ hg book -f foo |
|
237 | 237 | $ hg push --traceback |
|
238 | 238 | pushing to ssh://user@dummy/remote |
|
239 | 239 | searching for changes |
|
240 | 240 | no changes found |
|
241 | 241 | updating bookmark foo |
|
242 | 242 | [1] |
|
243 | 243 | $ hg book -d foo |
|
244 | 244 | $ hg in -B |
|
245 | 245 | comparing with ssh://user@dummy/remote |
|
246 | 246 | searching for changed bookmarks |
|
247 | 247 | foo a28a9d1a809c |
|
248 | 248 | $ hg book -f -r 0 foo |
|
249 | 249 | $ hg pull -B foo |
|
250 | 250 | pulling from ssh://user@dummy/remote |
|
251 | 251 | no changes found |
|
252 | 252 | updating bookmark foo |
|
253 | 253 | $ hg book -d foo |
|
254 | 254 | $ hg push -B foo |
|
255 | 255 | pushing to ssh://user@dummy/remote |
|
256 | 256 | searching for changes |
|
257 | 257 | no changes found |
|
258 | 258 | deleting remote bookmark foo |
|
259 | 259 | [1] |
|
260 | 260 | |
|
261 | 261 | a bad, evil hook that prints to stdout |
|
262 | 262 | |
|
263 | 263 | $ cat <<EOF > $TESTTMP/badhook |
|
264 | 264 | > import sys |
|
265 | 265 | > sys.stdout.write("KABOOM\n") |
|
266 | 266 | > EOF |
|
267 | 267 | |
|
268 | 268 | $ cat <<EOF > $TESTTMP/badpyhook.py |
|
269 | 269 | > import sys |
|
270 | 270 | > def hook(ui, repo, hooktype, **kwargs): |
|
271 | 271 | > sys.stdout.write("KABOOM IN PROCESS\n") |
|
272 | 272 | > EOF |
|
273 | 273 | |
|
274 | 274 | $ cat <<EOF >> ../remote/.hg/hgrc |
|
275 | 275 | > [hooks] |
|
276 | 276 | > changegroup.stdout = $PYTHON $TESTTMP/badhook |
|
277 | 277 | > changegroup.pystdout = python:$TESTTMP/badpyhook.py:hook |
|
278 | 278 | > EOF |
|
279 | 279 | $ echo r > r |
|
280 | 280 | $ hg ci -A -m z r |
|
281 | 281 | |
|
282 | 282 | push should succeed even though it has an unexpected response |
|
283 | 283 | |
|
284 | 284 | $ hg push |
|
285 | 285 | pushing to ssh://user@dummy/remote |
|
286 | 286 | searching for changes |
|
287 | 287 | remote has heads on branch 'default' that are not known locally: 6c0482d977a3 |
|
288 | 288 | remote: adding changesets |
|
289 | 289 | remote: adding manifests |
|
290 | 290 | remote: adding file changes |
|
291 | 291 | remote: added 1 changesets with 1 changes to 1 files |
|
292 | 292 | remote: KABOOM |
|
293 | 293 | remote: KABOOM IN PROCESS |
|
294 | 294 | $ hg -R ../remote heads |
|
295 | 295 | changeset: 5:1383141674ec |
|
296 | 296 | tag: tip |
|
297 | 297 | parent: 3:a28a9d1a809c |
|
298 | 298 | user: test |
|
299 | 299 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
300 | 300 | summary: z |
|
301 | 301 | |
|
302 | 302 | changeset: 4:6c0482d977a3 |
|
303 | 303 | parent: 0:1160648e36ce |
|
304 | 304 | user: test |
|
305 | 305 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
306 | 306 | summary: z |
|
307 | 307 | |
|
308 | 308 | |
|
309 | 309 | clone bookmarks |
|
310 | 310 | |
|
311 | 311 | $ hg -R ../remote bookmark test |
|
312 | 312 | $ hg -R ../remote bookmarks |
|
313 | 313 | * test 4:6c0482d977a3 |
|
314 | 314 | $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local-bookmarks |
|
315 | 315 | requesting all changes |
|
316 | 316 | adding changesets |
|
317 | 317 | adding manifests |
|
318 | 318 | adding file changes |
|
319 | 319 | added 6 changesets with 5 changes to 4 files (+1 heads) |
|
320 | 320 | updating to branch default |
|
321 | 321 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
322 | 322 | $ hg -R local-bookmarks bookmarks |
|
323 | 323 | test 4:6c0482d977a3 |
|
324 | 324 | |
|
325 | 325 | passwords in ssh urls are not supported |
|
326 | 326 | (we use a glob here because different Python versions give different |
|
327 | 327 | results here) |
|
328 | 328 | |
|
329 | 329 | $ hg push ssh://user:erroneouspwd@dummy/remote |
|
330 | 330 | pushing to ssh://user:*@dummy/remote (glob) |
|
331 | 331 | abort: password in URL not supported! |
|
332 | 332 | [255] |
|
333 | 333 | |
|
334 | 334 | $ cd .. |
|
335 | 335 | |
|
336 | 336 | hide outer repo |
|
337 | 337 | $ hg init |
|
338 | 338 | |
|
339 | 339 | Test remote paths with spaces (issue2983): |
|
340 | 340 | |
|
341 | 341 | $ hg init --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" |
|
342 | 342 | $ touch "$TESTTMP/a repo/test" |
|
343 | 343 | $ hg -R 'a repo' commit -A -m "test" |
|
344 | 344 | adding test |
|
345 | 345 | $ hg -R 'a repo' tag tag |
|
346 | 346 | $ hg id --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" |
|
347 | 347 | 73649e48688a |
|
348 | 348 | |
|
349 | 349 | $ hg id --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo#noNoNO" |
|
350 | 350 | abort: unknown revision 'noNoNO'! |
|
351 | 351 | [255] |
|
352 | 352 | |
|
353 | 353 | Test (non-)escaping of remote paths with spaces when cloning (issue3145): |
|
354 | 354 | |
|
355 | 355 | $ hg clone --ssh "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" |
|
356 | 356 | destination directory: a repo |
|
357 | 357 | abort: destination 'a repo' is not empty |
|
358 | 358 | [255] |
|
359 | 359 | |
|
360 | 360 | Make sure hg is really paranoid in serve --stdio mode. It used to be |
|
361 | 361 | possible to get a debugger REPL by specifying a repo named --debugger. |
|
362 | 362 | $ hg -R --debugger serve --stdio |
|
363 | 363 | abort: potentially unsafe serve --stdio invocation: ['-R', '--debugger', 'serve', '--stdio'] |
|
364 | 364 | [255] |
|
365 | 365 | $ hg -R --config=ui.debugger=yes serve --stdio |
|
366 | 366 | abort: potentially unsafe serve --stdio invocation: ['-R', '--config=ui.debugger=yes', 'serve', '--stdio'] |
|
367 | 367 | [255] |
|
368 | 368 | Abbreviations of 'serve' also don't work, to avoid shenanigans. |
|
369 | 369 | $ hg -R narf serv --stdio |
|
370 | 370 | abort: potentially unsafe serve --stdio invocation: ['-R', 'narf', 'serv', '--stdio'] |
|
371 | 371 | [255] |
|
372 | 372 | |
|
373 | 373 | Test hg-ssh using a helper script that will restore PYTHONPATH (which might |
|
374 | 374 | have been cleared by a hg.exe wrapper) and invoke hg-ssh with the right |
|
375 | 375 | parameters: |
|
376 | 376 | |
|
377 | 377 | $ cat > ssh.sh << EOF |
|
378 | 378 | > userhost="\$1" |
|
379 | 379 | > SSH_ORIGINAL_COMMAND="\$2" |
|
380 | 380 | > export SSH_ORIGINAL_COMMAND |
|
381 | 381 | > PYTHONPATH="$PYTHONPATH" |
|
382 | 382 | > export PYTHONPATH |
|
383 | 383 | > "$PYTHON" "$TESTDIR/../contrib/hg-ssh" "$TESTTMP/a repo" |
|
384 | 384 | > EOF |
|
385 | 385 | |
|
386 | 386 | $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a repo" |
|
387 | 387 | 73649e48688a |
|
388 | 388 | |
|
389 | 389 | $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a'repo" |
|
390 | 390 | remote: Illegal repository "$TESTTMP/a'repo" (glob) |
|
391 | 391 | abort: no suitable response from remote hg! |
|
392 | 392 | [255] |
|
393 | 393 | |
|
394 | 394 | $ hg id --ssh "sh ssh.sh" --remotecmd hacking "ssh://user@dummy/a'repo" |
|
395 | 395 | remote: Illegal command "hacking -R 'a'\''repo' serve --stdio" |
|
396 | 396 | abort: no suitable response from remote hg! |
|
397 | 397 | [255] |
|
398 | 398 | |
|
399 | 399 | $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" $PYTHON "$TESTDIR/../contrib/hg-ssh" |
|
400 | 400 | Illegal command "'hg' -R 'a'repo' serve --stdio": No closing quotation |
|
401 | 401 | [255] |
|
402 | 402 | |
|
403 | 403 | Test hg-ssh in read-only mode: |
|
404 | 404 | |
|
405 | 405 | $ cat > ssh.sh << EOF |
|
406 | 406 | > userhost="\$1" |
|
407 | 407 | > SSH_ORIGINAL_COMMAND="\$2" |
|
408 | 408 | > export SSH_ORIGINAL_COMMAND |
|
409 | 409 | > PYTHONPATH="$PYTHONPATH" |
|
410 | 410 | > export PYTHONPATH |
|
411 | 411 | > "$PYTHON" "$TESTDIR/../contrib/hg-ssh" --read-only "$TESTTMP/remote" |
|
412 | 412 | > EOF |
|
413 | 413 | |
|
414 | 414 | $ hg clone --ssh "sh ssh.sh" "ssh://user@dummy/$TESTTMP/remote" read-only-local |
|
415 | 415 | requesting all changes |
|
416 | 416 | adding changesets |
|
417 | 417 | adding manifests |
|
418 | 418 | adding file changes |
|
419 | 419 | added 6 changesets with 5 changes to 4 files (+1 heads) |
|
420 | 420 | updating to branch default |
|
421 | 421 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
422 | 422 | |
|
423 | 423 | $ cd read-only-local |
|
424 | 424 | $ echo "baz" > bar |
|
425 | 425 | $ hg ci -A -m "unpushable commit" bar |
|
426 | 426 | $ hg push --ssh "sh ../ssh.sh" |
|
427 | 427 | pushing to ssh://user@dummy/*/remote (glob) |
|
428 | 428 | searching for changes |
|
429 | 429 | remote: Permission denied |
|
430 | 430 | remote: pretxnopen.hg-ssh hook failed |
|
431 | 431 | abort: push failed on remote |
|
432 | 432 | [255] |
|
433 | 433 | |
|
434 | 434 | $ cd .. |
|
435 | 435 | |
|
436 | 436 | stderr from remote commands should be printed before stdout from local code (issue4336) |
|
437 | 437 | |
|
438 | 438 | $ hg clone remote stderr-ordering |
|
439 | 439 | updating to branch default |
|
440 | 440 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
441 | 441 | $ cd stderr-ordering |
|
442 | 442 | $ cat >> localwrite.py << EOF |
|
443 | 443 | > from mercurial import exchange, extensions |
|
444 | 444 | > |
|
445 | 445 | > def wrappedpush(orig, repo, *args, **kwargs): |
|
446 | 446 | > res = orig(repo, *args, **kwargs) |
|
447 | 447 | > repo.ui.write('local stdout\n') |
|
448 | 448 | > return res |
|
449 | 449 | > |
|
450 | 450 | > def extsetup(ui): |
|
451 | 451 | > extensions.wrapfunction(exchange, 'push', wrappedpush) |
|
452 | 452 | > EOF |
|
453 | 453 | |
|
454 | 454 | $ cat >> .hg/hgrc << EOF |
|
455 | 455 | > [paths] |
|
456 | 456 | > default-push = ssh://user@dummy/remote |
|
457 | 457 | > [ui] |
|
458 | 458 | > ssh = "$PYTHON" "$TESTDIR/dummyssh" |
|
459 | 459 | > [extensions] |
|
460 | 460 | > localwrite = localwrite.py |
|
461 | 461 | > EOF |
|
462 | 462 | |
|
463 | 463 | $ echo localwrite > foo |
|
464 | 464 | $ hg commit -m 'testing localwrite' |
|
465 | 465 | $ hg push |
|
466 | 466 | pushing to ssh://user@dummy/remote |
|
467 | 467 | searching for changes |
|
468 | 468 | remote: adding changesets |
|
469 | 469 | remote: adding manifests |
|
470 | 470 | remote: adding file changes |
|
471 | 471 | remote: added 1 changesets with 1 changes to 1 files |
|
472 | 472 | remote: KABOOM |
|
473 | 473 | remote: KABOOM IN PROCESS |
|
474 | 474 | local stdout |
|
475 | 475 | |
|
476 | 476 | debug output |
|
477 | 477 | |
|
478 | 478 | $ hg pull --debug ssh://user@dummy/remote |
|
479 | 479 | pulling from ssh://user@dummy/remote |
|
480 | 480 | running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve --stdio('|") (re) |
|
481 | 481 | sending hello command |
|
482 | 482 | sending between command |
|
483 | 483 | remote: 372 |
|
484 | 484 | remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Aphases%3Dheads%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps unbundle=HG10GZ,HG10BZ,HG10UN |
|
485 | 485 | remote: 1 |
|
486 | 486 | query 1; heads |
|
487 | 487 | sending batch command |
|
488 | 488 | searching for changes |
|
489 | 489 | all remote heads known locally |
|
490 | 490 | no changes found |
|
491 | 491 | sending getbundle command |
|
492 | 492 | bundle2-input-bundle: with-transaction |
|
493 | 493 | bundle2-input-part: "listkeys" (params: 1 mandatory) supported |
|
494 | 494 | bundle2-input-part: total payload size 45 |
|
495 | 495 | bundle2-input-part: "phase-heads" supported |
|
496 | 496 | bundle2-input-part: total payload size 72 |
|
497 | 497 | bundle2-input-bundle: 1 parts total |
|
498 | 498 | checking for updated bookmarks |
|
499 | 499 | |
|
500 | 500 | $ cd .. |
|
501 | 501 | |
|
502 | 502 | $ cat dummylog |
|
503 | 503 | Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio |
|
504 | 504 | Got arguments 1:user@dummy 2:hg -R $TESTTMP/nonexistent serve --stdio |
|
505 | 505 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
506 | 506 | Got arguments 1:user@dummy 2:hg -R local-stream serve --stdio |
|
507 | 507 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
508 | 508 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
509 | 509 | Got arguments 1:user@dummy 2:hg -R doesnotexist serve --stdio |
|
510 | 510 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
511 | 511 | Got arguments 1:user@dummy 2:hg -R local serve --stdio |
|
512 | 512 | Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio |
|
513 | 513 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
514 | 514 | changegroup-in-remote hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_NODE_LAST=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:ssh:$LOCALIP |
|
515 | 515 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
516 | 516 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
517 | 517 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
518 | 518 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
519 | 519 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
520 | 520 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
521 | 521 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
522 | 522 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
523 | 523 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
524 | 524 | changegroup-in-remote hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_NODE_LAST=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:ssh:$LOCALIP |
|
525 | 525 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
526 | 526 | Got arguments 1:user@dummy 2:hg init 'a repo' |
|
527 | 527 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
528 | 528 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
529 | 529 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
530 | 530 | Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio |
|
531 | 531 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
532 | 532 | changegroup-in-remote hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_NODE_LAST=65c38f4125f9602c8db4af56530cc221d93b8ef8 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:ssh:$LOCALIP |
|
533 | 533 | Got arguments 1:user@dummy 2:hg -R remote serve --stdio |
|
534 | 534 | |
|
535 | 535 | remote hook failure is attributed to remote |
|
536 | 536 | |
|
537 | 537 | $ cat > $TESTTMP/failhook << EOF |
|
538 | 538 | > def hook(ui, repo, **kwargs): |
|
539 | 539 | > ui.write('hook failure!\n') |
|
540 | 540 | > ui.flush() |
|
541 | 541 | > return 1 |
|
542 | 542 | > EOF |
|
543 | 543 | |
|
544 | 544 | $ echo "pretxnchangegroup.fail = python:$TESTTMP/failhook:hook" >> remote/.hg/hgrc |
|
545 | 545 | |
|
546 | 546 | $ hg -q --config ui.ssh="\"$PYTHON\" $TESTDIR/dummyssh" clone ssh://user@dummy/remote hookout |
|
547 | 547 | $ cd hookout |
|
548 | 548 | $ touch hookfailure |
|
549 | 549 | $ hg -q commit -A -m 'remote hook failure' |
|
550 | 550 | $ hg --config ui.ssh="\"$PYTHON\" $TESTDIR/dummyssh" push |
|
551 | 551 | pushing to ssh://user@dummy/remote |
|
552 | 552 | searching for changes |
|
553 | 553 | remote: adding changesets |
|
554 | 554 | remote: adding manifests |
|
555 | 555 | remote: adding file changes |
|
556 | 556 | remote: added 1 changesets with 1 changes to 1 files |
|
557 | 557 | remote: hook failure! |
|
558 | 558 | remote: transaction abort! |
|
559 | 559 | remote: rollback completed |
|
560 | 560 | remote: pretxnchangegroup.fail hook failed |
|
561 | 561 | abort: push failed on remote |
|
562 | 562 | [255] |
|
563 | 563 | |
|
564 | 564 | abort during pull is properly reported as such |
|
565 | 565 | |
|
566 | 566 | $ echo morefoo >> ../remote/foo |
|
567 | 567 | $ hg -R ../remote commit --message "more foo to be pulled" |
|
568 | 568 | $ cat >> ../remote/.hg/hgrc << EOF |
|
569 | 569 | > [extensions] |
|
570 | 570 | > crash = ${TESTDIR}/crashgetbundler.py |
|
571 | 571 | > EOF |
|
572 | 572 | $ hg --config ui.ssh="\"$PYTHON\" $TESTDIR/dummyssh" pull |
|
573 | 573 | pulling from ssh://user@dummy/remote |
|
574 | 574 | searching for changes |
|
575 | 575 | remote: abort: this is an exercise |
|
576 | 576 | abort: pull failed on remote |
|
577 | 577 | [255] |
@@ -1,869 +1,869 b'' | |||
|
1 | 1 | #require killdaemons |
|
2 | 2 | |
|
3 | 3 | $ cat << EOF >> $HGRCPATH |
|
4 | 4 | > [format] |
|
5 | 5 | > usegeneraldelta=yes |
|
6 | 6 | > [ui] |
|
7 | 7 | > ssh=$PYTHON "$TESTDIR/dummyssh" |
|
8 | 8 | > EOF |
|
9 | 9 | |
|
10 | 10 | Set up repo |
|
11 | 11 | |
|
12 | 12 | $ hg --config experimental.treemanifest=True init repo |
|
13 | 13 | $ cd repo |
|
14 | 14 | |
|
15 | 15 | Requirements get set on init |
|
16 | 16 | |
|
17 | 17 | $ grep treemanifest .hg/requires |
|
18 | 18 | treemanifest |
|
19 | 19 | |
|
20 | 20 | Without directories, looks like any other repo |
|
21 | 21 | |
|
22 | 22 | $ echo 0 > a |
|
23 | 23 | $ echo 0 > b |
|
24 | 24 | $ hg ci -Aqm initial |
|
25 | 25 | $ hg debugdata -m 0 |
|
26 | 26 | a\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc) |
|
27 | 27 | b\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc) |
|
28 | 28 | |
|
29 | 29 | Submanifest is stored in separate revlog |
|
30 | 30 | |
|
31 | 31 | $ mkdir dir1 |
|
32 | 32 | $ echo 1 > dir1/a |
|
33 | 33 | $ echo 1 > dir1/b |
|
34 | 34 | $ echo 1 > e |
|
35 | 35 | $ hg ci -Aqm 'add dir1' |
|
36 | 36 | $ hg debugdata -m 1 |
|
37 | 37 | a\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc) |
|
38 | 38 | b\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc) |
|
39 | 39 | dir1\x008b3ffd73f901e83304c83d33132c8e774ceac44et (esc) |
|
40 | 40 | e\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc) |
|
41 | 41 | $ hg debugdata --dir dir1 0 |
|
42 | 42 | a\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc) |
|
43 | 43 | b\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc) |
|
44 | 44 | |
|
45 | 45 | Can add nested directories |
|
46 | 46 | |
|
47 | 47 | $ mkdir dir1/dir1 |
|
48 | 48 | $ echo 2 > dir1/dir1/a |
|
49 | 49 | $ echo 2 > dir1/dir1/b |
|
50 | 50 | $ mkdir dir1/dir2 |
|
51 | 51 | $ echo 2 > dir1/dir2/a |
|
52 | 52 | $ echo 2 > dir1/dir2/b |
|
53 | 53 | $ hg ci -Aqm 'add dir1/dir1' |
|
54 | 54 | $ hg files -r . |
|
55 | 55 | a |
|
56 | 56 | b |
|
57 | 57 | dir1/a (glob) |
|
58 | 58 | dir1/b (glob) |
|
59 | 59 | dir1/dir1/a (glob) |
|
60 | 60 | dir1/dir1/b (glob) |
|
61 | 61 | dir1/dir2/a (glob) |
|
62 | 62 | dir1/dir2/b (glob) |
|
63 | 63 | e |
|
64 | 64 | |
|
65 | 65 | The manifest command works |
|
66 | 66 | |
|
67 | 67 | $ hg manifest |
|
68 | 68 | a |
|
69 | 69 | b |
|
70 | 70 | dir1/a |
|
71 | 71 | dir1/b |
|
72 | 72 | dir1/dir1/a |
|
73 | 73 | dir1/dir1/b |
|
74 | 74 | dir1/dir2/a |
|
75 | 75 | dir1/dir2/b |
|
76 | 76 | e |
|
77 | 77 | |
|
78 | 78 | Revision is not created for unchanged directory |
|
79 | 79 | |
|
80 | 80 | $ mkdir dir2 |
|
81 | 81 | $ echo 3 > dir2/a |
|
82 | 82 | $ hg add dir2 |
|
83 | 83 | adding dir2/a (glob) |
|
84 | 84 | $ hg debugindex --dir dir1 > before |
|
85 | 85 | $ hg ci -qm 'add dir2' |
|
86 | 86 | $ hg debugindex --dir dir1 > after |
|
87 | 87 | $ diff before after |
|
88 | 88 | $ rm before after |
|
89 | 89 | |
|
90 | 90 | Removing directory does not create an revlog entry |
|
91 | 91 | |
|
92 | 92 | $ hg rm dir1/dir1 |
|
93 | 93 | removing dir1/dir1/a (glob) |
|
94 | 94 | removing dir1/dir1/b (glob) |
|
95 | 95 | $ hg debugindex --dir dir1/dir1 > before |
|
96 | 96 | $ hg ci -qm 'remove dir1/dir1' |
|
97 | 97 | $ hg debugindex --dir dir1/dir1 > after |
|
98 | 98 | $ diff before after |
|
99 | 99 | $ rm before after |
|
100 | 100 | |
|
101 | 101 | Check that hg files (calls treemanifest.walk()) works |
|
102 | 102 | without loading all directory revlogs |
|
103 | 103 | |
|
104 | 104 | $ hg co 'desc("add dir2")' |
|
105 | 105 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
106 | 106 | $ mv .hg/store/meta/dir2 .hg/store/meta/dir2-backup |
|
107 | 107 | $ hg files -r . dir1 |
|
108 | 108 | dir1/a (glob) |
|
109 | 109 | dir1/b (glob) |
|
110 | 110 | dir1/dir1/a (glob) |
|
111 | 111 | dir1/dir1/b (glob) |
|
112 | 112 | dir1/dir2/a (glob) |
|
113 | 113 | dir1/dir2/b (glob) |
|
114 | 114 | |
|
115 | 115 | Check that status between revisions works (calls treemanifest.matches()) |
|
116 | 116 | without loading all directory revlogs |
|
117 | 117 | |
|
118 | 118 | $ hg status --rev 'desc("add dir1")' --rev . dir1 |
|
119 | 119 | A dir1/dir1/a |
|
120 | 120 | A dir1/dir1/b |
|
121 | 121 | A dir1/dir2/a |
|
122 | 122 | A dir1/dir2/b |
|
123 | 123 | $ mv .hg/store/meta/dir2-backup .hg/store/meta/dir2 |
|
124 | 124 | |
|
125 | 125 | Merge creates 2-parent revision of directory revlog |
|
126 | 126 | |
|
127 | 127 | $ echo 5 > dir1/a |
|
128 | 128 | $ hg ci -Aqm 'modify dir1/a' |
|
129 | 129 | $ hg co '.^' |
|
130 | 130 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
131 | 131 | $ echo 6 > dir1/b |
|
132 | 132 | $ hg ci -Aqm 'modify dir1/b' |
|
133 | 133 | $ hg merge 'desc("modify dir1/a")' |
|
134 | 134 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
135 | 135 | (branch merge, don't forget to commit) |
|
136 | 136 | $ hg ci -m 'conflict-free merge involving dir1/' |
|
137 | 137 | $ cat dir1/a |
|
138 | 138 | 5 |
|
139 | 139 | $ cat dir1/b |
|
140 | 140 | 6 |
|
141 | 141 | $ hg debugindex --dir dir1 |
|
142 | 142 | rev offset length delta linkrev nodeid p1 p2 |
|
143 | 143 | 0 0 54 -1 1 8b3ffd73f901 000000000000 000000000000 |
|
144 | 144 | 1 54 68 0 2 68e9d057c5a8 8b3ffd73f901 000000000000 |
|
145 | 145 | 2 122 12 1 4 4698198d2624 68e9d057c5a8 000000000000 |
|
146 | 146 | 3 134 55 1 5 44844058ccce 68e9d057c5a8 000000000000 |
|
147 | 147 | 4 189 55 1 6 bf3d9b744927 68e9d057c5a8 000000000000 |
|
148 | 148 | 5 244 55 4 7 dde7c0af2a03 bf3d9b744927 44844058ccce |
|
149 | 149 | |
|
150 | 150 | Merge keeping directory from parent 1 does not create revlog entry. (Note that |
|
151 | 151 | dir1's manifest does change, but only because dir1/a's filelog changes.) |
|
152 | 152 | |
|
153 | 153 | $ hg co 'desc("add dir2")' |
|
154 | 154 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
155 | 155 | $ echo 8 > dir2/a |
|
156 | 156 | $ hg ci -m 'modify dir2/a' |
|
157 | 157 | created new head |
|
158 | 158 | |
|
159 | 159 | $ hg debugindex --dir dir2 > before |
|
160 | 160 | $ hg merge 'desc("modify dir1/a")' |
|
161 | 161 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
162 | 162 | (branch merge, don't forget to commit) |
|
163 | 163 | $ hg revert -r 'desc("modify dir2/a")' . |
|
164 | 164 | reverting dir1/a (glob) |
|
165 | 165 | $ hg ci -m 'merge, keeping parent 1' |
|
166 | 166 | $ hg debugindex --dir dir2 > after |
|
167 | 167 | $ diff before after |
|
168 | 168 | $ rm before after |
|
169 | 169 | |
|
170 | 170 | Merge keeping directory from parent 2 does not create revlog entry. (Note that |
|
171 | 171 | dir2's manifest does change, but only because dir2/a's filelog changes.) |
|
172 | 172 | |
|
173 | 173 | $ hg co 'desc("modify dir2/a")' |
|
174 | 174 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
175 | 175 | $ hg debugindex --dir dir1 > before |
|
176 | 176 | $ hg merge 'desc("modify dir1/a")' |
|
177 | 177 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
178 | 178 | (branch merge, don't forget to commit) |
|
179 | 179 | $ hg revert -r 'desc("modify dir1/a")' . |
|
180 | 180 | reverting dir2/a (glob) |
|
181 | 181 | $ hg ci -m 'merge, keeping parent 2' |
|
182 | 182 | created new head |
|
183 | 183 | $ hg debugindex --dir dir1 > after |
|
184 | 184 | $ diff before after |
|
185 | 185 | $ rm before after |
|
186 | 186 | |
|
187 | 187 | Create flat source repo for tests with mixed flat/tree manifests |
|
188 | 188 | |
|
189 | 189 | $ cd .. |
|
190 | 190 | $ hg init repo-flat |
|
191 | 191 | $ cd repo-flat |
|
192 | 192 | |
|
193 | 193 | Create a few commits with flat manifest |
|
194 | 194 | |
|
195 | 195 | $ echo 0 > a |
|
196 | 196 | $ echo 0 > b |
|
197 | 197 | $ echo 0 > e |
|
198 | 198 | $ for d in dir1 dir1/dir1 dir1/dir2 dir2 |
|
199 | 199 | > do |
|
200 | 200 | > mkdir $d |
|
201 | 201 | > echo 0 > $d/a |
|
202 | 202 | > echo 0 > $d/b |
|
203 | 203 | > done |
|
204 | 204 | $ hg ci -Aqm initial |
|
205 | 205 | |
|
206 | 206 | $ echo 1 > a |
|
207 | 207 | $ echo 1 > dir1/a |
|
208 | 208 | $ echo 1 > dir1/dir1/a |
|
209 | 209 | $ hg ci -Aqm 'modify on branch 1' |
|
210 | 210 | |
|
211 | 211 | $ hg co 0 |
|
212 | 212 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
213 | 213 | $ echo 2 > b |
|
214 | 214 | $ echo 2 > dir1/b |
|
215 | 215 | $ echo 2 > dir1/dir1/b |
|
216 | 216 | $ hg ci -Aqm 'modify on branch 2' |
|
217 | 217 | |
|
218 | 218 | $ hg merge 1 |
|
219 | 219 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
220 | 220 | (branch merge, don't forget to commit) |
|
221 | 221 | $ hg ci -m 'merge of flat manifests to new flat manifest' |
|
222 | 222 | |
|
223 | 223 | $ hg serve -p $HGPORT -d --pid-file=hg.pid --errorlog=errors.log |
|
224 | 224 | $ cat hg.pid >> $DAEMON_PIDS |
|
225 | 225 | |
|
226 | 226 | Create clone with tree manifests enabled |
|
227 | 227 | |
|
228 | 228 | $ cd .. |
|
229 | 229 | $ hg clone --config experimental.treemanifest=1 \ |
|
230 | 230 | > http://localhost:$HGPORT repo-mixed -r 1 |
|
231 | 231 | adding changesets |
|
232 | 232 | adding manifests |
|
233 | 233 | adding file changes |
|
234 | 234 | added 2 changesets with 14 changes to 11 files |
|
235 | 235 | updating to branch default |
|
236 | 236 | 11 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
237 | 237 | $ cd repo-mixed |
|
238 | 238 | $ test -d .hg/store/meta |
|
239 | 239 | [1] |
|
240 | 240 | $ grep treemanifest .hg/requires |
|
241 | 241 | treemanifest |
|
242 | 242 | |
|
243 | 243 | Should be possible to push updates from flat to tree manifest repo |
|
244 | 244 | |
|
245 | 245 | $ hg -R ../repo-flat push ssh://user@dummy/repo-mixed |
|
246 | 246 | pushing to ssh://user@dummy/repo-mixed |
|
247 | 247 | searching for changes |
|
248 | 248 | remote: adding changesets |
|
249 | 249 | remote: adding manifests |
|
250 | 250 | remote: adding file changes |
|
251 | 251 | remote: added 2 changesets with 3 changes to 3 files |
|
252 | 252 | |
|
253 | 253 | Commit should store revlog per directory |
|
254 | 254 | |
|
255 | 255 | $ hg co 1 |
|
256 | 256 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
257 | 257 | $ echo 3 > a |
|
258 | 258 | $ echo 3 > dir1/a |
|
259 | 259 | $ echo 3 > dir1/dir1/a |
|
260 | 260 | $ hg ci -m 'first tree' |
|
261 | 261 | created new head |
|
262 | 262 | $ find .hg/store/meta | sort |
|
263 | 263 | .hg/store/meta |
|
264 | 264 | .hg/store/meta/dir1 |
|
265 | 265 | .hg/store/meta/dir1/00manifest.i |
|
266 | 266 | .hg/store/meta/dir1/dir1 |
|
267 | 267 | .hg/store/meta/dir1/dir1/00manifest.i |
|
268 | 268 | .hg/store/meta/dir1/dir2 |
|
269 | 269 | .hg/store/meta/dir1/dir2/00manifest.i |
|
270 | 270 | .hg/store/meta/dir2 |
|
271 | 271 | .hg/store/meta/dir2/00manifest.i |
|
272 | 272 | |
|
273 | 273 | Merge of two trees |
|
274 | 274 | |
|
275 | 275 | $ hg co 2 |
|
276 | 276 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
277 | 277 | $ hg merge 1 |
|
278 | 278 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
279 | 279 | (branch merge, don't forget to commit) |
|
280 | 280 | $ hg ci -m 'merge of flat manifests to new tree manifest' |
|
281 | 281 | created new head |
|
282 | 282 | $ hg diff -r 3 |
|
283 | 283 | |
|
284 | 284 | Parent of tree root manifest should be flat manifest, and two for merge |
|
285 | 285 | |
|
286 | 286 | $ hg debugindex -m |
|
287 | 287 | rev offset length delta linkrev nodeid p1 p2 |
|
288 | 288 | 0 0 80 -1 0 40536115ed9e 000000000000 000000000000 |
|
289 | 289 | 1 80 83 0 1 f3376063c255 40536115ed9e 000000000000 |
|
290 | 290 | 2 163 89 0 2 5d9b9da231a2 40536115ed9e 000000000000 |
|
291 | 291 | 3 252 83 2 3 d17d663cbd8a 5d9b9da231a2 f3376063c255 |
|
292 | 292 | 4 335 124 1 4 51e32a8c60ee f3376063c255 000000000000 |
|
293 | 293 | 5 459 126 2 5 cc5baa78b230 5d9b9da231a2 f3376063c255 |
|
294 | 294 | |
|
295 | 295 | |
|
296 | 296 | Status across flat/tree boundary should work |
|
297 | 297 | |
|
298 | 298 | $ hg status --rev '.^' --rev . |
|
299 | 299 | M a |
|
300 | 300 | M dir1/a |
|
301 | 301 | M dir1/dir1/a |
|
302 | 302 | |
|
303 | 303 | |
|
304 | 304 | Turning off treemanifest config has no effect |
|
305 | 305 | |
|
306 | 306 | $ hg debugindex --dir dir1 |
|
307 | 307 | rev offset length delta linkrev nodeid p1 p2 |
|
308 | 308 | 0 0 127 -1 4 064927a0648a 000000000000 000000000000 |
|
309 | 309 | 1 127 111 0 5 25ecb8cb8618 000000000000 000000000000 |
|
310 | 310 | $ echo 2 > dir1/a |
|
311 | 311 | $ hg --config experimental.treemanifest=False ci -qm 'modify dir1/a' |
|
312 | 312 | $ hg debugindex --dir dir1 |
|
313 | 313 | rev offset length delta linkrev nodeid p1 p2 |
|
314 | 314 | 0 0 127 -1 4 064927a0648a 000000000000 000000000000 |
|
315 | 315 | 1 127 111 0 5 25ecb8cb8618 000000000000 000000000000 |
|
316 | 316 | 2 238 55 1 6 5b16163a30c6 25ecb8cb8618 000000000000 |
|
317 | 317 | |
|
318 | 318 | Stripping and recovering changes should work |
|
319 | 319 | |
|
320 | 320 | $ hg st --change tip |
|
321 | 321 | M dir1/a |
|
322 | 322 | $ hg --config extensions.strip= strip tip |
|
323 | 323 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
324 | 324 | saved backup bundle to $TESTTMP/repo-mixed/.hg/strip-backup/51cfd7b1e13b-78a2f3ed-backup.hg (glob) |
|
325 | 325 | $ hg debugindex --dir dir1 |
|
326 | 326 | rev offset length delta linkrev nodeid p1 p2 |
|
327 | 327 | 0 0 127 -1 4 064927a0648a 000000000000 000000000000 |
|
328 | 328 | 1 127 111 0 5 25ecb8cb8618 000000000000 000000000000 |
|
329 | 329 | $ hg incoming .hg/strip-backup/* |
|
330 | 330 | comparing with .hg/strip-backup/*-backup.hg (glob) |
|
331 | 331 | searching for changes |
|
332 | 332 | changeset: 6:51cfd7b1e13b |
|
333 | 333 | tag: tip |
|
334 | 334 | user: test |
|
335 | 335 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
336 | 336 | summary: modify dir1/a |
|
337 | 337 | |
|
338 | 338 | $ hg pull .hg/strip-backup/* |
|
339 | 339 | pulling from .hg/strip-backup/51cfd7b1e13b-78a2f3ed-backup.hg |
|
340 | 340 | searching for changes |
|
341 | 341 | adding changesets |
|
342 | 342 | adding manifests |
|
343 | 343 | adding file changes |
|
344 | 344 | added 1 changesets with 1 changes to 1 files |
|
345 | 345 | (run 'hg update' to get a working copy) |
|
346 | 346 | $ hg --config extensions.strip= strip tip |
|
347 | 347 | saved backup bundle to $TESTTMP/repo-mixed/.hg/strip-backup/*-backup.hg (glob) |
|
348 | 348 | $ hg unbundle -q .hg/strip-backup/* |
|
349 | 349 | $ hg debugindex --dir dir1 |
|
350 | 350 | rev offset length delta linkrev nodeid p1 p2 |
|
351 | 351 | 0 0 127 -1 4 064927a0648a 000000000000 000000000000 |
|
352 | 352 | 1 127 111 0 5 25ecb8cb8618 000000000000 000000000000 |
|
353 | 353 | 2 238 55 1 6 5b16163a30c6 25ecb8cb8618 000000000000 |
|
354 | 354 | $ hg st --change tip |
|
355 | 355 | M dir1/a |
|
356 | 356 | |
|
357 | 357 | Shelving and unshelving should work |
|
358 | 358 | |
|
359 | 359 | $ echo foo >> dir1/a |
|
360 | 360 | $ hg --config extensions.shelve= shelve |
|
361 | 361 | shelved as default |
|
362 | 362 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
363 | 363 | $ hg --config extensions.shelve= unshelve |
|
364 | 364 | unshelving change 'default' |
|
365 | 365 | $ hg diff --nodates |
|
366 | 366 | diff -r 708a273da119 dir1/a |
|
367 | 367 | --- a/dir1/a |
|
368 | 368 | +++ b/dir1/a |
|
369 | 369 | @@ -1,1 +1,2 @@ |
|
370 | 370 | 1 |
|
371 | 371 | +foo |
|
372 | 372 | |
|
373 | 373 | Pushing from treemanifest repo to an empty repo makes that a treemanifest repo |
|
374 | 374 | |
|
375 | 375 | $ cd .. |
|
376 | 376 | $ hg init empty-repo |
|
377 | 377 | $ cat << EOF >> empty-repo/.hg/hgrc |
|
378 | 378 | > [experimental] |
|
379 | 379 | > changegroup3=yes |
|
380 | 380 | > EOF |
|
381 | 381 | $ grep treemanifest empty-repo/.hg/requires |
|
382 | 382 | [1] |
|
383 | 383 | $ hg push -R repo -r 0 empty-repo |
|
384 | 384 | pushing to empty-repo |
|
385 | 385 | searching for changes |
|
386 | 386 | adding changesets |
|
387 | 387 | adding manifests |
|
388 | 388 | adding file changes |
|
389 | 389 | added 1 changesets with 2 changes to 2 files |
|
390 | 390 | $ grep treemanifest empty-repo/.hg/requires |
|
391 | 391 | treemanifest |
|
392 | 392 | |
|
393 | 393 | Pushing to an empty repo works |
|
394 | 394 | |
|
395 | 395 | $ hg --config experimental.treemanifest=1 init clone |
|
396 | 396 | $ grep treemanifest clone/.hg/requires |
|
397 | 397 | treemanifest |
|
398 | 398 | $ hg push -R repo clone |
|
399 | 399 | pushing to clone |
|
400 | 400 | searching for changes |
|
401 | 401 | adding changesets |
|
402 | 402 | adding manifests |
|
403 | 403 | adding file changes |
|
404 | 404 | added 11 changesets with 15 changes to 10 files (+3 heads) |
|
405 | 405 | $ grep treemanifest clone/.hg/requires |
|
406 | 406 | treemanifest |
|
407 | 407 | $ hg -R clone verify |
|
408 | 408 | checking changesets |
|
409 | 409 | checking manifests |
|
410 | 410 | checking directory manifests |
|
411 | 411 | crosschecking files in changesets and manifests |
|
412 | 412 | checking files |
|
413 | 413 | 10 files, 11 changesets, 15 total revisions |
|
414 | 414 | |
|
415 | 415 | Create deeper repo with tree manifests. |
|
416 | 416 | |
|
417 | 417 | $ hg --config experimental.treemanifest=True init deeprepo |
|
418 | 418 | $ cd deeprepo |
|
419 | 419 | |
|
420 | 420 | $ mkdir .A |
|
421 | 421 | $ mkdir b |
|
422 | 422 | $ mkdir b/bar |
|
423 | 423 | $ mkdir b/bar/orange |
|
424 | 424 | $ mkdir b/bar/orange/fly |
|
425 | 425 | $ mkdir b/foo |
|
426 | 426 | $ mkdir b/foo/apple |
|
427 | 427 | $ mkdir b/foo/apple/bees |
|
428 | 428 | |
|
429 | 429 | $ touch .A/one.txt |
|
430 | 430 | $ touch .A/two.txt |
|
431 | 431 | $ touch b/bar/fruits.txt |
|
432 | 432 | $ touch b/bar/orange/fly/gnat.py |
|
433 | 433 | $ touch b/bar/orange/fly/housefly.txt |
|
434 | 434 | $ touch b/foo/apple/bees/flower.py |
|
435 | 435 | $ touch c.txt |
|
436 | 436 | $ touch d.py |
|
437 | 437 | |
|
438 | 438 | $ hg ci -Aqm 'initial' |
|
439 | 439 | |
|
440 | 440 | $ echo >> .A/one.txt |
|
441 | 441 | $ echo >> .A/two.txt |
|
442 | 442 | $ echo >> b/bar/fruits.txt |
|
443 | 443 | $ echo >> b/bar/orange/fly/gnat.py |
|
444 | 444 | $ echo >> b/bar/orange/fly/housefly.txt |
|
445 | 445 | $ echo >> b/foo/apple/bees/flower.py |
|
446 | 446 | $ echo >> c.txt |
|
447 | 447 | $ echo >> d.py |
|
448 | 448 | $ hg ci -Aqm 'second' |
|
449 | 449 | |
|
450 | 450 | We'll see that visitdir works by removing some treemanifest revlogs and running |
|
451 | 451 | the files command with various parameters. |
|
452 | 452 | |
|
453 | 453 | Test files from the root. |
|
454 | 454 | |
|
455 | 455 | $ hg files -r . |
|
456 | 456 | .A/one.txt (glob) |
|
457 | 457 | .A/two.txt (glob) |
|
458 | 458 | b/bar/fruits.txt (glob) |
|
459 | 459 | b/bar/orange/fly/gnat.py (glob) |
|
460 | 460 | b/bar/orange/fly/housefly.txt (glob) |
|
461 | 461 | b/foo/apple/bees/flower.py (glob) |
|
462 | 462 | c.txt |
|
463 | 463 | d.py |
|
464 | 464 | |
|
465 | 465 | Excludes with a glob should not exclude everything from the glob's root |
|
466 | 466 | |
|
467 | 467 | $ hg files -r . -X 'b/fo?' b |
|
468 | 468 | b/bar/fruits.txt (glob) |
|
469 | 469 | b/bar/orange/fly/gnat.py (glob) |
|
470 | 470 | b/bar/orange/fly/housefly.txt (glob) |
|
471 | 471 | $ cp -R .hg/store .hg/store-copy |
|
472 | 472 | |
|
473 | 473 | Test files for a subdirectory. |
|
474 | 474 | |
|
475 | 475 | $ rm -r .hg/store/meta/~2e_a |
|
476 | 476 | $ hg files -r . b |
|
477 | 477 | b/bar/fruits.txt (glob) |
|
478 | 478 | b/bar/orange/fly/gnat.py (glob) |
|
479 | 479 | b/bar/orange/fly/housefly.txt (glob) |
|
480 | 480 | b/foo/apple/bees/flower.py (glob) |
|
481 | 481 | $ hg diff -r '.^' -r . --stat b |
|
482 | 482 | b/bar/fruits.txt | 1 + |
|
483 | 483 | b/bar/orange/fly/gnat.py | 1 + |
|
484 | 484 | b/bar/orange/fly/housefly.txt | 1 + |
|
485 | 485 | b/foo/apple/bees/flower.py | 1 + |
|
486 | 486 | 4 files changed, 4 insertions(+), 0 deletions(-) |
|
487 | 487 | $ cp -R .hg/store-copy/. .hg/store |
|
488 | 488 | |
|
489 | 489 | Test files with just includes and excludes. |
|
490 | 490 | |
|
491 | 491 | $ rm -r .hg/store/meta/~2e_a |
|
492 | 492 | $ rm -r .hg/store/meta/b/bar/orange/fly |
|
493 | 493 | $ rm -r .hg/store/meta/b/foo/apple/bees |
|
494 | 494 | $ hg files -r . -I path:b/bar -X path:b/bar/orange/fly -I path:b/foo -X path:b/foo/apple/bees |
|
495 | 495 | b/bar/fruits.txt (glob) |
|
496 | 496 | $ hg diff -r '.^' -r . --stat -I path:b/bar -X path:b/bar/orange/fly -I path:b/foo -X path:b/foo/apple/bees |
|
497 | 497 | b/bar/fruits.txt | 1 + |
|
498 | 498 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
499 | 499 | $ cp -R .hg/store-copy/. .hg/store |
|
500 | 500 | |
|
501 | 501 | Test files for a subdirectory, excluding a directory within it. |
|
502 | 502 | |
|
503 | 503 | $ rm -r .hg/store/meta/~2e_a |
|
504 | 504 | $ rm -r .hg/store/meta/b/foo |
|
505 | 505 | $ hg files -r . -X path:b/foo b |
|
506 | 506 | b/bar/fruits.txt (glob) |
|
507 | 507 | b/bar/orange/fly/gnat.py (glob) |
|
508 | 508 | b/bar/orange/fly/housefly.txt (glob) |
|
509 | 509 | $ hg diff -r '.^' -r . --stat -X path:b/foo b |
|
510 | 510 | b/bar/fruits.txt | 1 + |
|
511 | 511 | b/bar/orange/fly/gnat.py | 1 + |
|
512 | 512 | b/bar/orange/fly/housefly.txt | 1 + |
|
513 | 513 | 3 files changed, 3 insertions(+), 0 deletions(-) |
|
514 | 514 | $ cp -R .hg/store-copy/. .hg/store |
|
515 | 515 | |
|
516 | 516 | Test files for a sub directory, including only a directory within it, and |
|
517 | 517 | including an unrelated directory. |
|
518 | 518 | |
|
519 | 519 | $ rm -r .hg/store/meta/~2e_a |
|
520 | 520 | $ rm -r .hg/store/meta/b/foo |
|
521 | 521 | $ hg files -r . -I path:b/bar/orange -I path:a b |
|
522 | 522 | b/bar/orange/fly/gnat.py (glob) |
|
523 | 523 | b/bar/orange/fly/housefly.txt (glob) |
|
524 | 524 | $ hg diff -r '.^' -r . --stat -I path:b/bar/orange -I path:a b |
|
525 | 525 | b/bar/orange/fly/gnat.py | 1 + |
|
526 | 526 | b/bar/orange/fly/housefly.txt | 1 + |
|
527 | 527 | 2 files changed, 2 insertions(+), 0 deletions(-) |
|
528 | 528 | $ cp -R .hg/store-copy/. .hg/store |
|
529 | 529 | |
|
530 | 530 | Test files for a pattern, including a directory, and excluding a directory |
|
531 | 531 | within that. |
|
532 | 532 | |
|
533 | 533 | $ rm -r .hg/store/meta/~2e_a |
|
534 | 534 | $ rm -r .hg/store/meta/b/foo |
|
535 | 535 | $ rm -r .hg/store/meta/b/bar/orange |
|
536 | 536 | $ hg files -r . glob:**.txt -I path:b/bar -X path:b/bar/orange |
|
537 | 537 | b/bar/fruits.txt (glob) |
|
538 | 538 | $ hg diff -r '.^' -r . --stat glob:**.txt -I path:b/bar -X path:b/bar/orange |
|
539 | 539 | b/bar/fruits.txt | 1 + |
|
540 | 540 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
541 | 541 | $ cp -R .hg/store-copy/. .hg/store |
|
542 | 542 | |
|
543 | 543 | Add some more changes to the deep repo |
|
544 | 544 | $ echo narf >> b/bar/fruits.txt |
|
545 | 545 | $ hg ci -m narf |
|
546 | 546 | $ echo troz >> b/bar/orange/fly/gnat.py |
|
547 | 547 | $ hg ci -m troz |
|
548 | 548 | |
|
549 | 549 | Verify works |
|
550 | 550 | $ hg verify |
|
551 | 551 | checking changesets |
|
552 | 552 | checking manifests |
|
553 | 553 | checking directory manifests |
|
554 | 554 | crosschecking files in changesets and manifests |
|
555 | 555 | checking files |
|
556 | 556 | 8 files, 4 changesets, 18 total revisions |
|
557 | 557 | |
|
558 | 558 | Dirlogs are included in fncache |
|
559 | 559 | $ grep meta/.A/00manifest.i .hg/store/fncache |
|
560 | 560 | meta/.A/00manifest.i |
|
561 | 561 | |
|
562 | 562 | Rebuilt fncache includes dirlogs |
|
563 | 563 | $ rm .hg/store/fncache |
|
564 | 564 | $ hg debugrebuildfncache |
|
565 | 565 | adding data/.A/one.txt.i |
|
566 | 566 | adding data/.A/two.txt.i |
|
567 | 567 | adding data/b/bar/fruits.txt.i |
|
568 | 568 | adding data/b/bar/orange/fly/gnat.py.i |
|
569 | 569 | adding data/b/bar/orange/fly/housefly.txt.i |
|
570 | 570 | adding data/b/foo/apple/bees/flower.py.i |
|
571 | 571 | adding data/c.txt.i |
|
572 | 572 | adding data/d.py.i |
|
573 | 573 | adding meta/.A/00manifest.i |
|
574 | 574 | adding meta/b/00manifest.i |
|
575 | 575 | adding meta/b/bar/00manifest.i |
|
576 | 576 | adding meta/b/bar/orange/00manifest.i |
|
577 | 577 | adding meta/b/bar/orange/fly/00manifest.i |
|
578 | 578 | adding meta/b/foo/00manifest.i |
|
579 | 579 | adding meta/b/foo/apple/00manifest.i |
|
580 | 580 | adding meta/b/foo/apple/bees/00manifest.i |
|
581 | 581 | 16 items added, 0 removed from fncache |
|
582 | 582 | |
|
583 | 583 | Finish first server |
|
584 | 584 | $ killdaemons.py |
|
585 | 585 | |
|
586 | 586 | Back up the recently added revlogs |
|
587 | 587 | $ cp -R .hg/store .hg/store-newcopy |
|
588 | 588 | |
|
589 | 589 | Verify reports missing dirlog |
|
590 | 590 | $ rm .hg/store/meta/b/00manifest.* |
|
591 | 591 | $ hg verify |
|
592 | 592 | checking changesets |
|
593 | 593 | checking manifests |
|
594 | 594 | checking directory manifests |
|
595 | 595 | 0: empty or missing b/ |
|
596 | 596 | b/@0: parent-directory manifest refers to unknown revision 67688a370455 |
|
597 | 597 | b/@1: parent-directory manifest refers to unknown revision f065da70369e |
|
598 | 598 | b/@2: parent-directory manifest refers to unknown revision ac0d30948e0b |
|
599 | 599 | b/@3: parent-directory manifest refers to unknown revision 367152e6af28 |
|
600 | 600 | warning: orphan revlog 'meta/b/bar/00manifest.i' |
|
601 | 601 | warning: orphan revlog 'meta/b/bar/orange/00manifest.i' |
|
602 | 602 | warning: orphan revlog 'meta/b/bar/orange/fly/00manifest.i' |
|
603 | 603 | warning: orphan revlog 'meta/b/foo/00manifest.i' |
|
604 | 604 | warning: orphan revlog 'meta/b/foo/apple/00manifest.i' |
|
605 | 605 | warning: orphan revlog 'meta/b/foo/apple/bees/00manifest.i' |
|
606 | 606 | crosschecking files in changesets and manifests |
|
607 | 607 | b/bar/fruits.txt@0: in changeset but not in manifest |
|
608 | 608 | b/bar/orange/fly/gnat.py@0: in changeset but not in manifest |
|
609 | 609 | b/bar/orange/fly/housefly.txt@0: in changeset but not in manifest |
|
610 | 610 | b/foo/apple/bees/flower.py@0: in changeset but not in manifest |
|
611 | 611 | checking files |
|
612 | 612 | 8 files, 4 changesets, 18 total revisions |
|
613 | 613 | 6 warnings encountered! |
|
614 | 614 | 9 integrity errors encountered! |
|
615 | 615 | (first damaged changeset appears to be 0) |
|
616 | 616 | [1] |
|
617 | 617 | $ cp -R .hg/store-newcopy/. .hg/store |
|
618 | 618 | |
|
619 | 619 | Verify reports missing dirlog entry |
|
620 | 620 | $ mv -f .hg/store-copy/meta/b/00manifest.* .hg/store/meta/b/ |
|
621 | 621 | $ hg verify |
|
622 | 622 | checking changesets |
|
623 | 623 | checking manifests |
|
624 | 624 | checking directory manifests |
|
625 | 625 | b/@2: parent-directory manifest refers to unknown revision ac0d30948e0b |
|
626 | 626 | b/@3: parent-directory manifest refers to unknown revision 367152e6af28 |
|
627 | 627 | b/bar/@?: rev 2 points to unexpected changeset 2 |
|
628 | 628 | b/bar/@?: 44d7e1146e0d not in parent-directory manifest |
|
629 | 629 | b/bar/@?: rev 3 points to unexpected changeset 3 |
|
630 | 630 | b/bar/@?: 70b10c6b17b7 not in parent-directory manifest |
|
631 | 631 | b/bar/orange/@?: rev 2 points to unexpected changeset 3 |
|
632 | 632 | (expected None) |
|
633 | 633 | b/bar/orange/fly/@?: rev 2 points to unexpected changeset 3 |
|
634 | 634 | (expected None) |
|
635 | 635 | crosschecking files in changesets and manifests |
|
636 | 636 | checking files |
|
637 | 637 | 8 files, 4 changesets, 18 total revisions |
|
638 | 638 | 2 warnings encountered! |
|
639 | 639 | 8 integrity errors encountered! |
|
640 | 640 | (first damaged changeset appears to be 2) |
|
641 | 641 | [1] |
|
642 | 642 | $ cp -R .hg/store-newcopy/. .hg/store |
|
643 | 643 | |
|
644 | 644 | Test cloning a treemanifest repo over http. |
|
645 | 645 | $ hg serve -p $HGPORT -d --pid-file=hg.pid --errorlog=errors.log |
|
646 | 646 | $ cat hg.pid >> $DAEMON_PIDS |
|
647 | 647 | $ cd .. |
|
648 | 648 | We can clone even with the knob turned off and we'll get a treemanifest repo. |
|
649 | 649 | $ hg clone --config experimental.treemanifest=False \ |
|
650 | 650 | > --config experimental.changegroup3=True \ |
|
651 | 651 | > http://localhost:$HGPORT deepclone |
|
652 | 652 | requesting all changes |
|
653 | 653 | adding changesets |
|
654 | 654 | adding manifests |
|
655 | 655 | adding file changes |
|
656 | 656 | added 4 changesets with 18 changes to 8 files |
|
657 | 657 | updating to branch default |
|
658 | 658 | 8 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
659 | 659 | No server errors. |
|
660 | 660 | $ cat deeprepo/errors.log |
|
661 | 661 | requires got updated to include treemanifest |
|
662 | 662 | $ cat deepclone/.hg/requires | grep treemanifest |
|
663 | 663 | treemanifest |
|
664 | 664 | Tree manifest revlogs exist. |
|
665 | 665 | $ find deepclone/.hg/store/meta | sort |
|
666 | 666 | deepclone/.hg/store/meta |
|
667 | 667 | deepclone/.hg/store/meta/b |
|
668 | 668 | deepclone/.hg/store/meta/b/00manifest.i |
|
669 | 669 | deepclone/.hg/store/meta/b/bar |
|
670 | 670 | deepclone/.hg/store/meta/b/bar/00manifest.i |
|
671 | 671 | deepclone/.hg/store/meta/b/bar/orange |
|
672 | 672 | deepclone/.hg/store/meta/b/bar/orange/00manifest.i |
|
673 | 673 | deepclone/.hg/store/meta/b/bar/orange/fly |
|
674 | 674 | deepclone/.hg/store/meta/b/bar/orange/fly/00manifest.i |
|
675 | 675 | deepclone/.hg/store/meta/b/foo |
|
676 | 676 | deepclone/.hg/store/meta/b/foo/00manifest.i |
|
677 | 677 | deepclone/.hg/store/meta/b/foo/apple |
|
678 | 678 | deepclone/.hg/store/meta/b/foo/apple/00manifest.i |
|
679 | 679 | deepclone/.hg/store/meta/b/foo/apple/bees |
|
680 | 680 | deepclone/.hg/store/meta/b/foo/apple/bees/00manifest.i |
|
681 | 681 | deepclone/.hg/store/meta/~2e_a |
|
682 | 682 | deepclone/.hg/store/meta/~2e_a/00manifest.i |
|
683 | 683 | Verify passes. |
|
684 | 684 | $ cd deepclone |
|
685 | 685 | $ hg verify |
|
686 | 686 | checking changesets |
|
687 | 687 | checking manifests |
|
688 | 688 | checking directory manifests |
|
689 | 689 | crosschecking files in changesets and manifests |
|
690 | 690 | checking files |
|
691 | 691 | 8 files, 4 changesets, 18 total revisions |
|
692 | 692 | $ cd .. |
|
693 | 693 | |
|
694 | 694 | Create clones using old repo formats to use in later tests |
|
695 | 695 | $ hg clone --config format.usestore=False \ |
|
696 | 696 | > --config experimental.changegroup3=True \ |
|
697 | 697 | > http://localhost:$HGPORT deeprepo-basicstore |
|
698 | 698 | requesting all changes |
|
699 | 699 | adding changesets |
|
700 | 700 | adding manifests |
|
701 | 701 | adding file changes |
|
702 | 702 | added 4 changesets with 18 changes to 8 files |
|
703 | 703 | updating to branch default |
|
704 | 704 | 8 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
705 | 705 | $ cd deeprepo-basicstore |
|
706 | 706 | $ grep store .hg/requires |
|
707 | 707 | [1] |
|
708 | 708 | $ hg serve -p $HGPORT1 -d --pid-file=hg.pid --errorlog=errors.log |
|
709 | 709 | $ cat hg.pid >> $DAEMON_PIDS |
|
710 | 710 | $ cd .. |
|
711 | 711 | $ hg clone --config format.usefncache=False \ |
|
712 | 712 | > --config experimental.changegroup3=True \ |
|
713 | 713 | > http://localhost:$HGPORT deeprepo-encodedstore |
|
714 | 714 | requesting all changes |
|
715 | 715 | adding changesets |
|
716 | 716 | adding manifests |
|
717 | 717 | adding file changes |
|
718 | 718 | added 4 changesets with 18 changes to 8 files |
|
719 | 719 | updating to branch default |
|
720 | 720 | 8 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
721 | 721 | $ cd deeprepo-encodedstore |
|
722 | 722 | $ grep fncache .hg/requires |
|
723 | 723 | [1] |
|
724 | 724 | $ hg serve -p $HGPORT2 -d --pid-file=hg.pid --errorlog=errors.log |
|
725 | 725 | $ cat hg.pid >> $DAEMON_PIDS |
|
726 | 726 | $ cd .. |
|
727 | 727 | |
|
728 | 728 | Local clone with basicstore |
|
729 | 729 | $ hg clone -U deeprepo-basicstore local-clone-basicstore |
|
730 | 730 | $ hg -R local-clone-basicstore verify |
|
731 | 731 | checking changesets |
|
732 | 732 | checking manifests |
|
733 | 733 | checking directory manifests |
|
734 | 734 | crosschecking files in changesets and manifests |
|
735 | 735 | checking files |
|
736 | 736 | 8 files, 4 changesets, 18 total revisions |
|
737 | 737 | |
|
738 | 738 | Local clone with encodedstore |
|
739 | 739 | $ hg clone -U deeprepo-encodedstore local-clone-encodedstore |
|
740 | 740 | $ hg -R local-clone-encodedstore verify |
|
741 | 741 | checking changesets |
|
742 | 742 | checking manifests |
|
743 | 743 | checking directory manifests |
|
744 | 744 | crosschecking files in changesets and manifests |
|
745 | 745 | checking files |
|
746 | 746 | 8 files, 4 changesets, 18 total revisions |
|
747 | 747 | |
|
748 | 748 | Local clone with fncachestore |
|
749 | 749 | $ hg clone -U deeprepo local-clone-fncachestore |
|
750 | 750 | $ hg -R local-clone-fncachestore verify |
|
751 | 751 | checking changesets |
|
752 | 752 | checking manifests |
|
753 | 753 | checking directory manifests |
|
754 | 754 | crosschecking files in changesets and manifests |
|
755 | 755 | checking files |
|
756 | 756 | 8 files, 4 changesets, 18 total revisions |
|
757 | 757 | |
|
758 | 758 | Stream clone with basicstore |
|
759 |
$ hg clone --config experimental.changegroup3=True -- |
|
|
759 | $ hg clone --config experimental.changegroup3=True --stream -U \ | |
|
760 | 760 | > http://localhost:$HGPORT1 stream-clone-basicstore |
|
761 | 761 | streaming all changes |
|
762 | 762 | 18 files to transfer, * of data (glob) |
|
763 | 763 | transferred * in * seconds (*) (glob) |
|
764 | 764 | searching for changes |
|
765 | 765 | no changes found |
|
766 | 766 | $ hg -R stream-clone-basicstore verify |
|
767 | 767 | checking changesets |
|
768 | 768 | checking manifests |
|
769 | 769 | checking directory manifests |
|
770 | 770 | crosschecking files in changesets and manifests |
|
771 | 771 | checking files |
|
772 | 772 | 8 files, 4 changesets, 18 total revisions |
|
773 | 773 | |
|
774 | 774 | Stream clone with encodedstore |
|
775 |
$ hg clone --config experimental.changegroup3=True -- |
|
|
775 | $ hg clone --config experimental.changegroup3=True --stream -U \ | |
|
776 | 776 | > http://localhost:$HGPORT2 stream-clone-encodedstore |
|
777 | 777 | streaming all changes |
|
778 | 778 | 18 files to transfer, * of data (glob) |
|
779 | 779 | transferred * in * seconds (*) (glob) |
|
780 | 780 | searching for changes |
|
781 | 781 | no changes found |
|
782 | 782 | $ hg -R stream-clone-encodedstore verify |
|
783 | 783 | checking changesets |
|
784 | 784 | checking manifests |
|
785 | 785 | checking directory manifests |
|
786 | 786 | crosschecking files in changesets and manifests |
|
787 | 787 | checking files |
|
788 | 788 | 8 files, 4 changesets, 18 total revisions |
|
789 | 789 | |
|
790 | 790 | Stream clone with fncachestore |
|
791 |
$ hg clone --config experimental.changegroup3=True -- |
|
|
791 | $ hg clone --config experimental.changegroup3=True --stream -U \ | |
|
792 | 792 | > http://localhost:$HGPORT stream-clone-fncachestore |
|
793 | 793 | streaming all changes |
|
794 | 794 | 18 files to transfer, * of data (glob) |
|
795 | 795 | transferred * in * seconds (*) (glob) |
|
796 | 796 | searching for changes |
|
797 | 797 | no changes found |
|
798 | 798 | $ hg -R stream-clone-fncachestore verify |
|
799 | 799 | checking changesets |
|
800 | 800 | checking manifests |
|
801 | 801 | checking directory manifests |
|
802 | 802 | crosschecking files in changesets and manifests |
|
803 | 803 | checking files |
|
804 | 804 | 8 files, 4 changesets, 18 total revisions |
|
805 | 805 | |
|
806 | 806 | Packed bundle |
|
807 | 807 | $ hg -R deeprepo debugcreatestreamclonebundle repo-packed.hg |
|
808 | 808 | writing 5330 bytes for 18 files |
|
809 | 809 | bundle requirements: generaldelta, revlogv1, treemanifest |
|
810 | 810 | $ hg debugbundle --spec repo-packed.hg |
|
811 | 811 | none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Ctreemanifest |
|
812 | 812 | |
|
813 | 813 | Bundle with changegroup2 is not supported |
|
814 | 814 | |
|
815 | 815 | $ hg -R deeprepo bundle --all -t v2 deeprepo.bundle |
|
816 | 816 | abort: repository does not support bundle version 02 |
|
817 | 817 | [255] |
|
818 | 818 | |
|
819 | 819 | Pull does not include changegroup for manifest the client already has from |
|
820 | 820 | other branch |
|
821 | 821 | |
|
822 | 822 | $ mkdir grafted-dir-repo |
|
823 | 823 | $ cd grafted-dir-repo |
|
824 | 824 | $ hg --config experimental.treemanifest=1 init |
|
825 | 825 | $ mkdir dir |
|
826 | 826 | $ echo a > dir/file |
|
827 | 827 | $ echo a > file |
|
828 | 828 | $ hg ci -Am initial |
|
829 | 829 | adding dir/file |
|
830 | 830 | adding file |
|
831 | 831 | $ echo b > dir/file |
|
832 | 832 | $ hg ci -m updated |
|
833 | 833 | $ hg co '.^' |
|
834 | 834 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
835 | 835 | $ hg revert -r tip dir/ |
|
836 | 836 | reverting dir/file (glob) |
|
837 | 837 | $ echo b > file # to make sure root manifest is sent |
|
838 | 838 | $ hg ci -m grafted |
|
839 | 839 | created new head |
|
840 | 840 | $ cd .. |
|
841 | 841 | |
|
842 | 842 | $ hg --config experimental.treemanifest=1 clone --pull -r 1 \ |
|
843 | 843 | > grafted-dir-repo grafted-dir-repo-clone |
|
844 | 844 | adding changesets |
|
845 | 845 | adding manifests |
|
846 | 846 | adding file changes |
|
847 | 847 | added 2 changesets with 3 changes to 2 files |
|
848 | 848 | updating to branch default |
|
849 | 849 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
850 | 850 | $ cd grafted-dir-repo-clone |
|
851 | 851 | $ hg pull -r 2 |
|
852 | 852 | pulling from $TESTTMP/grafted-dir-repo (glob) |
|
853 | 853 | searching for changes |
|
854 | 854 | adding changesets |
|
855 | 855 | adding manifests |
|
856 | 856 | adding file changes |
|
857 | 857 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
858 | 858 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
859 | 859 | |
|
860 | 860 | Committing a empty commit does not duplicate root treemanifest |
|
861 | 861 | $ echo z >> z |
|
862 | 862 | $ hg commit -Aqm 'pre-empty commit' |
|
863 | 863 | $ hg rm z |
|
864 | 864 | $ hg commit --amend -m 'empty commit' |
|
865 | 865 | saved backup bundle to $TESTTMP/grafted-dir-repo-clone/.hg/strip-backup/cb99d5717cea-9e3b6b02-amend.hg (glob) |
|
866 | 866 | $ hg log -r 'tip + tip^' -T '{manifest}\n' |
|
867 | 867 | 1:678d3574b88c |
|
868 | 868 | 1:678d3574b88c |
|
869 | 869 | $ hg --config extensions.strip= strip -r . -q |
General Comments 0
You need to be logged in to leave comments.
Login now