comparison mercurial/commands.py @ 1109:ee817c5e3ece

Merge with TAH
author mpm@selenic.com
date Sat, 27 Aug 2005 17:26:26 -0700
parents 1f1661c58283 7a75d8fbbdaf
children 6130de75bb2a
comparison
equal deleted inserted replaced
1104:98988cc3723a 1109:ee817c5e3ece
794 forget.append(abs) 794 forget.append(abs)
795 if not exact: 795 if not exact:
796 ui.status('forgetting ', rel, '\n') 796 ui.status('forgetting ', rel, '\n')
797 repo.forget(forget) 797 repo.forget(forget)
798 798
799 def grep(ui, repo, pattern=None, *pats, **opts): 799 def grep(ui, repo, pattern, *pats, **opts):
800 """search for a pattern in specified files and revisions""" 800 """search for a pattern in specified files and revisions"""
801 if pattern is None:
802 pattern = opts['regexp']
803 if not pattern:
804 raise util.Abort('no pattern to search for')
805 reflags = 0 801 reflags = 0
806 if opts['ignore_case']: 802 if opts['ignore_case']:
807 reflags |= re.I 803 reflags |= re.I
808 regexp = re.compile(pattern, reflags) 804 regexp = re.compile(pattern, reflags)
809 sep, end = ':', '\n' 805 sep, end = ':', '\n'
810 if opts['null'] or opts['print0']: 806 if opts['print0']:
811 sep = end = '\0' 807 sep = end = '\0'
812 808
813 fcache = {} 809 fcache = {}
814 def getfile(fn): 810 def getfile(fn):
815 if fn not in fcache: 811 if fn not in fcache:
1347 ('added', 'A', a), 1343 ('added', 'A', a),
1348 ('removed', 'R', d), 1344 ('removed', 'R', d),
1349 ('unknown', '?', u)] 1345 ('unknown', '?', u)]
1350 1346
1351 end = opts['print0'] and '\0' or '\n' 1347 end = opts['print0'] and '\0' or '\n'
1352 1348
1353 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]] 1349 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
1354 or changetypes): 1350 or changetypes):
1355 if opts['strip']: 1351 if opts['no_status']:
1356 format = "%%s%s" % end 1352 format = "%%s%s" % end
1357 else: 1353 else:
1358 format = "%s %%s%s" % (char, end); 1354 format = "%s %%s%s" % (char, end);
1359 1355
1360 for f in changes: 1356 for f in changes:
1361 ui.write(format % f) 1357 ui.write(format % f)
1362 1358
1363 def tag(ui, repo, name, rev=None, **opts): 1359 def tag(ui, repo, name, rev=None, **opts):
1364 """add a tag for the current tip or a given revision""" 1360 """add a tag for the current tip or a given revision"""
1542 "grep": 1538 "grep":
1543 (grep, 1539 (grep,
1544 [('0', 'print0', None, 'terminate file names with NUL'), 1540 [('0', 'print0', None, 'terminate file names with NUL'),
1545 ('I', 'include', [], 'include path in search'), 1541 ('I', 'include', [], 'include path in search'),
1546 ('X', 'exclude', [], 'include path in search'), 1542 ('X', 'exclude', [], 'include path in search'),
1547 ('Z', 'null', None, 'terminate file names with NUL'),
1548 ('a', 'all-revs', '', 'search all revs'),
1549 ('e', 'regexp', '', 'pattern to search for'),
1550 ('f', 'full-path', None, 'print complete paths'),
1551 ('i', 'ignore-case', None, 'ignore case when matching'), 1543 ('i', 'ignore-case', None, 'ignore case when matching'),
1552 ('l', 'files-with-matches', None, 'print names of files with matches'), 1544 ('l', 'files-with-matches', None, 'print names of files with matches'),
1553 ('n', 'line-number', '', 'print line numbers'), 1545 ('n', 'line-number', '', 'print line numbers'),
1554 ('r', 'rev', [], 'search in revision rev'), 1546 ('r', 'rev', [], 'search in revision rev')],
1555 ('s', 'no-messages', None, 'do not print error messages'), 1547 "hg grep [OPTION]... PATTERN [FILE]..."),
1556 ('v', 'invert-match', None, 'select non-matching lines')],
1557 "hg grep [OPTION]... [PATTERN] [FILE]..."),
1558 "heads": 1548 "heads":
1559 (heads, 1549 (heads,
1560 [('b', 'branches', None, 'find branch info')], 1550 [('b', 'branches', None, 'find branch info')],
1561 'hg heads [-b]'), 1551 'hg heads [-b]'),
1562 "help": (help_, [], 'hg help [COMMAND]'), 1552 "help": (help_, [], 'hg help [COMMAND]'),
1634 (status, 1624 (status,
1635 [('m', 'modified', None, 'show only modified files'), 1625 [('m', 'modified', None, 'show only modified files'),
1636 ('a', 'added', None, 'show only added files'), 1626 ('a', 'added', None, 'show only added files'),
1637 ('r', 'removed', None, 'show only removed files'), 1627 ('r', 'removed', None, 'show only removed files'),
1638 ('u', 'unknown', None, 'show only unknown (not tracked) files'), 1628 ('u', 'unknown', None, 'show only unknown (not tracked) files'),
1639 ('p', 'strip', None, 'strip status prefix'), 1629 ('n', 'no-status', None, 'hide status prefix'),
1640 ('0', 'print0', None, 'end records with NUL'), 1630 ('0', 'print0', None, 'end records with NUL'),
1641 ('I', 'include', [], 'include path in search'), 1631 ('I', 'include', [], 'include path in search'),
1642 ('X', 'exclude', [], 'exclude path from search')], 1632 ('X', 'exclude', [], 'exclude path from search')],
1643 "hg status [OPTION]... [FILE]..."), 1633 "hg status [OPTION]... [FILE]..."),
1644 "tag": 1634 "tag":