Show More
@@ -44,7 +44,8 b" def makewalk(repo, pats, opts, head=''):" | |||||
44 |
|
44 | |||
45 | def walk(repo, pats, opts, head=''): |
|
45 | def walk(repo, pats, opts, head=''): | |
46 | files, matchfn, results = makewalk(repo, pats, opts, head) |
|
46 | files, matchfn, results = makewalk(repo, pats, opts, head) | |
47 |
for r in results: |
|
47 | for r in results: | |
|
48 | yield r | |||
48 |
|
49 | |||
49 | def walkchangerevs(ui, repo, cwd, pats, opts): |
|
50 | def walkchangerevs(ui, repo, cwd, pats, opts): | |
50 | # This code most commonly needs to iterate backwards over the |
|
51 | # This code most commonly needs to iterate backwards over the | |
@@ -88,7 +89,8 b' def walkchangerevs(ui, repo, cwd, pats, ' | |||||
88 | break |
|
89 | break | |
89 | for rev in filerevgen(filelog): |
|
90 | for rev in filerevgen(filelog): | |
90 | if rev <= maxrev: |
|
91 | if rev <= maxrev: | |
91 |
if rev < minrev: |
|
92 | if rev < minrev: | |
|
93 | break | |||
92 | fncache.setdefault(rev, []) |
|
94 | fncache.setdefault(rev, []) | |
93 | fncache[rev].append(file) |
|
95 | fncache[rev].append(file) | |
94 | wanted[rev] = 1 |
|
96 | wanted[rev] = 1 | |
@@ -205,8 +207,7 b' def make_filename(repo, r, pat, node=Non' | |||||
205 | def make_file(repo, r, pat, node=None, |
|
207 | def make_file(repo, r, pat, node=None, | |
206 | total=None, seqno=None, revwidth=None, mode='wb'): |
|
208 | total=None, seqno=None, revwidth=None, mode='wb'): | |
207 | if not pat or pat == '-': |
|
209 | if not pat or pat == '-': | |
208 |
|
|
210 | return 'w' in mode and sys.stdout or sys.stdin | |
209 | else: return sys.stdin |
|
|||
210 | if hasattr(pat, 'write') and 'w' in mode: |
|
211 | if hasattr(pat, 'write') and 'w' in mode: | |
211 | return pat |
|
212 | return pat | |
212 | if hasattr(pat, 'read') and 'r' in mode: |
|
213 | if hasattr(pat, 'read') and 'r' in mode: | |
@@ -455,10 +456,12 b' def addremove(ui, repo, *pats, **opts):' | |||||
455 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
456 | for src, abs, rel, exact in walk(repo, pats, opts): | |
456 | if src == 'f' and repo.dirstate.state(abs) == '?': |
|
457 | if src == 'f' and repo.dirstate.state(abs) == '?': | |
457 | add.append(abs) |
|
458 | add.append(abs) | |
458 |
if not exact: |
|
459 | if not exact: | |
|
460 | ui.status('adding ', rel, '\n') | |||
459 | if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): |
|
461 | if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): | |
460 | remove.append(abs) |
|
462 | remove.append(abs) | |
461 | if not exact: ui.status('removing ', rel, '\n') |
|
463 | if not exact: | |
|
464 | ui.status('removing ', rel, '\n') | |||
462 | repo.add(add) |
|
465 | repo.add(add) | |
463 | repo.remove(remove) |
|
466 | repo.remove(remove) | |
464 |
|
467 | |||
@@ -672,7 +675,8 b' def debugconfig(ui):' | |||||
672 | """show combined config settings from all hgrc files""" |
|
675 | """show combined config settings from all hgrc files""" | |
673 | try: |
|
676 | try: | |
674 | repo = hg.repository(ui) |
|
677 | repo = hg.repository(ui) | |
675 | except: pass |
|
678 | except hg.RepoError: | |
|
679 | pass | |||
676 | for section, name, value in ui.walkconfig(): |
|
680 | for section, name, value in ui.walkconfig(): | |
677 | ui.write('%s.%s=%s\n' % (section, name, value)) |
|
681 | ui.write('%s.%s=%s\n' % (section, name, value)) | |
678 |
|
682 | |||
@@ -718,13 +722,13 b' def debugindexdot(ui, file_):' | |||||
718 | def debugwalk(ui, repo, *pats, **opts): |
|
722 | def debugwalk(ui, repo, *pats, **opts): | |
719 | """show how files match on given patterns""" |
|
723 | """show how files match on given patterns""" | |
720 | items = list(walk(repo, pats, opts)) |
|
724 | items = list(walk(repo, pats, opts)) | |
721 |
if not items: |
|
725 | if not items: | |
|
726 | return | |||
722 | fmt = '%%s %%-%ds %%-%ds %%s\n' % ( |
|
727 | fmt = '%%s %%-%ds %%-%ds %%s\n' % ( | |
723 | max([len(abs) for (src, abs, rel, exact) in items]), |
|
728 | max([len(abs) for (src, abs, rel, exact) in items]), | |
724 | max([len(rel) for (src, abs, rel, exact) in items])) |
|
729 | max([len(rel) for (src, abs, rel, exact) in items])) | |
725 | exactly = {True: 'exact', False: ''} |
|
|||
726 | for src, abs, rel, exact in items: |
|
730 | for src, abs, rel, exact in items: | |
727 |
ui.write(fmt % (src, abs, rel, |
|
731 | ui.write(fmt % (src, abs, rel, exact and 'exact' or '')) | |
728 |
|
732 | |||
729 | def diff(ui, repo, *pats, **opts): |
|
733 | def diff(ui, repo, *pats, **opts): | |
730 | """diff working directory (or selected files)""" |
|
734 | """diff working directory (or selected files)""" | |
@@ -769,7 +773,8 b' def doexport(ui, repo, changeset, seqno,' | |||||
769 | fp.write("\n\n") |
|
773 | fp.write("\n\n") | |
770 |
|
774 | |||
771 | dodiff(fp, ui, repo, prev, node, text=opts['text']) |
|
775 | dodiff(fp, ui, repo, prev, node, text=opts['text']) | |
772 |
if fp != sys.stdout: |
|
776 | if fp != sys.stdout: | |
|
777 | fp.close() | |||
773 |
|
778 | |||
774 | def export(ui, repo, *changesets, **opts): |
|
779 | def export(ui, repo, *changesets, **opts): | |
775 | """dump the header and diffs for one or more changesets""" |
|
780 | """dump the header and diffs for one or more changesets""" | |
@@ -790,18 +795,23 b' def forget(ui, repo, *pats, **opts):' | |||||
790 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
795 | for src, abs, rel, exact in walk(repo, pats, opts): | |
791 | if repo.dirstate.state(abs) == 'a': |
|
796 | if repo.dirstate.state(abs) == 'a': | |
792 | forget.append(abs) |
|
797 | forget.append(abs) | |
793 | if not exact: ui.status('forgetting ', rel, '\n') |
|
798 | if not exact: | |
|
799 | ui.status('forgetting ', rel, '\n') | |||
794 | repo.forget(forget) |
|
800 | repo.forget(forget) | |
795 |
|
801 | |||
796 | def grep(ui, repo, pattern=None, *pats, **opts): |
|
802 | def grep(ui, repo, pattern=None, *pats, **opts): | |
797 | """search for a pattern in specified files and revisions""" |
|
803 | """search for a pattern in specified files and revisions""" | |
798 |
if pattern is None: |
|
804 | if pattern is None: | |
799 | if not pattern: raise util.Abort('no pattern to search for') |
|
805 | pattern = opts['regexp'] | |
|
806 | if not pattern: | |||
|
807 | raise util.Abort('no pattern to search for') | |||
800 | reflags = 0 |
|
808 | reflags = 0 | |
801 |
if opts['ignore_case']: |
|
809 | if opts['ignore_case']: | |
|
810 | reflags |= re.I | |||
802 | regexp = re.compile(pattern, reflags) |
|
811 | regexp = re.compile(pattern, reflags) | |
803 | sep, end = ':', '\n' |
|
812 | sep, end = ':', '\n' | |
804 |
if opts['null'] or opts['print0']: |
|
813 | if opts['null'] or opts['print0']: | |
|
814 | sep = end = '\0' | |||
805 |
|
815 | |||
806 | fcache = {} |
|
816 | fcache = {} | |
807 | def getfile(fn): |
|
817 | def getfile(fn): | |
@@ -814,7 +824,8 b' def grep(ui, repo, pattern=None, *pats, ' | |||||
814 | linenum = 0 |
|
824 | linenum = 0 | |
815 | while True: |
|
825 | while True: | |
816 | match = regexp.search(body, begin) |
|
826 | match = regexp.search(body, begin) | |
817 |
if not match: |
|
827 | if not match: | |
|
828 | break | |||
818 | mstart, mend = match.span() |
|
829 | mstart, mend = match.span() | |
819 | linenum += body.count('\n', begin, mstart) + 1 |
|
830 | linenum += body.count('\n', begin, mstart) + 1 | |
820 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
831 | lstart = body.rfind('\n', begin, mstart) + 1 or begin | |
@@ -828,8 +839,10 b' def grep(ui, repo, pattern=None, *pats, ' | |||||
828 | self.linenum = linenum |
|
839 | self.linenum = linenum | |
829 | self.colstart = colstart |
|
840 | self.colstart = colstart | |
830 | self.colend = colend |
|
841 | self.colend = colend | |
831 |
def __eq__(self, other): |
|
842 | def __eq__(self, other): | |
832 | def __hash__(self): return hash(self.line) |
|
843 | return self.line == other.line | |
|
844 | def __hash__(self): | |||
|
845 | return hash(self.line) | |||
833 |
|
846 | |||
834 | matches = {} |
|
847 | matches = {} | |
835 | def grepbody(fn, rev, body): |
|
848 | def grepbody(fn, rev, body): | |
@@ -999,11 +1012,11 b' def init(ui, dest="."):' | |||||
999 |
|
1012 | |||
1000 | def locate(ui, repo, *pats, **opts): |
|
1013 | def locate(ui, repo, *pats, **opts): | |
1001 | """locate files matching specific patterns""" |
|
1014 | """locate files matching specific patterns""" | |
1002 | end = '\n' |
|
1015 | end = opts['print0'] and '\0' or '\n' | |
1003 | if opts['print0']: end = '\0' |
|
|||
1004 |
|
1016 | |||
1005 | for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'): |
|
1017 | for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'): | |
1006 |
if repo.dirstate.state(abs) == '?': |
|
1018 | if repo.dirstate.state(abs) == '?': | |
|
1019 | continue | |||
1007 | if opts['fullpath']: |
|
1020 | if opts['fullpath']: | |
1008 | ui.write(os.path.join(repo.root, abs), end) |
|
1021 | ui.write(os.path.join(repo.root, abs), end) | |
1009 | else: |
|
1022 | else: | |
@@ -1021,9 +1034,11 b' def log(ui, repo, *pats, **opts):' | |||||
1021 | self.rev = rev |
|
1034 | self.rev = rev | |
1022 | self.hunk[rev] = [] |
|
1035 | self.hunk[rev] = [] | |
1023 | def note(self, *args): |
|
1036 | def note(self, *args): | |
1024 |
if self.verbose: |
|
1037 | if self.verbose: | |
|
1038 | self.write(*args) | |||
1025 | def status(self, *args): |
|
1039 | def status(self, *args): | |
1026 |
if not self.quiet: |
|
1040 | if not self.quiet: | |
|
1041 | self.write(*args) | |||
1027 | def write(self, *args): |
|
1042 | def write(self, *args): | |
1028 | self.hunk[self.rev].append(args) |
|
1043 | self.hunk[self.rev].append(args) | |
1029 | def __getattr__(self, key): |
|
1044 | def __getattr__(self, key): | |
@@ -1093,7 +1108,7 b' def paths(ui, search=None):' | |||||
1093 | """show definition of symbolic path names""" |
|
1108 | """show definition of symbolic path names""" | |
1094 | try: |
|
1109 | try: | |
1095 | repo = hg.repository(ui=ui) |
|
1110 | repo = hg.repository(ui=ui) | |
1096 | except: |
|
1111 | except hg.RepoError: | |
1097 | pass |
|
1112 | pass | |
1098 |
|
1113 | |||
1099 | if search: |
|
1114 | if search: | |
@@ -1520,7 +1535,8 b' table = {' | |||||
1520 | [('I', 'include', [], 'include path in search'), |
|
1535 | [('I', 'include', [], 'include path in search'), | |
1521 | ('X', 'exclude', [], 'exclude path from search')], |
|
1536 | ('X', 'exclude', [], 'exclude path from search')], | |
1522 | "hg forget [OPTION]... FILE..."), |
|
1537 | "hg forget [OPTION]... FILE..."), | |
1523 |
"grep": |
|
1538 | "grep": | |
|
1539 | (grep, | |||
1524 |
|
|
1540 | [('0', 'print0', None, 'terminate file names with NUL'), | |
1525 |
|
|
1541 | ('I', 'include', [], 'include path in search'), | |
1526 |
|
|
1542 | ('X', 'exclude', [], 'include path in search'), | |
@@ -1654,8 +1670,8 b' globalopts = [' | |||||
1654 | ('h', 'help', None, 'display help and exit'), |
|
1670 | ('h', 'help', None, 'display help and exit'), | |
1655 | ] |
|
1671 | ] | |
1656 |
|
1672 | |||
1657 |
norepo = "clone init version help debugconfig debugdata" |
|
1673 | norepo = ("clone init version help debugconfig debugdata" | |
1658 | " debugindex debugindexdot paths" |
|
1674 | " debugindex debugindexdot paths") | |
1659 |
|
1675 | |||
1660 | def find(cmd): |
|
1676 | def find(cmd): | |
1661 | for e in table.keys(): |
|
1677 | for e in table.keys(): | |
@@ -1812,7 +1828,8 b' def dispatch(args):' | |||||
1812 | elif hasattr(inst, "reason"): |
|
1828 | elif hasattr(inst, "reason"): | |
1813 | u.warn("abort: error: %s\n" % inst.reason[1]) |
|
1829 | u.warn("abort: error: %s\n" % inst.reason[1]) | |
1814 | elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
|
1830 | elif hasattr(inst, "args") and inst[0] == errno.EPIPE: | |
1815 |
if u.debugflag: |
|
1831 | if u.debugflag: | |
|
1832 | u.warn("broken pipe\n") | |||
1816 | else: |
|
1833 | else: | |
1817 | raise |
|
1834 | raise | |
1818 | except OSError, inst: |
|
1835 | except OSError, inst: |
General Comments 0
You need to be logged in to leave comments.
Login now