Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 24803:e89f909edffa stable 3.4-rc
merge default into stable for 3.4 freeze
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 16 Apr 2015 20:57:51 -0500 |
parents | 077683371b7b |
children | 22c70c08d4af |
comparison
equal
deleted
inserted
replaced
24753:612ed41ae359 | 24803:e89f909edffa |
---|---|
146 ('', 'reverse', None, _('produce a diff that undoes the changes')), | 146 ('', 'reverse', None, _('produce a diff that undoes the changes')), |
147 ] + diffwsopts + [ | 147 ] + diffwsopts + [ |
148 ('U', 'unified', '', | 148 ('U', 'unified', '', |
149 _('number of lines of context to show'), _('NUM')), | 149 _('number of lines of context to show'), _('NUM')), |
150 ('', 'stat', None, _('output diffstat-style summary of changes')), | 150 ('', 'stat', None, _('output diffstat-style summary of changes')), |
151 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')), | |
151 ] | 152 ] |
152 | 153 |
153 mergetoolopts = [ | 154 mergetoolopts = [ |
154 ('t', 'tool', '', _('specify merge tool')), | 155 ('t', 'tool', '', _('specify merge tool')), |
155 ] | 156 ] |
274 if opts.get('follow'): | 275 if opts.get('follow'): |
275 # --follow is deprecated and now just an alias for -f/--file | 276 # --follow is deprecated and now just an alias for -f/--file |
276 # to mimic the behavior of Mercurial before version 1.5 | 277 # to mimic the behavior of Mercurial before version 1.5 |
277 opts['file'] = True | 278 opts['file'] = True |
278 | 279 |
280 ctx = scmutil.revsingle(repo, opts.get('rev')) | |
281 | |
279 fm = ui.formatter('annotate', opts) | 282 fm = ui.formatter('annotate', opts) |
280 datefunc = ui.quiet and util.shortdate or util.datestr | 283 if ui.quiet: |
281 hexfn = fm.hexfunc | 284 datefunc = util.shortdate |
285 else: | |
286 datefunc = util.datestr | |
287 if ctx.rev() is None: | |
288 def hexfn(node): | |
289 if node is None: | |
290 return None | |
291 else: | |
292 return fm.hexfunc(node) | |
293 if opts.get('changeset'): | |
294 # omit "+" suffix which is appended to node hex | |
295 def formatrev(rev): | |
296 if rev is None: | |
297 return '%d' % ctx.p1().rev() | |
298 else: | |
299 return '%d' % rev | |
300 else: | |
301 def formatrev(rev): | |
302 if rev is None: | |
303 return '%d+' % ctx.p1().rev() | |
304 else: | |
305 return '%d ' % rev | |
306 def formathex(hex): | |
307 if hex is None: | |
308 return '%s+' % fm.hexfunc(ctx.p1().node()) | |
309 else: | |
310 return '%s ' % hex | |
311 else: | |
312 hexfn = fm.hexfunc | |
313 formatrev = formathex = str | |
282 | 314 |
283 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), | 315 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), |
284 ('number', ' ', lambda x: x[0].rev(), str), | 316 ('number', ' ', lambda x: x[0].rev(), formatrev), |
285 ('changeset', ' ', lambda x: hexfn(x[0].node()), str), | 317 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex), |
286 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)), | 318 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)), |
287 ('file', ' ', lambda x: x[0].path(), str), | 319 ('file', ' ', lambda x: x[0].path(), str), |
288 ('line_number', ':', lambda x: x[1], str), | 320 ('line_number', ':', lambda x: x[1], str), |
289 ] | 321 ] |
290 fieldnamemap = {'number': 'rev', 'changeset': 'node'} | 322 fieldnamemap = {'number': 'rev', 'changeset': 'node'} |
310 if opts.get(op)) | 342 if opts.get(op)) |
311 | 343 |
312 def bad(x, y): | 344 def bad(x, y): |
313 raise util.Abort("%s: %s" % (x, y)) | 345 raise util.Abort("%s: %s" % (x, y)) |
314 | 346 |
315 ctx = scmutil.revsingle(repo, opts.get('rev')) | |
316 m = scmutil.match(ctx, pats, opts) | 347 m = scmutil.match(ctx, pats, opts) |
317 m.bad = bad | 348 m.bad = bad |
318 follow = not opts.get('no_follow') | 349 follow = not opts.get('no_follow') |
319 diffopts = patch.difffeatureopts(ui, opts, section='annotate', | 350 diffopts = patch.difffeatureopts(ui, opts, section='annotate', |
320 whitespace=True) | 351 whitespace=True) |
662 def extendbisectrange(nodes, good): | 693 def extendbisectrange(nodes, good): |
663 # bisect is incomplete when it ends on a merge node and | 694 # bisect is incomplete when it ends on a merge node and |
664 # one of the parent was not checked. | 695 # one of the parent was not checked. |
665 parents = repo[nodes[0]].parents() | 696 parents = repo[nodes[0]].parents() |
666 if len(parents) > 1: | 697 if len(parents) > 1: |
667 side = good and state['bad'] or state['good'] | 698 if good: |
699 side = state['bad'] | |
700 else: | |
701 side = state['good'] | |
668 num = len(set(i.node() for i in parents) & set(side)) | 702 num = len(set(i.node() for i in parents) & set(side)) |
669 if num == 1: | 703 if num == 1: |
670 return parents[0].ancestor(parents[1]) | 704 return parents[0].ancestor(parents[1]) |
671 return None | 705 return None |
672 | 706 |
1182 | 1216 |
1183 bundletype = opts.get('type', 'bzip2').lower() | 1217 bundletype = opts.get('type', 'bzip2').lower() |
1184 btypes = {'none': 'HG10UN', | 1218 btypes = {'none': 'HG10UN', |
1185 'bzip2': 'HG10BZ', | 1219 'bzip2': 'HG10BZ', |
1186 'gzip': 'HG10GZ', | 1220 'gzip': 'HG10GZ', |
1187 'bundle2': 'HG2Y'} | 1221 'bundle2': 'HG20'} |
1188 bundletype = btypes.get(bundletype) | 1222 bundletype = btypes.get(bundletype) |
1189 if bundletype not in changegroup.bundletypes: | 1223 if bundletype not in changegroup.bundletypes: |
1190 raise util.Abort(_('unknown bundle type specified with --type')) | 1224 raise util.Abort(_('unknown bundle type specified with --type')) |
1191 | 1225 |
1192 if opts.get('all'): | 1226 if opts.get('all'): |
1255 m = scmutil.match(ctx, (file1,) + pats, opts) | 1289 m = scmutil.match(ctx, (file1,) + pats, opts) |
1256 | 1290 |
1257 return cmdutil.cat(ui, repo, ctx, m, '', **opts) | 1291 return cmdutil.cat(ui, repo, ctx, m, '', **opts) |
1258 | 1292 |
1259 @command('^clone', | 1293 @command('^clone', |
1260 [('U', 'noupdate', None, | 1294 [('U', 'noupdate', None, _('the clone will include an empty working ' |
1261 _('the clone will include an empty working copy (only a repository)')), | 1295 'directory (only a repository)')), |
1262 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')), | 1296 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')), |
1263 ('r', 'rev', [], _('include the specified changeset'), _('REV')), | 1297 ('r', 'rev', [], _('include the specified changeset'), _('REV')), |
1264 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')), | 1298 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')), |
1265 ('', 'pull', None, _('use pull protocol to copy metadata')), | 1299 ('', 'pull', None, _('use pull protocol to copy metadata')), |
1266 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')), | 1300 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')), |
1378 @command('^commit|ci', | 1412 @command('^commit|ci', |
1379 [('A', 'addremove', None, | 1413 [('A', 'addremove', None, |
1380 _('mark new/missing files as added/removed before committing')), | 1414 _('mark new/missing files as added/removed before committing')), |
1381 ('', 'close-branch', None, | 1415 ('', 'close-branch', None, |
1382 _('mark a branch as closed, hiding it from the branch list')), | 1416 _('mark a branch as closed, hiding it from the branch list')), |
1383 ('', 'amend', None, _('amend the parent of the working dir')), | 1417 ('', 'amend', None, _('amend the parent of the working directory')), |
1384 ('s', 'secret', None, _('use the secret phase for committing')), | 1418 ('s', 'secret', None, _('use the secret phase for committing')), |
1385 ('e', 'edit', None, _('invoke editor on commit messages')), | 1419 ('e', 'edit', None, _('invoke editor on commit messages')), |
1420 ('i', 'interactive', None, _('use interactive mode')), | |
1386 ] + walkopts + commitopts + commitopts2 + subrepoopts, | 1421 ] + walkopts + commitopts + commitopts2 + subrepoopts, |
1387 _('[OPTION]... [FILE]...'), | 1422 _('[OPTION]... [FILE]...'), |
1388 inferrepo=True) | 1423 inferrepo=True) |
1389 def commit(ui, repo, *pats, **opts): | 1424 def commit(ui, repo, *pats, **opts): |
1390 """commit the specified files or all outstanding changes | 1425 """commit the specified files or all outstanding changes |
1420 | 1455 |
1421 See :hg:`help dates` for a list of formats valid for -d/--date. | 1456 See :hg:`help dates` for a list of formats valid for -d/--date. |
1422 | 1457 |
1423 Returns 0 on success, 1 if nothing changed. | 1458 Returns 0 on success, 1 if nothing changed. |
1424 """ | 1459 """ |
1460 if opts.get('interactive'): | |
1461 opts.pop('interactive') | |
1462 cmdutil.dorecord(ui, repo, commit, 'commit', False, | |
1463 cmdutil.recordfilter, *pats, **opts) | |
1464 return | |
1465 | |
1425 if opts.get('subrepos'): | 1466 if opts.get('subrepos'): |
1426 if opts.get('amend'): | 1467 if opts.get('amend'): |
1427 raise util.Abort(_('cannot amend with --subrepos')) | 1468 raise util.Abort(_('cannot amend with --subrepos')) |
1428 # Let --subrepos on the command line override config setting. | 1469 # Let --subrepos on the command line override config setting. |
1429 ui.setconfig('ui', 'commitsubrepos', True, 'commit') | 1470 ui.setconfig('ui', 'commitsubrepos', True, 'commit') |
1872 if not isinstance(gen, bundle2.unbundle20): | 1913 if not isinstance(gen, bundle2.unbundle20): |
1873 raise util.Abort(_('not a bundle2 file')) | 1914 raise util.Abort(_('not a bundle2 file')) |
1874 ui.write(('Stream params: %s\n' % repr(gen.params))) | 1915 ui.write(('Stream params: %s\n' % repr(gen.params))) |
1875 for part in gen.iterparts(): | 1916 for part in gen.iterparts(): |
1876 ui.write('%s -- %r\n' % (part.type, repr(part.params))) | 1917 ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
1877 if part.type == 'b2x:changegroup': | 1918 if part.type == 'changegroup': |
1878 version = part.params.get('version', '01') | 1919 version = part.params.get('version', '01') |
1879 cg = changegroup.packermap[version][1](part, 'UN') | 1920 cg = changegroup.packermap[version][1](part, 'UN') |
1880 chunkdata = cg.changelogheader() | 1921 chunkdata = cg.changelogheader() |
1881 chain = None | 1922 chain = None |
1882 while True: | 1923 while True: |
1944 options.append('-%s' % o[0]) | 1985 options.append('-%s' % o[0]) |
1945 options.append('--%s' % o[1]) | 1986 options.append('--%s' % o[1]) |
1946 ui.write("%s\n" % "\n".join(options)) | 1987 ui.write("%s\n" % "\n".join(options)) |
1947 return | 1988 return |
1948 | 1989 |
1949 cmdlist = cmdutil.findpossible(cmd, table) | 1990 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table) |
1950 if ui.verbose: | 1991 if ui.verbose: |
1951 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] | 1992 cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
1952 ui.write("%s\n" % "\n".join(sorted(cmdlist))) | 1993 ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
1953 | 1994 |
1954 @command('debugdag', | 1995 @command('debugdag', |
2165 | 2206 |
2166 bundletype = opts.get('type', 'bzip2').lower() | 2207 bundletype = opts.get('type', 'bzip2').lower() |
2167 btypes = {'none': 'HG10UN', | 2208 btypes = {'none': 'HG10UN', |
2168 'bzip2': 'HG10BZ', | 2209 'bzip2': 'HG10BZ', |
2169 'gzip': 'HG10GZ', | 2210 'gzip': 'HG10GZ', |
2170 'bundle2': 'HG2Y'} | 2211 'bundle2': 'HG20'} |
2171 bundletype = btypes.get(bundletype) | 2212 bundletype = btypes.get(bundletype) |
2172 if bundletype not in changegroup.bundletypes: | 2213 if bundletype not in changegroup.bundletypes: |
2173 raise util.Abort(_('unknown bundle type specified with --type')) | 2214 raise util.Abort(_('unknown bundle type specified with --type')) |
2174 changegroup.writebundle(ui, bundle, bundlepath, bundletype) | 2215 changegroup.writebundle(ui, bundle, bundlepath, bundletype) |
2175 | 2216 |
2797 deltatotal = deltasize[2] | 2838 deltatotal = deltasize[2] |
2798 if numrevs - numfull > 0: | 2839 if numrevs - numfull > 0: |
2799 deltasize[2] /= numrevs - numfull | 2840 deltasize[2] /= numrevs - numfull |
2800 totalsize = fulltotal + deltatotal | 2841 totalsize = fulltotal + deltatotal |
2801 avgchainlen = sum(chainlengths) / numrevs | 2842 avgchainlen = sum(chainlengths) / numrevs |
2843 maxchainlen = max(chainlengths) | |
2802 compratio = totalrawsize / totalsize | 2844 compratio = totalrawsize / totalsize |
2803 | 2845 |
2804 basedfmtstr = '%%%dd\n' | 2846 basedfmtstr = '%%%dd\n' |
2805 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' | 2847 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
2806 | 2848 |
2829 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) | 2871 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
2830 | 2872 |
2831 ui.write('\n') | 2873 ui.write('\n') |
2832 fmt = dfmtstr(max(avgchainlen, compratio)) | 2874 fmt = dfmtstr(max(avgchainlen, compratio)) |
2833 ui.write(('avg chain length : ') + fmt % avgchainlen) | 2875 ui.write(('avg chain length : ') + fmt % avgchainlen) |
2876 ui.write(('max chain length : ') + fmt % maxchainlen) | |
2834 ui.write(('compression ratio : ') + fmt % compratio) | 2877 ui.write(('compression ratio : ') + fmt % compratio) |
2835 | 2878 |
2836 if format > 0: | 2879 if format > 0: |
2837 ui.write('\n') | 2880 ui.write('\n') |
2838 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') | 2881 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') |
2883 ui.note(revset.prettyformat(newtree), "\n") | 2926 ui.note(revset.prettyformat(newtree), "\n") |
2884 if opts["optimize"]: | 2927 if opts["optimize"]: |
2885 weight, optimizedtree = revset.optimize(newtree, True) | 2928 weight, optimizedtree = revset.optimize(newtree, True) |
2886 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n") | 2929 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n") |
2887 func = revset.match(ui, expr) | 2930 func = revset.match(ui, expr) |
2888 for c in func(repo, revset.spanset(repo)): | 2931 revs = func(repo) |
2932 if ui.verbose: | |
2933 ui.note("* set:\n", revset.prettyformatset(revs), "\n") | |
2934 for c in revs: | |
2889 ui.write("%s\n" % c) | 2935 ui.write("%s\n" % c) |
2890 | 2936 |
2891 @command('debugsetparents', [], _('REV1 [REV2]')) | 2937 @command('debugsetparents', [], _('REV1 [REV2]')) |
2892 def debugsetparents(ui, repo, rev1, rev2=None): | 2938 def debugsetparents(ui, repo, rev1, rev2=None): |
2893 """manually set the parents of the current working directory | 2939 """manually set the parents of the current working directory |
2894 | 2940 |
2895 This is useful for writing repository conversion tools, but should | 2941 This is useful for writing repository conversion tools, but should |
2896 be used with care. | 2942 be used with care. For example, neither the working directory nor the |
2943 dirstate is updated, so file status may be incorrect after running this | |
2944 command. | |
2897 | 2945 |
2898 Returns 0 on success. | 2946 Returns 0 on success. |
2899 """ | 2947 """ |
2900 | 2948 |
2901 r1 = scmutil.revsingle(repo, rev1).node() | 2949 r1 = scmutil.revsingle(repo, rev1).node() |
3122 node1, node2 = node2, node1 | 3170 node1, node2 = node2, node1 |
3123 | 3171 |
3124 diffopts = patch.diffallopts(ui, opts) | 3172 diffopts = patch.diffallopts(ui, opts) |
3125 m = scmutil.match(repo[node2], pats, opts) | 3173 m = scmutil.match(repo[node2], pats, opts) |
3126 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, | 3174 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, |
3127 listsubrepos=opts.get('subrepos')) | 3175 listsubrepos=opts.get('subrepos'), |
3176 root=opts.get('root')) | |
3128 | 3177 |
3129 @command('^export', | 3178 @command('^export', |
3130 [('o', 'output', '', | 3179 [('o', 'output', '', |
3131 _('print output to file with formatted name'), _('FORMAT')), | 3180 _('print output to file with formatted name'), _('FORMAT')), |
3132 ('', 'switch-parent', None, _('diff against the second parent')), | 3181 ('', 'switch-parent', None, _('diff against the second parent')), |
3208 opts=patch.diffallopts(ui, opts)) | 3257 opts=patch.diffallopts(ui, opts)) |
3209 | 3258 |
3210 @command('files', | 3259 @command('files', |
3211 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), | 3260 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')), |
3212 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), | 3261 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), |
3213 ] + walkopts + formatteropts, | 3262 ] + walkopts + formatteropts + subrepoopts, |
3214 _('[OPTION]... [PATTERN]...')) | 3263 _('[OPTION]... [PATTERN]...')) |
3215 def files(ui, repo, *pats, **opts): | 3264 def files(ui, repo, *pats, **opts): |
3216 """list tracked files | 3265 """list tracked files |
3217 | 3266 |
3218 Print files under Mercurial control in the working directory or | 3267 Print files under Mercurial control in the working directory or |
3219 specified revision whose names match the given patterns (excluding | 3268 specified revision whose names match the given patterns (excluding |
3220 removed files). | 3269 removed files). |
3221 | 3270 |
3222 If no patterns are given to match, this command prints the names | 3271 If no patterns are given to match, this command prints the names |
3223 of all files under Mercurial control in the working copy. | 3272 of all files under Mercurial control in the working directory. |
3224 | 3273 |
3225 .. container:: verbose | 3274 .. container:: verbose |
3226 | 3275 |
3227 Examples: | 3276 Examples: |
3228 | 3277 |
3255 | 3304 |
3256 Returns 0 if a match is found, 1 otherwise. | 3305 Returns 0 if a match is found, 1 otherwise. |
3257 | 3306 |
3258 """ | 3307 """ |
3259 ctx = scmutil.revsingle(repo, opts.get('rev'), None) | 3308 ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
3260 rev = ctx.rev() | |
3261 ret = 1 | |
3262 | 3309 |
3263 end = '\n' | 3310 end = '\n' |
3264 if opts.get('print0'): | 3311 if opts.get('print0'): |
3265 end = '\0' | 3312 end = '\0' |
3266 fm = ui.formatter('files', opts) | 3313 fm = ui.formatter('files', opts) |
3267 fmt = '%s' + end | 3314 fmt = '%s' + end |
3268 | 3315 |
3269 m = scmutil.match(ctx, pats, opts) | 3316 m = scmutil.match(ctx, pats, opts) |
3270 ds = repo.dirstate | 3317 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) |
3271 for f in ctx.matches(m): | |
3272 if rev is None and ds[f] == 'r': | |
3273 continue | |
3274 fm.startitem() | |
3275 if ui.verbose: | |
3276 fc = ctx[f] | |
3277 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags()) | |
3278 fm.data(abspath=f) | |
3279 fm.write('path', fmt, m.rel(f)) | |
3280 ret = 0 | |
3281 | 3318 |
3282 fm.end() | 3319 fm.end() |
3283 | 3320 |
3284 return ret | 3321 return ret |
3285 | 3322 |
3505 ui.status(_('grafting %s\n') % desc) | 3542 ui.status(_('grafting %s\n') % desc) |
3506 if opts.get('dry_run'): | 3543 if opts.get('dry_run'): |
3507 continue | 3544 continue |
3508 | 3545 |
3509 source = ctx.extra().get('source') | 3546 source = ctx.extra().get('source') |
3510 if not source: | 3547 extra = {} |
3511 source = ctx.hex() | 3548 if source: |
3512 extra = {'source': source} | 3549 extra['source'] = source |
3550 extra['intermediate-source'] = ctx.hex() | |
3551 else: | |
3552 extra['source'] = ctx.hex() | |
3513 user = ctx.user() | 3553 user = ctx.user() |
3514 if opts.get('user'): | 3554 if opts.get('user'): |
3515 user = opts['user'] | 3555 user = opts['user'] |
3516 date = ctx.date() | 3556 date = ctx.date() |
3517 if opts.get('date'): | 3557 if opts.get('date'): |
3673 for i in xrange(blo, bhi): | 3713 for i in xrange(blo, bhi): |
3674 yield ('+', b[i]) | 3714 yield ('+', b[i]) |
3675 | 3715 |
3676 def display(fn, ctx, pstates, states): | 3716 def display(fn, ctx, pstates, states): |
3677 rev = ctx.rev() | 3717 rev = ctx.rev() |
3678 datefunc = ui.quiet and util.shortdate or util.datestr | 3718 if ui.quiet: |
3719 datefunc = util.shortdate | |
3720 else: | |
3721 datefunc = util.datestr | |
3679 found = False | 3722 found = False |
3680 @util.cachefunc | 3723 @util.cachefunc |
3681 def binary(): | 3724 def binary(): |
3682 flog = getfile(fn) | 3725 flog = getfile(fn) |
3683 return util.binary(flog.read(ctx.filenode(fn))) | 3726 return util.binary(flog.read(ctx.filenode(fn))) |
3913 ] + remoteopts, | 3956 ] + remoteopts, |
3914 _('[-nibtB] [-r REV] [SOURCE]'), | 3957 _('[-nibtB] [-r REV] [SOURCE]'), |
3915 optionalrepo=True) | 3958 optionalrepo=True) |
3916 def identify(ui, repo, source=None, rev=None, | 3959 def identify(ui, repo, source=None, rev=None, |
3917 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts): | 3960 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts): |
3918 """identify the working copy or specified revision | 3961 """identify the working directory or specified revision |
3919 | 3962 |
3920 Print a summary identifying the repository state at REV using one or | 3963 Print a summary identifying the repository state at REV using one or |
3921 two parent hash identifiers, followed by a "+" if the working | 3964 two parent hash identifiers, followed by a "+" if the working |
3922 directory has uncommitted changes, the branch name (if not default), | 3965 directory has uncommitted changes, the branch name (if not default), |
3923 a list of tags, and a list of bookmarks. | 3966 a list of tags, and a list of bookmarks. |
3949 | 3992 |
3950 if not repo and not source: | 3993 if not repo and not source: |
3951 raise util.Abort(_("there is no Mercurial repository here " | 3994 raise util.Abort(_("there is no Mercurial repository here " |
3952 "(.hg not found)")) | 3995 "(.hg not found)")) |
3953 | 3996 |
3954 hexfunc = ui.debugflag and hex or short | 3997 if ui.debugflag: |
3998 hexfunc = hex | |
3999 else: | |
4000 hexfunc = short | |
3955 default = not (num or id or branch or tags or bookmarks) | 4001 default = not (num or id or branch or tags or bookmarks) |
3956 output = [] | 4002 output = [] |
3957 revs = [] | 4003 revs = [] |
3958 | 4004 |
3959 if source: | 4005 if source: |
4054 _("apply patch without touching the working directory")), | 4100 _("apply patch without touching the working directory")), |
4055 ('', 'partial', None, | 4101 ('', 'partial', None, |
4056 _('commit even if some hunks fail')), | 4102 _('commit even if some hunks fail')), |
4057 ('', 'exact', None, | 4103 ('', 'exact', None, |
4058 _('apply patch to the nodes from which it was generated')), | 4104 _('apply patch to the nodes from which it was generated')), |
4105 ('', 'prefix', '', | |
4106 _('apply patch to subdirectory'), _('DIR')), | |
4059 ('', 'import-branch', None, | 4107 ('', 'import-branch', None, |
4060 _('use any branch information in patch (implied by --exact)'))] + | 4108 _('use any branch information in patch (implied by --exact)'))] + |
4061 commitopts + commitopts2 + similarityopts, | 4109 commitopts + commitopts2 + similarityopts, |
4062 _('[OPTION]... PATCH...')) | 4110 _('[OPTION]... PATCH...')) |
4063 def import_(ui, repo, patch1=None, *patches, **opts): | 4111 def import_(ui, repo, patch1=None, *patches, **opts): |
4153 raise util.Abort(_('similarity must be between 0 and 100')) | 4201 raise util.Abort(_('similarity must be between 0 and 100')) |
4154 if sim and not update: | 4202 if sim and not update: |
4155 raise util.Abort(_('cannot use --similarity with --bypass')) | 4203 raise util.Abort(_('cannot use --similarity with --bypass')) |
4156 if opts.get('exact') and opts.get('edit'): | 4204 if opts.get('exact') and opts.get('edit'): |
4157 raise util.Abort(_('cannot use --exact with --edit')) | 4205 raise util.Abort(_('cannot use --exact with --edit')) |
4206 if opts.get('exact') and opts.get('prefix'): | |
4207 raise util.Abort(_('cannot use --exact with --prefix')) | |
4158 | 4208 |
4159 if update: | 4209 if update: |
4160 cmdutil.checkunfinished(repo) | 4210 cmdutil.checkunfinished(repo) |
4161 if (opts.get('exact') or not opts.get('force')) and update: | 4211 if (opts.get('exact') or not opts.get('force')) and update: |
4162 cmdutil.bailifchanged(repo) | 4212 cmdutil.bailifchanged(repo) |
4241 | 4291 |
4242 Show new changesets found in the specified path/URL or the default | 4292 Show new changesets found in the specified path/URL or the default |
4243 pull location. These are the changesets that would have been pulled | 4293 pull location. These are the changesets that would have been pulled |
4244 if a pull at the time you issued this command. | 4294 if a pull at the time you issued this command. |
4245 | 4295 |
4246 For remote repository, using --bundle avoids downloading the | |
4247 changesets twice if the incoming is followed by a pull. | |
4248 | |
4249 See pull for valid source format details. | 4296 See pull for valid source format details. |
4250 | 4297 |
4251 .. container:: verbose | 4298 .. container:: verbose |
4299 | |
4300 With -B/--bookmarks, the result of bookmark comparison between | |
4301 local and remote repositories is displayed. With -v/--verbose, | |
4302 status is also displayed for each bookmark like below:: | |
4303 | |
4304 BM1 01234567890a added | |
4305 BM2 1234567890ab advanced | |
4306 BM3 234567890abc diverged | |
4307 BM4 34567890abcd changed | |
4308 | |
4309 The action taken locally when pulling depends on the | |
4310 status of each bookmark: | |
4311 | |
4312 :``added``: pull will create it | |
4313 :``advanced``: pull will update it | |
4314 :``diverged``: pull will create a divergent bookmark | |
4315 :``changed``: result depends on remote changesets | |
4316 | |
4317 From the point of view of pulling behavior, bookmark | |
4318 existing only in the remote repository are treated as ``added``, | |
4319 even if it is in fact locally deleted. | |
4320 | |
4321 .. container:: verbose | |
4322 | |
4323 For remote repository, using --bundle avoids downloading the | |
4324 changesets twice if the incoming is followed by a pull. | |
4252 | 4325 |
4253 Examples: | 4326 Examples: |
4254 | 4327 |
4255 - show incoming changes with patches and full description:: | 4328 - show incoming changes with patches and full description:: |
4256 | 4329 |
4287 other = hg.peer(repo, opts, source) | 4360 other = hg.peer(repo, opts, source) |
4288 if 'bookmarks' not in other.listkeys('namespaces'): | 4361 if 'bookmarks' not in other.listkeys('namespaces'): |
4289 ui.warn(_("remote doesn't support bookmarks\n")) | 4362 ui.warn(_("remote doesn't support bookmarks\n")) |
4290 return 0 | 4363 return 0 |
4291 ui.status(_('comparing with %s\n') % util.hidepassword(source)) | 4364 ui.status(_('comparing with %s\n') % util.hidepassword(source)) |
4292 return bookmarks.diff(ui, repo, other) | 4365 return bookmarks.incoming(ui, repo, other) |
4293 | 4366 |
4294 repo._subtoppath = ui.expandpath(source) | 4367 repo._subtoppath = ui.expandpath(source) |
4295 try: | 4368 try: |
4296 return hg.incoming(ui, repo, source, opts) | 4369 return hg.incoming(ui, repo, source, opts) |
4297 finally: | 4370 finally: |
4341 | 4414 |
4342 See :hg:`help files` for a more versatile command. | 4415 See :hg:`help files` for a more versatile command. |
4343 | 4416 |
4344 Returns 0 if a match is found, 1 otherwise. | 4417 Returns 0 if a match is found, 1 otherwise. |
4345 """ | 4418 """ |
4346 end = opts.get('print0') and '\0' or '\n' | 4419 if opts.get('print0'): |
4420 end = '\0' | |
4421 else: | |
4422 end = '\n' | |
4347 rev = scmutil.revsingle(repo, opts.get('rev'), None).node() | 4423 rev = scmutil.revsingle(repo, opts.get('rev'), None).node() |
4348 | 4424 |
4349 ret = 1 | 4425 ret = 1 |
4350 ctx = repo[rev] | 4426 ctx = repo[rev] |
4351 m = scmutil.match(ctx, pats, opts, default='relglob') | 4427 m = scmutil.match(ctx, pats, opts, default='relglob') |
4475 specifying custom templates. | 4551 specifying custom templates. |
4476 | 4552 |
4477 Returns 0 on success. | 4553 Returns 0 on success. |
4478 | 4554 |
4479 """ | 4555 """ |
4556 if opts.get('follow') and opts.get('rev'): | |
4557 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))] | |
4558 del opts['follow'] | |
4559 | |
4480 if opts.get('graph'): | 4560 if opts.get('graph'): |
4481 return cmdutil.graphlog(ui, repo, *pats, **opts) | 4561 return cmdutil.graphlog(ui, repo, *pats, **opts) |
4482 | 4562 |
4483 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) | 4563 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) |
4484 limit = cmdutil.loglimit(opts) | 4564 limit = cmdutil.loglimit(opts) |
4501 copies = [] | 4581 copies = [] |
4502 for fn in ctx.files(): | 4582 for fn in ctx.files(): |
4503 rename = getrenamed(fn, rev) | 4583 rename = getrenamed(fn, rev) |
4504 if rename: | 4584 if rename: |
4505 copies.append((fn, rename[0])) | 4585 copies.append((fn, rename[0])) |
4506 revmatchfn = filematcher and filematcher(ctx.rev()) or None | 4586 if filematcher: |
4587 revmatchfn = filematcher(ctx.rev()) | |
4588 else: | |
4589 revmatchfn = None | |
4507 displayer.show(ctx, copies=copies, matchfn=revmatchfn) | 4590 displayer.show(ctx, copies=copies, matchfn=revmatchfn) |
4508 if displayer.flush(rev): | 4591 if displayer.flush(rev): |
4509 count += 1 | 4592 count += 1 |
4510 | 4593 |
4511 displayer.close() | 4594 displayer.close() |
4707 or the default push location. These are the changesets that would | 4790 or the default push location. These are the changesets that would |
4708 be pushed if a push was requested. | 4791 be pushed if a push was requested. |
4709 | 4792 |
4710 See pull for details of valid destination formats. | 4793 See pull for details of valid destination formats. |
4711 | 4794 |
4795 .. container:: verbose | |
4796 | |
4797 With -B/--bookmarks, the result of bookmark comparison between | |
4798 local and remote repositories is displayed. With -v/--verbose, | |
4799 status is also displayed for each bookmark like below:: | |
4800 | |
4801 BM1 01234567890a added | |
4802 BM2 deleted | |
4803 BM3 234567890abc advanced | |
4804 BM4 34567890abcd diverged | |
4805 BM5 4567890abcde changed | |
4806 | |
4807 The action taken when pushing depends on the | |
4808 status of each bookmark: | |
4809 | |
4810 :``added``: push with ``-B`` will create it | |
4811 :``deleted``: push with ``-B`` will delete it | |
4812 :``advanced``: push will update it | |
4813 :``diverged``: push with ``-B`` will update it | |
4814 :``changed``: push with ``-B`` will update it | |
4815 | |
4816 From the point of view of pushing behavior, bookmarks | |
4817 existing only in the remote repository are treated as | |
4818 ``deleted``, even if it is in fact added remotely. | |
4819 | |
4712 Returns 0 if there are outgoing changes, 1 otherwise. | 4820 Returns 0 if there are outgoing changes, 1 otherwise. |
4713 """ | 4821 """ |
4714 if opts.get('graph'): | 4822 if opts.get('graph'): |
4715 cmdutil.checkunsupportedgraphflags([], opts) | 4823 cmdutil.checkunsupportedgraphflags([], opts) |
4716 o, other = hg._outgoing(ui, repo, dest, opts) | 4824 o, other = hg._outgoing(ui, repo, dest, opts) |
4732 other = hg.peer(repo, opts, dest) | 4840 other = hg.peer(repo, opts, dest) |
4733 if 'bookmarks' not in other.listkeys('namespaces'): | 4841 if 'bookmarks' not in other.listkeys('namespaces'): |
4734 ui.warn(_("remote doesn't support bookmarks\n")) | 4842 ui.warn(_("remote doesn't support bookmarks\n")) |
4735 return 0 | 4843 return 0 |
4736 ui.status(_('comparing with %s\n') % util.hidepassword(dest)) | 4844 ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
4737 return bookmarks.diff(ui, other, repo) | 4845 return bookmarks.outgoing(ui, repo, other) |
4738 | 4846 |
4739 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') | 4847 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') |
4740 try: | 4848 try: |
4741 return hg.outgoing(ui, repo, dest, opts) | 4849 return hg.outgoing(ui, repo, dest, opts) |
4742 finally: | 4850 finally: |
4819 See :hg:`help urls` for more information. | 4927 See :hg:`help urls` for more information. |
4820 | 4928 |
4821 Returns 0 on success. | 4929 Returns 0 on success. |
4822 """ | 4930 """ |
4823 if search: | 4931 if search: |
4824 for name, path in ui.configitems("paths"): | 4932 for name, path in sorted(ui.paths.iteritems()): |
4825 if name == search: | 4933 if name == search: |
4826 ui.status("%s\n" % util.hidepassword(path)) | 4934 ui.status("%s\n" % util.hidepassword(path.loc)) |
4827 return | 4935 return |
4828 if not ui.quiet: | 4936 if not ui.quiet: |
4829 ui.warn(_("not found!\n")) | 4937 ui.warn(_("not found!\n")) |
4830 return 1 | 4938 return 1 |
4831 else: | 4939 else: |
4832 for name, path in ui.configitems("paths"): | 4940 for name, path in sorted(ui.paths.iteritems()): |
4833 if ui.quiet: | 4941 if ui.quiet: |
4834 ui.write("%s\n" % name) | 4942 ui.write("%s\n" % name) |
4835 else: | 4943 else: |
4836 ui.write("%s = %s\n" % (name, util.hidepassword(path))) | 4944 ui.write("%s = %s\n" % (name, |
4945 util.hidepassword(path.loc))) | |
4837 | 4946 |
4838 @command('phase', | 4947 @command('phase', |
4839 [('p', 'public', False, _('set changeset phase to public')), | 4948 [('p', 'public', False, _('set changeset phase to public')), |
4840 ('d', 'draft', False, _('set changeset phase to draft')), | 4949 ('d', 'draft', False, _('set changeset phase to draft')), |
4841 ('s', 'secret', False, _('set changeset phase to secret')), | 4950 ('s', 'secret', False, _('set changeset phase to secret')), |
4982 See :hg:`help urls` for more information. | 5091 See :hg:`help urls` for more information. |
4983 | 5092 |
4984 Returns 0 on success, 1 if an update had unresolved files. | 5093 Returns 0 on success, 1 if an update had unresolved files. |
4985 """ | 5094 """ |
4986 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | 5095 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
5096 ui.status(_('pulling from %s\n') % util.hidepassword(source)) | |
4987 other = hg.peer(repo, opts, source) | 5097 other = hg.peer(repo, opts, source) |
4988 try: | 5098 try: |
4989 ui.status(_('pulling from %s\n') % util.hidepassword(source)) | |
4990 revs, checkout = hg.addbranchrevs(repo, other, branches, | 5099 revs, checkout = hg.addbranchrevs(repo, other, branches, |
4991 opts.get('rev')) | 5100 opts.get('rev')) |
4992 | 5101 |
4993 remotebookmarks = other.listkeys('bookmarks') | 5102 remotebookmarks = other.listkeys('bookmarks') |
4994 | 5103 |
5096 else: | 5205 else: |
5097 raise | 5206 raise |
5098 | 5207 |
5099 if revs: | 5208 if revs: |
5100 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] | 5209 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] |
5210 if not revs: | |
5211 raise util.Abort(_("specified revisions evaluate to an empty set"), | |
5212 hint=_("use different revision arguments")) | |
5101 | 5213 |
5102 repo._subtoppath = dest | 5214 repo._subtoppath = dest |
5103 try: | 5215 try: |
5104 # push subrepos depth-first for coherent ordering | 5216 # push subrepos depth-first for coherent ordering |
5105 c = repo[''] | 5217 c = repo[''] |
5223 [('a', 'all', None, _('select all unresolved files')), | 5335 [('a', 'all', None, _('select all unresolved files')), |
5224 ('l', 'list', None, _('list state of files needing merge')), | 5336 ('l', 'list', None, _('list state of files needing merge')), |
5225 ('m', 'mark', None, _('mark files as resolved')), | 5337 ('m', 'mark', None, _('mark files as resolved')), |
5226 ('u', 'unmark', None, _('mark files as unresolved')), | 5338 ('u', 'unmark', None, _('mark files as unresolved')), |
5227 ('n', 'no-status', None, _('hide status prefix'))] | 5339 ('n', 'no-status', None, _('hide status prefix'))] |
5228 + mergetoolopts + walkopts, | 5340 + mergetoolopts + walkopts + formatteropts, |
5229 _('[OPTION]... [FILE]...'), | 5341 _('[OPTION]... [FILE]...'), |
5230 inferrepo=True) | 5342 inferrepo=True) |
5231 def resolve(ui, repo, *pats, **opts): | 5343 def resolve(ui, repo, *pats, **opts): |
5232 """redo merges or set/view the merge status of files | 5344 """redo merges or set/view the merge status of files |
5233 | 5345 |
5275 raise util.Abort(_("can't specify --all and patterns")) | 5387 raise util.Abort(_("can't specify --all and patterns")) |
5276 if not (all or pats or show or mark or unmark): | 5388 if not (all or pats or show or mark or unmark): |
5277 raise util.Abort(_('no files or directories specified'), | 5389 raise util.Abort(_('no files or directories specified'), |
5278 hint=('use --all to remerge all files')) | 5390 hint=('use --all to remerge all files')) |
5279 | 5391 |
5392 if show: | |
5393 fm = ui.formatter('resolve', opts) | |
5394 ms = mergemod.mergestate(repo) | |
5395 m = scmutil.match(repo[None], pats, opts) | |
5396 for f in ms: | |
5397 if not m(f): | |
5398 continue | |
5399 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]] | |
5400 fm.startitem() | |
5401 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l) | |
5402 fm.write('path', '%s\n', f, label=l) | |
5403 fm.end() | |
5404 return 0 | |
5405 | |
5280 wlock = repo.wlock() | 5406 wlock = repo.wlock() |
5281 try: | 5407 try: |
5282 ms = mergemod.mergestate(repo) | 5408 ms = mergemod.mergestate(repo) |
5283 | 5409 |
5284 if not (ms.active() or repo.dirstate.p2() != nullid) and not show: | 5410 if not (ms.active() or repo.dirstate.p2() != nullid): |
5285 raise util.Abort( | 5411 raise util.Abort( |
5286 _('resolve command not applicable when not merging')) | 5412 _('resolve command not applicable when not merging')) |
5287 | 5413 |
5288 m = scmutil.match(repo[None], pats, opts) | 5414 m = scmutil.match(repo[None], pats, opts) |
5289 ret = 0 | 5415 ret = 0 |
5293 if not m(f): | 5419 if not m(f): |
5294 continue | 5420 continue |
5295 | 5421 |
5296 didwork = True | 5422 didwork = True |
5297 | 5423 |
5298 if show: | 5424 if mark: |
5299 if nostatus: | |
5300 ui.write("%s\n" % f) | |
5301 else: | |
5302 ui.write("%s %s\n" % (ms[f].upper(), f), | |
5303 label='resolve.' + | |
5304 {'u': 'unresolved', 'r': 'resolved'}[ms[f]]) | |
5305 elif mark: | |
5306 ms.mark(f, "r") | 5425 ms.mark(f, "r") |
5307 elif unmark: | 5426 elif unmark: |
5308 ms.mark(f, "u") | 5427 ms.mark(f, "u") |
5309 else: | 5428 else: |
5310 wctx = repo[None] | 5429 wctx = repo[None] |
5332 ui.warn(_("arguments do not match paths that need resolving\n")) | 5451 ui.warn(_("arguments do not match paths that need resolving\n")) |
5333 | 5452 |
5334 finally: | 5453 finally: |
5335 wlock.release() | 5454 wlock.release() |
5336 | 5455 |
5337 # Nudge users into finishing an unfinished operation. We don't print | 5456 # Nudge users into finishing an unfinished operation |
5338 # this with the list/show operation because we want list/show to remain | 5457 if not list(ms.unresolved()): |
5339 # machine readable. | |
5340 if not list(ms.unresolved()) and not show: | |
5341 ui.status(_('(no more unresolved files)\n')) | 5458 ui.status(_('(no more unresolved files)\n')) |
5342 | 5459 |
5343 return ret | 5460 return ret |
5344 | 5461 |
5345 @command('revert', | 5462 @command('revert', |
5346 [('a', 'all', None, _('revert all changes when no arguments given')), | 5463 [('a', 'all', None, _('revert all changes when no arguments given')), |
5347 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), | 5464 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), |
5348 ('r', 'rev', '', _('revert to the specified revision'), _('REV')), | 5465 ('r', 'rev', '', _('revert to the specified revision'), _('REV')), |
5349 ('C', 'no-backup', None, _('do not save backup copies of files')), | 5466 ('C', 'no-backup', None, _('do not save backup copies of files')), |
5467 ('i', 'interactive', None, _('interactively select the changes')), | |
5350 ] + walkopts + dryrunopts, | 5468 ] + walkopts + dryrunopts, |
5351 _('[OPTION]... [-r REV] [NAME]...')) | 5469 _('[OPTION]... [-r REV] [NAME]...')) |
5352 def revert(ui, repo, *pats, **opts): | 5470 def revert(ui, repo, *pats, **opts): |
5353 """restore files to their checkout state | 5471 """restore files to their checkout state |
5354 | 5472 |
5391 raise util.Abort(_('uncommitted merge with no revision specified'), | 5509 raise util.Abort(_('uncommitted merge with no revision specified'), |
5392 hint=_('use "hg update" or see "hg help revert"')) | 5510 hint=_('use "hg update" or see "hg help revert"')) |
5393 | 5511 |
5394 ctx = scmutil.revsingle(repo, opts.get('rev')) | 5512 ctx = scmutil.revsingle(repo, opts.get('rev')) |
5395 | 5513 |
5396 if not pats and not opts.get('all'): | 5514 if not pats and not (opts.get('all') or opts.get('interactive')): |
5397 msg = _("no files or directories specified") | 5515 msg = _("no files or directories specified") |
5398 if p2 != nullid: | 5516 if p2 != nullid: |
5399 hint = _("uncommitted merge, use --all to discard all changes," | 5517 hint = _("uncommitted merge, use --all to discard all changes," |
5400 " or 'hg update -C .' to abort the merge") | 5518 " or 'hg update -C .' to abort the merge") |
5401 raise util.Abort(msg, hint=hint) | 5519 raise util.Abort(msg, hint=hint) |
5539 | 5657 |
5540 # this way we can check if something was given in the command-line | 5658 # this way we can check if something was given in the command-line |
5541 if opts.get('port'): | 5659 if opts.get('port'): |
5542 opts['port'] = util.getport(opts.get('port')) | 5660 opts['port'] = util.getport(opts.get('port')) |
5543 | 5661 |
5544 baseui = repo and repo.baseui or ui | 5662 if repo: |
5663 baseui = repo.baseui | |
5664 else: | |
5665 baseui = ui | |
5545 optlist = ("name templates style address port prefix ipv6" | 5666 optlist = ("name templates style address port prefix ipv6" |
5546 " accesslog errorlog certificate encoding") | 5667 " accesslog errorlog certificate encoding") |
5547 for o in optlist.split(): | 5668 for o in optlist.split(): |
5548 val = opts.get(o, '') | 5669 val = opts.get(o, '') |
5549 if val in (None, ''): # should check against default options instead | 5670 if val in (None, ''): # should check against default options instead |
5666 - show changes in the working directory relative to a | 5787 - show changes in the working directory relative to a |
5667 changeset:: | 5788 changeset:: |
5668 | 5789 |
5669 hg status --rev 9353 | 5790 hg status --rev 9353 |
5670 | 5791 |
5792 - show changes in the working directory relative to the | |
5793 current directory (see :hg:`help patterns` for more information):: | |
5794 | |
5795 hg status re: | |
5796 | |
5671 - show all changes including copies in an existing changeset:: | 5797 - show all changes including copies in an existing changeset:: |
5672 | 5798 |
5673 hg status --copies --change 9353 | 5799 hg status --copies --change 9353 |
5674 | 5800 |
5675 - get a NUL separated list of added files, suitable for xargs:: | 5801 - get a NUL separated list of added files, suitable for xargs:: |
5689 node2 = scmutil.revsingle(repo, change, None).node() | 5815 node2 = scmutil.revsingle(repo, change, None).node() |
5690 node1 = repo[node2].p1().node() | 5816 node1 = repo[node2].p1().node() |
5691 else: | 5817 else: |
5692 node1, node2 = scmutil.revpair(repo, revs) | 5818 node1, node2 = scmutil.revpair(repo, revs) |
5693 | 5819 |
5694 cwd = (pats and repo.getcwd()) or '' | 5820 if pats: |
5695 end = opts.get('print0') and '\0' or '\n' | 5821 cwd = repo.getcwd() |
5822 else: | |
5823 cwd = '' | |
5824 | |
5825 if opts.get('print0'): | |
5826 end = '\0' | |
5827 else: | |
5828 end = '\n' | |
5696 copy = {} | 5829 copy = {} |
5697 states = 'modified added removed deleted unknown ignored clean'.split() | 5830 states = 'modified added removed deleted unknown ignored clean'.split() |
5698 show = [k for k in states if opts.get(k)] | 5831 show = [k for k in states if opts.get(k)] |
5699 if opts.get('all'): | 5832 if opts.get('all'): |
5700 show += ui.quiet and (states[:4] + ['clean']) or states | 5833 show += ui.quiet and (states[:4] + ['clean']) or states |
5701 if not show: | 5834 if not show: |
5702 show = ui.quiet and states[:4] or states[:5] | 5835 if ui.quiet: |
5836 show = states[:4] | |
5837 else: | |
5838 show = states[:5] | |
5703 | 5839 |
5704 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), | 5840 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts), |
5705 'ignored' in show, 'clean' in show, 'unknown' in show, | 5841 'ignored' in show, 'clean' in show, 'unknown' in show, |
5706 opts.get('subrepos')) | 5842 opts.get('subrepos')) |
5707 changestates = zip(states, 'MAR!?IC', stat) | 5843 changestates = zip(states, 'MAR!?IC', stat) |
5708 | 5844 |
5709 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): | 5845 if (opts.get('all') or opts.get('copies') |
5846 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'): | |
5710 copy = copies.pathcopies(repo[node1], repo[node2]) | 5847 copy = copies.pathcopies(repo[node1], repo[node2]) |
5711 | 5848 |
5712 fm = ui.formatter('status', opts) | 5849 fm = ui.formatter('status', opts) |
5713 fmt = '%s' + end | 5850 fmt = '%s' + end |
5714 showchar = not opts.get('no_status') | 5851 showchar = not opts.get('no_status') |
5937 o = outgoing.missing | 6074 o = outgoing.missing |
5938 if o: | 6075 if o: |
5939 t.append(_('%d outgoing') % len(o)) | 6076 t.append(_('%d outgoing') % len(o)) |
5940 other = dother or sother | 6077 other = dother or sother |
5941 if 'bookmarks' in other.listkeys('namespaces'): | 6078 if 'bookmarks' in other.listkeys('namespaces'): |
5942 lmarks = repo.listkeys('bookmarks') | 6079 counts = bookmarks.summary(repo, other) |
5943 rmarks = other.listkeys('bookmarks') | 6080 if counts[0] > 0: |
5944 diff = set(rmarks) - set(lmarks) | 6081 t.append(_('%d incoming bookmarks') % counts[0]) |
5945 if len(diff) > 0: | 6082 if counts[1] > 0: |
5946 t.append(_('%d incoming bookmarks') % len(diff)) | 6083 t.append(_('%d outgoing bookmarks') % counts[1]) |
5947 diff = set(lmarks) - set(rmarks) | |
5948 if len(diff) > 0: | |
5949 t.append(_('%d outgoing bookmarks') % len(diff)) | |
5950 | 6084 |
5951 if t: | 6085 if t: |
5952 # i18n: column positioning for "hg summary" | 6086 # i18n: column positioning for "hg summary" |
5953 ui.write(_('remote: %s\n') % (', '.join(t))) | 6087 ui.write(_('remote: %s\n') % (', '.join(t))) |
5954 else: | 6088 else: |
6018 raise util.Abort(_("--rev and --remove are incompatible")) | 6152 raise util.Abort(_("--rev and --remove are incompatible")) |
6019 if opts.get('rev'): | 6153 if opts.get('rev'): |
6020 rev_ = opts['rev'] | 6154 rev_ = opts['rev'] |
6021 message = opts.get('message') | 6155 message = opts.get('message') |
6022 if opts.get('remove'): | 6156 if opts.get('remove'): |
6023 expectedtype = opts.get('local') and 'local' or 'global' | 6157 if opts.get('local'): |
6158 expectedtype = 'local' | |
6159 else: | |
6160 expectedtype = 'global' | |
6161 | |
6024 for n in names: | 6162 for n in names: |
6025 if not repo.tagtype(n): | 6163 if not repo.tagtype(n): |
6026 raise util.Abort(_("tag '%s' does not exist") % n) | 6164 raise util.Abort(_("tag '%s' does not exist") % n) |
6027 if repo.tagtype(n) != expectedtype: | 6165 if repo.tagtype(n) != expectedtype: |
6028 if expectedtype == 'global': | 6166 if expectedtype == 'global': |
6248 if rev is not None: | 6386 if rev is not None: |
6249 raise util.Abort(_("you can't specify a revision and a date")) | 6387 raise util.Abort(_("you can't specify a revision and a date")) |
6250 rev = cmdutil.finddate(ui, repo, date) | 6388 rev = cmdutil.finddate(ui, repo, date) |
6251 | 6389 |
6252 if check: | 6390 if check: |
6253 c = repo[None] | 6391 cmdutil.bailifchanged(repo, merge=False) |
6254 if c.dirty(merge=False, branch=False, missing=True): | |
6255 raise util.Abort(_("uncommitted changes")) | |
6256 if rev is None: | 6392 if rev is None: |
6257 rev = repo[repo[None].branch()].rev() | 6393 rev = repo[repo[None].branch()].rev() |
6258 | 6394 |
6259 repo.ui.setconfig('ui', 'forcemerge', tool, 'update') | 6395 repo.ui.setconfig('ui', 'forcemerge', tool, 'update') |
6260 | 6396 |
6301 """output version and copyright information""" | 6437 """output version and copyright information""" |
6302 ui.write(_("Mercurial Distributed SCM (version %s)\n") | 6438 ui.write(_("Mercurial Distributed SCM (version %s)\n") |
6303 % util.version()) | 6439 % util.version()) |
6304 ui.status(_( | 6440 ui.status(_( |
6305 "(see http://mercurial.selenic.com for more information)\n" | 6441 "(see http://mercurial.selenic.com for more information)\n" |
6306 "\nCopyright (C) 2005-2014 Matt Mackall and others\n" | 6442 "\nCopyright (C) 2005-2015 Matt Mackall and others\n" |
6307 "This is free software; see the source for copying conditions. " | 6443 "This is free software; see the source for copying conditions. " |
6308 "There is NO\nwarranty; " | 6444 "There is NO\nwarranty; " |
6309 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | 6445 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
6310 )) | 6446 )) |
6311 | 6447 |