32 |
32 |
33 bad = [] |
33 bad = [] |
34 names = [] |
34 names = [] |
35 m = cmdutil.match(repo, pats, opts) |
35 m = cmdutil.match(repo, pats, opts) |
36 oldbad = m.bad |
36 oldbad = m.bad |
37 m.bad = lambda x,y: bad.append(x) or oldbad(x,y) |
37 m.bad = lambda x, y: bad.append(x) or oldbad(x, y) |
38 |
38 |
39 for f in repo.walk(m): |
39 for f in repo.walk(m): |
40 exact = m.exact(f) |
40 exact = m.exact(f) |
41 if exact or f not in repo.dirstate: |
41 if exact or f not in repo.dirstate: |
42 names.append(f) |
42 names.append(f) |
67 sim = float(opts.get('similarity') or 0) |
67 sim = float(opts.get('similarity') or 0) |
68 except ValueError: |
68 except ValueError: |
69 raise util.Abort(_('similarity must be a number')) |
69 raise util.Abort(_('similarity must be a number')) |
70 if sim < 0 or sim > 100: |
70 if sim < 0 or sim > 100: |
71 raise util.Abort(_('similarity must be between 0 and 100')) |
71 raise util.Abort(_('similarity must be between 0 and 100')) |
72 return cmdutil.addremove(repo, pats, opts, similarity=sim/100.) |
72 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0) |
73 |
73 |
74 def annotate(ui, repo, *pats, **opts): |
74 def annotate(ui, repo, *pats, **opts): |
75 """show changeset information by line for each file |
75 """show changeset information by line for each file |
76 |
76 |
77 List changes in files, showing the revision id responsible for |
77 List changes in files, showing the revision id responsible for |
96 ('changeset', lambda x: short(x[0].node())), |
96 ('changeset', lambda x: short(x[0].node())), |
97 ('date', getdate), |
97 ('date', getdate), |
98 ('follow', lambda x: x[0].path()), |
98 ('follow', lambda x: x[0].path()), |
99 ] |
99 ] |
100 |
100 |
101 if (not opts.get('user') and not opts.get('changeset') and not opts.get('date') |
101 if (not opts.get('user') and not opts.get('changeset') |
102 and not opts.get('follow')): |
102 and not opts.get('date') and not opts.get('follow')): |
103 opts['number'] = 1 |
103 opts['number'] = 1 |
104 |
104 |
105 linenumber = opts.get('line_number') is not None |
105 linenumber = opts.get('line_number') is not None |
106 if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))): |
106 if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))): |
107 raise util.Abort(_('at least one of -n/-c is required for -l')) |
107 raise util.Abort(_('at least one of -n/-c is required for -l')) |
171 prefix = opts.get('prefix') |
171 prefix = opts.get('prefix') |
172 if dest == '-': |
172 if dest == '-': |
173 if kind == 'files': |
173 if kind == 'files': |
174 raise util.Abort(_('cannot archive plain files to stdout')) |
174 raise util.Abort(_('cannot archive plain files to stdout')) |
175 dest = sys.stdout |
175 dest = sys.stdout |
176 if not prefix: prefix = os.path.basename(repo.root) + '-%h' |
176 if not prefix: |
|
177 prefix = os.path.basename(repo.root) + '-%h' |
177 prefix = cmdutil.make_filename(repo, prefix, node) |
178 prefix = cmdutil.make_filename(repo, prefix, node) |
178 archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
179 archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
179 matchfn, prefix) |
180 matchfn, prefix) |
180 |
181 |
181 def backout(ui, repo, node=None, rev=None, **opts): |
182 def backout(ui, repo, node=None, rev=None, **opts): |
255 ui.status(_('changeset %s backs out changeset %s\n') % |
256 ui.status(_('changeset %s backs out changeset %s\n') % |
256 (nice(repo.changelog.tip()), nice(node))) |
257 (nice(repo.changelog.tip()), nice(node))) |
257 if op1 != node: |
258 if op1 != node: |
258 hg.clean(repo, op1, show_stats=False) |
259 hg.clean(repo, op1, show_stats=False) |
259 if opts.get('merge'): |
260 if opts.get('merge'): |
260 ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip())) |
261 ui.status(_('merging with changeset %s\n') |
|
262 % nice(repo.changelog.tip())) |
261 hg.merge(repo, hex(repo.changelog.tip())) |
263 hg.merge(repo, hex(repo.changelog.tip())) |
262 else: |
264 else: |
263 ui.status(_('the backout changeset is a new head - ' |
265 ui.status(_('the backout changeset is a new head - ' |
264 'do not forget to merge\n')) |
266 'do not forget to merge\n')) |
265 ui.status(_('(use "backout --merge" ' |
267 ui.status(_('(use "backout --merge" ' |
866 showdate = not nodates |
868 showdate = not nodates |
867 for file_, ent in sorted(repo.dirstate._map.iteritems()): |
869 for file_, ent in sorted(repo.dirstate._map.iteritems()): |
868 if showdate: |
870 if showdate: |
869 if ent[3] == -1: |
871 if ent[3] == -1: |
870 # Pad or slice to locale representation |
872 # Pad or slice to locale representation |
871 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0))) |
873 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", |
|
874 time.localtime(0))) |
872 timestr = 'unset' |
875 timestr = 'unset' |
873 timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr)) |
876 timestr = (timestr[:locale_len] + |
|
877 ' ' * (locale_len - len(timestr))) |
874 else: |
878 else: |
875 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])) |
879 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
|
880 time.localtime(ent[3])) |
876 if ent[1] & 020000: |
881 if ent[1] & 020000: |
877 mode = 'lnk' |
882 mode = 'lnk' |
878 else: |
883 else: |
879 mode = '%3o' % (ent[1] & 0777) |
884 mode = '%3o' % (ent[1] & 0777) |
880 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
885 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
882 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
887 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
883 |
888 |
884 def debugsub(ui, repo, rev=None): |
889 def debugsub(ui, repo, rev=None): |
885 if rev == '': |
890 if rev == '': |
886 rev = None |
891 rev = None |
887 for k,v in sorted(repo[rev].substate.items()): |
892 for k, v in sorted(repo[rev].substate.items()): |
888 ui.write('path %s\n' % k) |
893 ui.write('path %s\n' % k) |
889 ui.write(' source %s\n' % v[0]) |
894 ui.write(' source %s\n' % v[0]) |
890 ui.write(' revision %s\n' % v[1]) |
895 ui.write(' revision %s\n' % v[1]) |
891 |
896 |
892 def debugdata(ui, file_, rev): |
897 def debugdata(ui, file_, rev): |
1426 continue |
1431 continue |
1427 visitedset.add(branch) |
1432 visitedset.add(branch) |
1428 bheads = repo.branchheads(branch, start, closed=closed) |
1433 bheads = repo.branchheads(branch, start, closed=closed) |
1429 if not bheads: |
1434 if not bheads: |
1430 if not opts.get('rev'): |
1435 if not opts.get('rev'): |
1431 ui.warn(_("no open branch heads on branch %s\n") % encodedbranch) |
1436 ui.warn(_("no open branch heads on branch %s\n") |
|
1437 % encodedbranch) |
1432 elif branch != branchrev: |
1438 elif branch != branchrev: |
1433 ui.warn(_("no changes on branch %s containing %s are " |
1439 ui.warn(_("no changes on branch %s containing %s are " |
1434 "reachable from %s\n") |
1440 "reachable from %s\n") |
1435 % (encodedbranch, branchrev, opts.get('rev'))) |
1441 % (encodedbranch, branchrev, opts.get('rev'))) |
1436 else: |
1442 else: |
1638 # list all option lists |
1644 # list all option lists |
1639 opt_output = [] |
1645 opt_output = [] |
1640 for title, options in option_lists: |
1646 for title, options in option_lists: |
1641 opt_output.append(("\n%s" % title, None)) |
1647 opt_output.append(("\n%s" % title, None)) |
1642 for shortopt, longopt, default, desc in options: |
1648 for shortopt, longopt, default, desc in options: |
1643 if _("DEPRECATED") in desc and not ui.verbose: continue |
1649 if _("DEPRECATED") in desc and not ui.verbose: |
|
1650 continue |
1644 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
1651 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
1645 longopt and " --%s" % longopt), |
1652 longopt and " --%s" % longopt), |
1646 "%s%s" % (desc, |
1653 "%s%s" % (desc, |
1647 default |
1654 default |
1648 and _(" (default: %s)") % default |
1655 and _(" (default: %s)") % default |
1849 files = {} |
1856 files = {} |
1850 try: |
1857 try: |
1851 patch.patch(tmpname, ui, strip=strip, cwd=repo.root, |
1858 patch.patch(tmpname, ui, strip=strip, cwd=repo.root, |
1852 files=files, eolmode=None) |
1859 files=files, eolmode=None) |
1853 finally: |
1860 finally: |
1854 files = patch.updatedir(ui, repo, files, similarity=sim/100.) |
1861 files = patch.updatedir(ui, repo, files, |
|
1862 similarity=sim / 100.0) |
1855 if not opts.get('no_commit'): |
1863 if not opts.get('no_commit'): |
1856 m = cmdutil.matchfiles(repo, files or []) |
1864 m = cmdutil.matchfiles(repo, files or []) |
1857 n = repo.commit(message, opts.get('user') or user, |
1865 n = repo.commit(message, opts.get('user') or user, |
1858 opts.get('date') or date, match=m, |
1866 opts.get('date') or date, match=m, |
1859 editor=cmdutil.commiteditor) |
1867 editor=cmdutil.commiteditor) |
1974 end = opts.get('print0') and '\0' or '\n' |
1982 end = opts.get('print0') and '\0' or '\n' |
1975 rev = opts.get('rev') or None |
1983 rev = opts.get('rev') or None |
1976 |
1984 |
1977 ret = 1 |
1985 ret = 1 |
1978 m = cmdutil.match(repo, pats, opts, default='relglob') |
1986 m = cmdutil.match(repo, pats, opts, default='relglob') |
1979 m.bad = lambda x,y: False |
1987 m.bad = lambda x, y: False |
1980 for abs in repo[rev].walk(m): |
1988 for abs in repo[rev].walk(m): |
1981 if not rev and abs not in repo.dirstate: |
1989 if not rev and abs not in repo.dirstate: |
1982 continue |
1990 continue |
1983 if opts.get('fullpath'): |
1991 if opts.get('fullpath'): |
1984 ui.write(repo.wjoin(abs), end) |
1992 ui.write(repo.wjoin(abs), end) |
2166 |
2174 |
2167 See pull for valid destination format details. |
2175 See pull for valid destination format details. |
2168 """ |
2176 """ |
2169 limit = cmdutil.loglimit(opts) |
2177 limit = cmdutil.loglimit(opts) |
2170 dest, revs, checkout = hg.parseurl( |
2178 dest, revs, checkout = hg.parseurl( |
2171 ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) |
2179 ui.expandpath(dest or 'default-push', dest or 'default'), |
|
2180 opts.get('rev')) |
2172 if revs: |
2181 if revs: |
2173 revs = [repo.lookup(rev) for rev in revs] |
2182 revs = [repo.lookup(rev) for rev in revs] |
2174 |
2183 |
2175 other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
2184 other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
2176 ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
2185 ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
2322 |
2331 |
2323 Please see 'hg help urls' for important details about ``ssh://`` |
2332 Please see 'hg help urls' for important details about ``ssh://`` |
2324 URLs. If DESTINATION is omitted, a default path will be used. |
2333 URLs. If DESTINATION is omitted, a default path will be used. |
2325 """ |
2334 """ |
2326 dest, revs, checkout = hg.parseurl( |
2335 dest, revs, checkout = hg.parseurl( |
2327 ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) |
2336 ui.expandpath(dest or 'default-push', dest or 'default'), |
|
2337 opts.get('rev')) |
2328 other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
2338 other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
2329 ui.status(_('pushing to %s\n') % url.hidepassword(dest)) |
2339 ui.status(_('pushing to %s\n') % url.hidepassword(dest)) |
2330 if revs: |
2340 if revs: |
2331 revs = [repo.lookup(rev) for rev in revs] |
2341 revs = [repo.lookup(rev) for rev in revs] |
2332 |
2342 |
2559 wlock = repo.wlock() |
2569 wlock = repo.wlock() |
2560 try: |
2570 try: |
2561 # walk dirstate. |
2571 # walk dirstate. |
2562 |
2572 |
2563 m = cmdutil.match(repo, pats, opts) |
2573 m = cmdutil.match(repo, pats, opts) |
2564 m.bad = lambda x,y: False |
2574 m.bad = lambda x, y: False |
2565 for abs in repo.walk(m): |
2575 for abs in repo.walk(m): |
2566 names[abs] = m.rel(abs), m.exact(abs) |
2576 names[abs] = m.rel(abs), m.exact(abs) |
2567 |
2577 |
2568 # walk target manifest. |
2578 # walk target manifest. |
2569 |
2579 |
2632 msg = xlist[1] |
2642 msg = xlist[1] |
2633 if not isinstance(msg, basestring): |
2643 if not isinstance(msg, basestring): |
2634 msg = msg(abs) |
2644 msg = msg(abs) |
2635 ui.status(msg % rel) |
2645 ui.status(msg % rel) |
2636 for table, hitlist, misslist, backuphit, backupmiss in disptable: |
2646 for table, hitlist, misslist, backuphit, backupmiss in disptable: |
2637 if abs not in table: continue |
2647 if abs not in table: |
|
2648 continue |
2638 # file has changed in dirstate |
2649 # file has changed in dirstate |
2639 if mfentry: |
2650 if mfentry: |
2640 handle(hitlist, backuphit) |
2651 handle(hitlist, backuphit) |
2641 elif misslist is not None: |
2652 elif misslist is not None: |
2642 handle(misslist, backupmiss) |
2653 handle(misslist, backupmiss) |
2648 elif exact: |
2659 elif exact: |
2649 ui.warn(_('file not managed: %s\n') % rel) |
2660 ui.warn(_('file not managed: %s\n') % rel) |
2650 continue |
2661 continue |
2651 # file has not changed in dirstate |
2662 # file has not changed in dirstate |
2652 if node == parent: |
2663 if node == parent: |
2653 if exact: ui.warn(_('no changes needed to %s\n') % rel) |
2664 if exact: |
|
2665 ui.warn(_('no changes needed to %s\n') % rel) |
2654 continue |
2666 continue |
2655 if pmf is None: |
2667 if pmf is None: |
2656 # only need parent manifest in this unlikely case, |
2668 # only need parent manifest in this unlikely case, |
2657 # so do not read by default |
2669 # so do not read by default |
2658 pmf = repo[parent].manifest() |
2670 pmf = repo[parent].manifest() |
2937 st.append([f for f in ms if f == 'u']) |
2950 st.append([f for f in ms if f == 'u']) |
2938 labels = [_('%d modified'), _('%d added'), _('%d removed'), |
2951 labels = [_('%d modified'), _('%d added'), _('%d removed'), |
2939 _('%d deleted'), _('%d unknown'), _('%d ignored'), |
2952 _('%d deleted'), _('%d unknown'), _('%d ignored'), |
2940 _('%d unresolved')] |
2953 _('%d unresolved')] |
2941 t = [] |
2954 t = [] |
2942 for s,l in zip(st, labels): |
2955 for s, l in zip(st, labels): |
2943 if s: |
2956 if s: |
2944 t.append(l % len(s)) |
2957 t.append(l % len(s)) |
2945 |
2958 |
2946 t = ', '.join(t) |
2959 t = ', '.join(t) |
2947 cleanworkdir = False |
2960 cleanworkdir = False |
3461 "grep": |
3474 "grep": |
3462 (grep, |
3475 (grep, |
3463 [('0', 'print0', None, _('end fields with NUL')), |
3476 [('0', 'print0', None, _('end fields with NUL')), |
3464 ('', 'all', None, _('print all revisions that match')), |
3477 ('', 'all', None, _('print all revisions that match')), |
3465 ('f', 'follow', None, |
3478 ('f', 'follow', None, |
3466 _('follow changeset history, or file history across copies and renames')), |
3479 _('follow changeset history,' |
|
3480 ' or file history across copies and renames')), |
3467 ('i', 'ignore-case', None, _('ignore case when matching')), |
3481 ('i', 'ignore-case', None, _('ignore case when matching')), |
3468 ('l', 'files-with-matches', None, |
3482 ('l', 'files-with-matches', None, |
3469 _('print only filenames and revisions that match')), |
3483 _('print only filenames and revisions that match')), |
3470 ('n', 'line-number', None, _('print matching line numbers')), |
3484 ('n', 'line-number', None, _('print matching line numbers')), |
3471 ('r', 'rev', [], _('search in given revision range')), |
3485 ('r', 'rev', [], _('search in given revision range')), |
3497 _('directory strip option for patch. This has the same ' |
3511 _('directory strip option for patch. This has the same ' |
3498 'meaning as the corresponding patch option')), |
3512 'meaning as the corresponding patch option')), |
3499 ('b', 'base', '', _('base path')), |
3513 ('b', 'base', '', _('base path')), |
3500 ('f', 'force', None, |
3514 ('f', 'force', None, |
3501 _('skip check for outstanding uncommitted changes')), |
3515 _('skip check for outstanding uncommitted changes')), |
3502 ('', 'no-commit', None, _("don't commit, just update the working directory")), |
3516 ('', 'no-commit', None, |
|
3517 _("don't commit, just update the working directory")), |
3503 ('', 'exact', None, |
3518 ('', 'exact', None, |
3504 _('apply patch to the nodes from which it was generated')), |
3519 _('apply patch to the nodes from which it was generated')), |
3505 ('', 'import-branch', None, |
3520 ('', 'import-branch', None, |
3506 _('use any branch information in patch (implied by --exact)'))] + |
3521 _('use any branch information in patch (implied by --exact)'))] + |
3507 commitopts + commitopts2 + similarityopts, |
3522 commitopts + commitopts2 + similarityopts, |
3531 ] + walkopts, |
3546 ] + walkopts, |
3532 _('[OPTION]... [PATTERN]...')), |
3547 _('[OPTION]... [PATTERN]...')), |
3533 "^log|history": |
3548 "^log|history": |
3534 (log, |
3549 (log, |
3535 [('f', 'follow', None, |
3550 [('f', 'follow', None, |
3536 _('follow changeset history, or file history across copies and renames')), |
3551 _('follow changeset history,' |
|
3552 ' or file history across copies and renames')), |
3537 ('', 'follow-first', None, |
3553 ('', 'follow-first', None, |
3538 _('only follow the first parent of merge changesets')), |
3554 _('only follow the first parent of merge changesets')), |
3539 ('d', 'date', '', _('show revisions matching date spec')), |
3555 ('d', 'date', '', _('show revisions matching date spec')), |
3540 ('C', 'copies', None, _('show copied files')), |
3556 ('C', 'copies', None, _('show copied files')), |
3541 ('k', 'keyword', [], _('do case-insensitive search for a keyword')), |
3557 ('k', 'keyword', [], _('do case-insensitive search for a keyword')), |
3543 ('', 'removed', None, _('include revisions where files were removed')), |
3559 ('', 'removed', None, _('include revisions where files were removed')), |
3544 ('m', 'only-merges', None, _('show only merges')), |
3560 ('m', 'only-merges', None, _('show only merges')), |
3545 ('u', 'user', [], _('revisions committed by user')), |
3561 ('u', 'user', [], _('revisions committed by user')), |
3546 ('b', 'only-branch', [], |
3562 ('b', 'only-branch', [], |
3547 _('show only changesets within the given named branch')), |
3563 _('show only changesets within the given named branch')), |
3548 ('P', 'prune', [], _('do not display revision or any of its ancestors')), |
3564 ('P', 'prune', [], |
|
3565 _('do not display revision or any of its ancestors')), |
3549 ] + logopts + walkopts, |
3566 ] + logopts + walkopts, |
3550 _('[OPTION]... [FILE]')), |
3567 _('[OPTION]... [FILE]')), |
3551 "manifest": |
3568 "manifest": |
3552 (manifest, |
3569 (manifest, |
3553 [('r', 'rev', '', _('revision to display'))], |
3570 [('r', 'rev', '', _('revision to display'))], |
3630 [('A', 'accesslog', '', _('name of access log file to write to')), |
3647 [('A', 'accesslog', '', _('name of access log file to write to')), |
3631 ('d', 'daemon', None, _('run server in background')), |
3648 ('d', 'daemon', None, _('run server in background')), |
3632 ('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
3649 ('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
3633 ('E', 'errorlog', '', _('name of error log file to write to')), |
3650 ('E', 'errorlog', '', _('name of error log file to write to')), |
3634 ('p', 'port', 0, _('port to listen on (default: 8000)')), |
3651 ('p', 'port', 0, _('port to listen on (default: 8000)')), |
3635 ('a', 'address', '', _('address to listen on (default: all interfaces)')), |
3652 ('a', 'address', '', |
3636 ('', 'prefix', '', _('prefix path to serve from (default: server root)')), |
3653 _('address to listen on (default: all interfaces)')), |
|
3654 ('', 'prefix', '', |
|
3655 _('prefix path to serve from (default: server root)')), |
3637 ('n', 'name', '', |
3656 ('n', 'name', '', |
3638 _('name to show in web pages (default: working directory)')), |
3657 _('name to show in web pages (default: working directory)')), |
3639 ('', 'webdir-conf', '', _('name of the webdir config file' |
3658 ('', 'webdir-conf', '', _('name of the webdir config file' |
3640 ' (serve more than one repository)')), |
3659 ' (serve more than one repository)')), |
3641 ('', 'pid-file', '', _('name of file to write process ID to')), |
3660 ('', 'pid-file', '', _('name of file to write process ID to')), |