Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 1062:6d5a62a549fa
pep-0008 cleanup
- Don't use spaces around the '=' sign when used to indicate a
keyword argument or a default parameter value.
author | benoit.boissinot@ens-lyon.fr |
---|---|
date | Fri, 26 Aug 2005 13:06:58 +0200 |
parents | fed8d078840b |
children | 6e94c0365d98 |
comparison
equal
deleted
inserted
replaced
1061:fed8d078840b | 1062:6d5a62a549fa |
---|---|
27 cwd = repo.getcwd() | 27 cwd = repo.getcwd() |
28 if cwd: | 28 if cwd: |
29 return [util.normpath(os.path.join(cwd, x)) for x in args] | 29 return [util.normpath(os.path.join(cwd, x)) for x in args] |
30 return args | 30 return args |
31 | 31 |
32 def matchpats(repo, cwd, pats = [], opts = {}, head = ''): | 32 def matchpats(repo, cwd, pats=[], opts={}, head=''): |
33 return util.matcher(repo, cwd, pats or ['.'], opts.get('include'), | 33 return util.matcher(repo, cwd, pats or ['.'], opts.get('include'), |
34 opts.get('exclude'), head) | 34 opts.get('exclude'), head) |
35 | 35 |
36 def makewalk(repo, pats, opts, head = ''): | 36 def makewalk(repo, pats, opts, head=''): |
37 cwd = repo.getcwd() | 37 cwd = repo.getcwd() |
38 files, matchfn, anypats = matchpats(repo, cwd, pats, opts, head) | 38 files, matchfn, anypats = matchpats(repo, cwd, pats, opts, head) |
39 exact = dict(zip(files, files)) | 39 exact = dict(zip(files, files)) |
40 def walk(): | 40 def walk(): |
41 for src, fn in repo.walk(files = files, match = matchfn): | 41 for src, fn in repo.walk(files=files, match=matchfn): |
42 yield src, fn, util.pathto(cwd, fn), fn in exact | 42 yield src, fn, util.pathto(cwd, fn), fn in exact |
43 return files, matchfn, walk() | 43 return files, matchfn, walk() |
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: yield r | 47 for r in results: yield r |
48 | 48 |
49 def walkchangerevs(ui, repo, cwd, pats, opts): | 49 def walkchangerevs(ui, repo, cwd, pats, opts): |
50 # This code most commonly needs to iterate backwards over the | 50 # This code most commonly needs to iterate backwards over the |
218 changes=None, text=False): | 218 changes=None, text=False): |
219 def date(c): | 219 def date(c): |
220 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) | 220 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
221 | 221 |
222 if not changes: | 222 if not changes: |
223 (c, a, d, u) = repo.changes(node1, node2, files, match = match) | 223 (c, a, d, u) = repo.changes(node1, node2, files, match=match) |
224 else: | 224 else: |
225 (c, a, d, u) = changes | 225 (c, a, d, u) = changes |
226 if files: | 226 if files: |
227 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) | 227 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) |
228 | 228 |
624 opts['include'] = [os.path.join(cwd, i) for i in opts['include']] | 624 opts['include'] = [os.path.join(cwd, i) for i in opts['include']] |
625 opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] | 625 opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] |
626 fns, match, anypats = matchpats(repo, (pats and repo.getcwd()) or '', | 626 fns, match, anypats = matchpats(repo, (pats and repo.getcwd()) or '', |
627 pats, opts) | 627 pats, opts) |
628 if pats: | 628 if pats: |
629 c, a, d, u = repo.changes(files = fns, match = match) | 629 c, a, d, u = repo.changes(files=fns, match=match) |
630 files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] | 630 files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] |
631 else: | 631 else: |
632 files = [] | 632 files = [] |
633 repo.commit(files, message, opts['user'], opts['date'], match) | 633 repo.commit(files, message, opts['user'], opts['date'], match) |
634 | 634 |
791 if repo.dirstate.state(abs) == 'a': | 791 if repo.dirstate.state(abs) == 'a': |
792 forget.append(abs) | 792 forget.append(abs) |
793 if not exact: ui.status('forgetting ', rel, '\n') | 793 if not exact: ui.status('forgetting ', rel, '\n') |
794 repo.forget(forget) | 794 repo.forget(forget) |
795 | 795 |
796 def grep(ui, repo, pattern = None, *pats, **opts): | 796 def grep(ui, repo, pattern=None, *pats, **opts): |
797 """search for a pattern in specified files and revisions""" | 797 """search for a pattern in specified files and revisions""" |
798 if pattern is None: pattern = opts['regexp'] | 798 if pattern is None: pattern = opts['regexp'] |
799 if not pattern: raise util.Abort('no pattern to search for') | 799 if not pattern: raise util.Abort('no pattern to search for') |
800 reflags = 0 | 800 reflags = 0 |
801 if opts['ignore_case']: reflags |= re.I | 801 if opts['ignore_case']: reflags |= re.I |
1087 | 1087 |
1088 for n in p: | 1088 for n in p: |
1089 if n != hg.nullid: | 1089 if n != hg.nullid: |
1090 show_changeset(ui, repo, changenode=n) | 1090 show_changeset(ui, repo, changenode=n) |
1091 | 1091 |
1092 def paths(ui, search = None): | 1092 def paths(ui, search=None): |
1093 """show definition of symbolic path names""" | 1093 """show definition of symbolic path names""" |
1094 try: | 1094 try: |
1095 repo = hg.repository(ui=ui) | 1095 repo = hg.repository(ui=ui) |
1096 except: | 1096 except: |
1097 pass | 1097 pass |