Show More
@@ -29,20 +29,20 b' def relpath(repo, args):' | |||
|
29 | 29 | return [util.normpath(os.path.join(cwd, x)) for x in args] |
|
30 | 30 | return args |
|
31 | 31 | |
|
32 |
def matchpats(repo, cwd, pats |
|
|
32 | def matchpats(repo, cwd, pats=[], opts={}, head=''): | |
|
33 | 33 | return util.matcher(repo, cwd, pats or ['.'], opts.get('include'), |
|
34 | 34 | opts.get('exclude'), head) |
|
35 | 35 | |
|
36 |
def makewalk(repo, pats, opts, head |
|
|
36 | def makewalk(repo, pats, opts, head=''): | |
|
37 | 37 | cwd = repo.getcwd() |
|
38 | 38 | files, matchfn, anypats = matchpats(repo, cwd, pats, opts, head) |
|
39 | 39 | exact = dict(zip(files, files)) |
|
40 | 40 | def walk(): |
|
41 |
for src, fn in repo.walk(files |
|
|
41 | for src, fn in repo.walk(files=files, match=matchfn): | |
|
42 | 42 | yield src, fn, util.pathto(cwd, fn), fn in exact |
|
43 | 43 | return files, matchfn, walk() |
|
44 | 44 | |
|
45 |
def walk(repo, pats, opts, head |
|
|
45 | def walk(repo, pats, opts, head=''): | |
|
46 | 46 | files, matchfn, results = makewalk(repo, pats, opts, head) |
|
47 | 47 | for r in results: yield r |
|
48 | 48 | |
@@ -220,7 +220,7 b' def dodiff(fp, ui, repo, node1, node2, f' | |||
|
220 | 220 | return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
|
221 | 221 | |
|
222 | 222 | if not changes: |
|
223 |
(c, a, d, u) = repo.changes(node1, node2, files, match |
|
|
223 | (c, a, d, u) = repo.changes(node1, node2, files, match=match) | |
|
224 | 224 | else: |
|
225 | 225 | (c, a, d, u) = changes |
|
226 | 226 | if files: |
@@ -626,7 +626,7 b' def commit(ui, repo, *pats, **opts):' | |||
|
626 | 626 | fns, match, anypats = matchpats(repo, (pats and repo.getcwd()) or '', |
|
627 | 627 | pats, opts) |
|
628 | 628 | if pats: |
|
629 |
c, a, d, u = repo.changes(files |
|
|
629 | c, a, d, u = repo.changes(files=fns, match=match) | |
|
630 | 630 | files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] |
|
631 | 631 | else: |
|
632 | 632 | files = [] |
@@ -793,7 +793,7 b' def forget(ui, repo, *pats, **opts):' | |||
|
793 | 793 | if not exact: ui.status('forgetting ', rel, '\n') |
|
794 | 794 | repo.forget(forget) |
|
795 | 795 | |
|
796 |
def grep(ui, repo, pattern |
|
|
796 | def grep(ui, repo, pattern=None, *pats, **opts): | |
|
797 | 797 | """search for a pattern in specified files and revisions""" |
|
798 | 798 | if pattern is None: pattern = opts['regexp'] |
|
799 | 799 | if not pattern: raise util.Abort('no pattern to search for') |
@@ -1089,7 +1089,7 b' def parents(ui, repo, rev=None):' | |||
|
1089 | 1089 | if n != hg.nullid: |
|
1090 | 1090 | show_changeset(ui, repo, changenode=n) |
|
1091 | 1091 | |
|
1092 |
def paths(ui, search |
|
|
1092 | def paths(ui, search=None): | |
|
1093 | 1093 | """show definition of symbolic path names""" |
|
1094 | 1094 | try: |
|
1095 | 1095 | repo = hg.repository(ui=ui) |
@@ -360,7 +360,7 b' class dirstate:' | |||
|
360 | 360 | if not self.dirty: |
|
361 | 361 | self.dirty = 1 |
|
362 | 362 | |
|
363 |
def setparents(self, p1, p2 |
|
|
363 | def setparents(self, p1, p2=nullid): | |
|
364 | 364 | self.markdirty() |
|
365 | 365 | self.pl = p1, p2 |
|
366 | 366 | |
@@ -480,7 +480,7 b' class dirstate:' | |||
|
480 | 480 | bs += 1 |
|
481 | 481 | return ret |
|
482 | 482 | |
|
483 |
def walk(self, files |
|
|
483 | def walk(self, files=None, match=util.always, dc=None): | |
|
484 | 484 | self.read() |
|
485 | 485 | |
|
486 | 486 | # walk all files by default |
@@ -816,7 +816,7 b' class localrepository:' | |||
|
816 | 816 | else: |
|
817 | 817 | self.ui.warn("no undo information available\n") |
|
818 | 818 | |
|
819 |
def lock(self, wait |
|
|
819 | def lock(self, wait=1): | |
|
820 | 820 | try: |
|
821 | 821 | return lock.lock(self.join("lock"), 0) |
|
822 | 822 | except lock.LockHeld, inst: |
@@ -911,7 +911,7 b' class localrepository:' | |||
|
911 | 911 | else: |
|
912 | 912 | self.ui.warn("%s not tracked!\n" % f) |
|
913 | 913 | else: |
|
914 |
(c, a, d, u) = self.changes(match |
|
|
914 | (c, a, d, u) = self.changes(match=match) | |
|
915 | 915 | commit = c + a |
|
916 | 916 | remove = d |
|
917 | 917 | |
@@ -1018,7 +1018,7 b' class localrepository:' | |||
|
1018 | 1018 | return None |
|
1019 | 1019 | return n |
|
1020 | 1020 | |
|
1021 |
def walk(self, node |
|
|
1021 | def walk(self, node=None, files=[], match=util.always): | |
|
1022 | 1022 | if node: |
|
1023 | 1023 | for fn in self.manifest.read(self.changelog.read(node)[0]): |
|
1024 | 1024 | if match(fn): yield 'm', fn |
@@ -65,7 +65,7 b' def write(*things):' | |||
|
65 | 65 | sys.stdout.write(str(thing)) |
|
66 | 66 | |
|
67 | 67 | class templater: |
|
68 |
def __init__(self, mapfile, filters |
|
|
68 | def __init__(self, mapfile, filters={}, defaults={}): | |
|
69 | 69 | self.cache = {} |
|
70 | 70 | self.map = {} |
|
71 | 71 | self.base = os.path.dirname(mapfile) |
@@ -92,7 +92,7 b' class templater:' | |||
|
92 | 92 | tmpl = self.cache[t] = file(self.map[t]).read() |
|
93 | 93 | return self.template(tmpl, self.filters, **m) |
|
94 | 94 | |
|
95 |
def template(self, tmpl, filters |
|
|
95 | def template(self, tmpl, filters={}, **map): | |
|
96 | 96 | while tmpl: |
|
97 | 97 | m = re.search(r"#([a-zA-Z0-9]+)((%[a-zA-Z0-9]+)*)((\|[a-zA-Z0-9]+)*)#", tmpl) |
|
98 | 98 | if m: |
@@ -162,13 +162,13 b' class hgweb:' | |||
|
162 | 162 | |
|
163 | 163 | def listfiles(self, files, mf): |
|
164 | 164 | for f in files[:self.maxfiles]: |
|
165 |
yield self.t("filenodelink", node |
|
|
165 | yield self.t("filenodelink", node=hex(mf[f]), file=f) | |
|
166 | 166 | if len(files) > self.maxfiles: |
|
167 | 167 | yield self.t("fileellipses") |
|
168 | 168 | |
|
169 | 169 | def listfilediffs(self, files, changeset): |
|
170 | 170 | for f in files[:self.maxfiles]: |
|
171 |
yield self.t("filedifflink", node |
|
|
171 | yield self.t("filedifflink", node=hex(changeset), file=f) | |
|
172 | 172 | if len(files) > self.maxfiles: |
|
173 | 173 | yield self.t("fileellipses") |
|
174 | 174 | |
@@ -176,11 +176,11 b' class hgweb:' | |||
|
176 | 176 | if not rev: rev = lambda x: "" |
|
177 | 177 | for node in nodes: |
|
178 | 178 | if node != nullid: |
|
179 |
yield self.t(t1, node |
|
|
179 | yield self.t(t1, node=hex(node), rev=rev(node), **args) | |
|
180 | 180 | |
|
181 | 181 | def showtag(self, t1, node=nullid, **args): |
|
182 | 182 | for t in self.repo.nodetags(node): |
|
183 |
yield self.t(t1, tag |
|
|
183 | yield self.t(t1, tag=t, **args) | |
|
184 | 184 | |
|
185 | 185 | def diff(self, node1, node2, files): |
|
186 | 186 | def filterfiles(list, files): |
@@ -203,13 +203,13 b' class hgweb:' | |||
|
203 | 203 | def prettyprintlines(diff): |
|
204 | 204 | for l in diff.splitlines(1): |
|
205 | 205 | if l.startswith('+'): |
|
206 |
yield self.t("difflineplus", line |
|
|
206 | yield self.t("difflineplus", line=l) | |
|
207 | 207 | elif l.startswith('-'): |
|
208 |
yield self.t("difflineminus", line |
|
|
208 | yield self.t("difflineminus", line=l) | |
|
209 | 209 | elif l.startswith('@'): |
|
210 |
yield self.t("difflineat", line |
|
|
210 | yield self.t("difflineat", line=l) | |
|
211 | 211 | else: |
|
212 |
yield self.t("diffline", line |
|
|
212 | yield self.t("diffline", line=l) | |
|
213 | 213 | |
|
214 | 214 | r = self.repo |
|
215 | 215 | cl = r.changelog |
@@ -240,7 +240,7 b' class hgweb:' | |||
|
240 | 240 | |
|
241 | 241 | def changelog(self, pos): |
|
242 | 242 | def changenav(**map): |
|
243 |
def seq(factor |
|
|
243 | def seq(factor=1): | |
|
244 | 244 | yield 1 * factor |
|
245 | 245 | yield 3 * factor |
|
246 | 246 | #yield 5 * factor |
@@ -296,9 +296,9 b' class hgweb:' | |||
|
296 | 296 | pos = end - 1 |
|
297 | 297 | |
|
298 | 298 | yield self.t('changelog', |
|
299 |
changenav |
|
|
300 |
manifest |
|
|
301 |
rev |
|
|
299 | changenav=changenav, | |
|
300 | manifest=hex(mf), | |
|
301 | rev=pos, changesets=count, entries=changelist) | |
|
302 | 302 | |
|
303 | 303 | def search(self, query): |
|
304 | 304 | |
@@ -334,17 +334,17 b' class hgweb:' | |||
|
334 | 334 | |
|
335 | 335 | yield self.t( |
|
336 | 336 | 'searchentry', |
|
337 |
parity |
|
|
338 |
author |
|
|
339 |
parent |
|
|
337 | parity=count & 1, | |
|
338 | author=changes[1], | |
|
339 | parent=self.parents("changelogparent", | |
|
340 | 340 | cl.parents(n), cl.rev), |
|
341 |
changelogtag |
|
|
342 |
manifest |
|
|
343 |
desc |
|
|
344 |
date |
|
|
345 |
files |
|
|
346 |
rev |
|
|
347 |
node |
|
|
341 | changelogtag=self.showtag("changelogtag",n), | |
|
342 | manifest=hex(changes[0]), | |
|
343 | desc=changes[4], | |
|
344 | date=t, | |
|
345 | files=self.listfilediffs(changes[3], n), | |
|
346 | rev=i, | |
|
347 | node=hn) | |
|
348 | 348 | |
|
349 | 349 | if count >= self.maxchanges: break |
|
350 | 350 | |
@@ -352,9 +352,9 b' class hgweb:' | |||
|
352 | 352 | mf = cl.read(cl.tip())[0] |
|
353 | 353 | |
|
354 | 354 | yield self.t('search', |
|
355 |
query |
|
|
356 |
manifest |
|
|
357 |
entries |
|
|
355 | query=query, | |
|
356 | manifest=hex(mf), | |
|
357 | entries=changelist) | |
|
358 | 358 | |
|
359 | 359 | def changeset(self, nodeid): |
|
360 | 360 | n = bin(nodeid) |
@@ -367,23 +367,23 b' class hgweb:' | |||
|
367 | 367 | mf = self.repo.manifest.read(changes[0]) |
|
368 | 368 | for f in changes[3]: |
|
369 | 369 | files.append(self.t("filenodelink", |
|
370 |
filenode = hex(mf.get(f, nullid)), file |
|
|
370 | filenode = hex(mf.get(f, nullid)), file=f)) | |
|
371 | 371 | |
|
372 | 372 | def diff(**map): |
|
373 | 373 | yield self.diff(p1, n, None) |
|
374 | 374 | |
|
375 | 375 | yield self.t('changeset', |
|
376 |
diff |
|
|
377 |
rev |
|
|
378 |
node |
|
|
379 |
parent |
|
|
376 | diff=diff, | |
|
377 | rev=cl.rev(n), | |
|
378 | node=nodeid, | |
|
379 | parent=self.parents("changesetparent", | |
|
380 | 380 | cl.parents(n), cl.rev), |
|
381 |
changesettag |
|
|
382 |
manifest |
|
|
383 |
author |
|
|
384 |
desc |
|
|
385 |
date |
|
|
386 |
files |
|
|
381 | changesettag=self.showtag("changesettag",n), | |
|
382 | manifest=hex(changes[0]), | |
|
383 | author=changes[1], | |
|
384 | desc=changes[4], | |
|
385 | date=t, | |
|
386 | files=files) | |
|
387 | 387 | |
|
388 | 388 | def filelog(self, f, filenode): |
|
389 | 389 | cl = self.repo.changelog |
@@ -417,9 +417,9 b' class hgweb:' | |||
|
417 | 417 | for e in l: yield e |
|
418 | 418 | |
|
419 | 419 | yield self.t("filelog", |
|
420 |
file |
|
|
421 |
filenode |
|
|
422 |
entries |
|
|
420 | file=f, | |
|
421 | filenode=filenode, | |
|
422 | entries=entries) | |
|
423 | 423 | |
|
424 | 424 | def filerevision(self, f, node): |
|
425 | 425 | fl = self.repo.file(f) |
@@ -438,18 +438,18 b' class hgweb:' | |||
|
438 | 438 | "linenumber": "% 6d" % (l + 1), |
|
439 | 439 | "parity": l & 1} |
|
440 | 440 | |
|
441 |
yield self.t("filerevision", file |
|
|
442 |
filenode |
|
|
443 |
path |
|
|
444 |
text |
|
|
445 |
rev |
|
|
446 |
node |
|
|
447 |
manifest |
|
|
448 |
author |
|
|
449 |
date |
|
|
450 |
parent |
|
|
441 | yield self.t("filerevision", file=f, | |
|
442 | filenode=node, | |
|
443 | path=up(f), | |
|
444 | text=lines(), | |
|
445 | rev=changerev, | |
|
446 | node=hex(cn), | |
|
447 | manifest=hex(mfn), | |
|
448 | author=cs[1], | |
|
449 | date=t, | |
|
450 | parent=self.parents("filerevparent", | |
|
451 | 451 | fl.parents(n), fl.rev, file=f), |
|
452 |
permissions |
|
|
452 | permissions=self.repo.manifest.readflags(mfn)[f]) | |
|
453 | 453 | |
|
454 | 454 | def fileannotate(self, f, node): |
|
455 | 455 | bcache = {} |
@@ -566,13 +566,13 b' class hgweb:' | |||
|
566 | 566 | parity = 1 - parity |
|
567 | 567 | |
|
568 | 568 | yield self.t("manifest", |
|
569 |
manifest |
|
|
570 |
rev |
|
|
571 |
node |
|
|
572 |
path |
|
|
573 |
up |
|
|
574 |
fentries |
|
|
575 |
dentries |
|
|
569 | manifest=mnode, | |
|
570 | rev=rev, | |
|
571 | node=hex(node), | |
|
572 | path=path, | |
|
573 | up=up(path), | |
|
574 | fentries=filelist, | |
|
575 | dentries=dirlist) | |
|
576 | 576 | |
|
577 | 577 | def tags(self): |
|
578 | 578 | cl = self.repo.changelog |
@@ -590,8 +590,8 b' class hgweb:' | |||
|
590 | 590 | parity = 1 - parity |
|
591 | 591 | |
|
592 | 592 | yield self.t("tags", |
|
593 |
manifest |
|
|
594 |
entries |
|
|
593 | manifest=hex(mf), | |
|
594 | entries=entries) | |
|
595 | 595 | |
|
596 | 596 | def filediff(self, file, changeset): |
|
597 | 597 | n = bin(changeset) |
@@ -604,13 +604,13 b' class hgweb:' | |||
|
604 | 604 | yield self.diff(p1, n, file) |
|
605 | 605 | |
|
606 | 606 | yield self.t("filediff", |
|
607 |
file |
|
|
608 |
filenode |
|
|
609 |
node |
|
|
610 |
rev |
|
|
611 |
parent |
|
|
607 | file=file, | |
|
608 | filenode=hex(mf.get(file, nullid)), | |
|
609 | node=changeset, | |
|
610 | rev=self.repo.changelog.rev(n), | |
|
611 | parent=self.parents("filediffparent", | |
|
612 | 612 | cl.parents(n), cl.rev), |
|
613 |
diff |
|
|
613 | diff=diff) | |
|
614 | 614 | |
|
615 | 615 | # add tags to things |
|
616 | 616 | # tags -> list of changesets corresponding to tags |
@@ -643,10 +643,10 b' class hgweb:' | |||
|
643 | 643 | url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) |
|
644 | 644 | |
|
645 | 645 | self.t = templater(m, common_filters, |
|
646 | {"url":url, | |
|
647 | "repo":self.reponame, | |
|
648 | "header":header, | |
|
649 | "footer":footer, | |
|
646 | {"url": url, | |
|
647 | "repo": self.reponame, | |
|
648 | "header": header, | |
|
649 | "footer": footer, | |
|
650 | 650 | }) |
|
651 | 651 | |
|
652 | 652 | if not args.has_key('cmd'): |
@@ -827,8 +827,8 b' def create_server(repo):' | |||
|
827 | 827 | else: |
|
828 | 828 | return BaseHTTPServer.HTTPServer((address, port), hgwebhandler) |
|
829 | 829 | |
|
830 |
def server(path, name, templates, address, port, use_ipv6 |
|
|
831 |
accesslog |
|
|
830 | def server(path, name, templates, address, port, use_ipv6=False, | |
|
831 | accesslog=sys.stdout, errorlog=sys.stderr): | |
|
832 | 832 | httpd = create_server(path, name, templates, address, port, use_ipv6, |
|
833 | 833 | accesslog, errorlog) |
|
834 | 834 | httpd.serve_forever() |
@@ -879,14 +879,14 b' class hgwebdir:' | |||
|
879 | 879 | url = os.environ["REQUEST_URI"] + "/" + v |
|
880 | 880 | url = url.replace("//", "/") |
|
881 | 881 | |
|
882 |
yield dict(author |
|
|
883 |
name |
|
|
884 |
url |
|
|
885 |
parity |
|
|
886 |
shortdesc |
|
|
887 |
lastupdate |
|
|
882 | yield dict(author=get("web", "author", "unknown"), | |
|
883 | name=get("web", "name", v), | |
|
884 | url=url, | |
|
885 | parity=parity, | |
|
886 | shortdesc=get("web", "description", "unknown"), | |
|
887 | lastupdate=os.stat(os.path.join(r, ".hg", | |
|
888 | 888 | "00changelog.d")).st_mtime) |
|
889 | 889 | |
|
890 | 890 | parity = 1 - parity |
|
891 | 891 | |
|
892 |
write(tmpl("index", entries |
|
|
892 | write(tmpl("index", entries=entries)) |
@@ -12,7 +12,7 b' class LockHeld(Exception):' | |||
|
12 | 12 | pass |
|
13 | 13 | |
|
14 | 14 | class lock: |
|
15 |
def __init__(self, file, wait |
|
|
15 | def __init__(self, file, wait=1): | |
|
16 | 16 | self.f = file |
|
17 | 17 | self.held = 0 |
|
18 | 18 | self.wait = wait |
@@ -473,7 +473,7 b' class revlog:' | |||
|
473 | 473 | |
|
474 | 474 | yield struct.pack(">l", 0) |
|
475 | 475 | |
|
476 |
def addgroup(self, revs, linkmapper, transaction, unique |
|
|
476 | def addgroup(self, revs, linkmapper, transaction, unique=0): | |
|
477 | 477 | # given a set of deltas, add them to the revision log. the |
|
478 | 478 | # first delta is against its parent, which should be in our |
|
479 | 479 | # log, the rest are against the previous delta. |
@@ -15,7 +15,7 b' import os' | |||
|
15 | 15 | import util |
|
16 | 16 | |
|
17 | 17 | class transaction: |
|
18 |
def __init__(self, report, opener, journal, after |
|
|
18 | def __init__(self, report, opener, journal, after=None): | |
|
19 | 19 | self.journal = None |
|
20 | 20 | |
|
21 | 21 | # abort here if the journal already exists |
@@ -89,7 +89,7 b' class ui:' | |||
|
89 | 89 | |
|
90 | 90 | def readline(self): |
|
91 | 91 | return sys.stdin.readline()[:-1] |
|
92 |
def prompt(self, msg, pat, default |
|
|
92 | def prompt(self, msg, pat, default="y"): | |
|
93 | 93 | if not self.interactive: return default |
|
94 | 94 | while 1: |
|
95 | 95 | self.write(msg, " ") |
@@ -118,7 +118,7 b' class ui:' | |||
|
118 | 118 | os.environ.get("EDITOR", "vi")) |
|
119 | 119 | |
|
120 | 120 | os.environ["HGUSER"] = self.username() |
|
121 |
util.system("%s %s" % (editor, name), errprefix |
|
|
121 | util.system("%s %s" % (editor, name), errprefix="edit failed") | |
|
122 | 122 | |
|
123 | 123 | t = open(name).read() |
|
124 | 124 | t = re.sub("(?m)^HG:.*\n", "", t) |
@@ -27,7 +27,7 b' class Abort(Exception):' | |||
|
27 | 27 | def always(fn): return True |
|
28 | 28 | def never(fn): return False |
|
29 | 29 | |
|
30 |
def globre(pat, head |
|
|
30 | def globre(pat, head='^', tail='$'): | |
|
31 | 31 | "convert a glob pattern into a regexp" |
|
32 | 32 | i, n = 0, len(pat) |
|
33 | 33 | res = '' |
@@ -98,7 +98,7 b' def canonpath(repo, cwd, myname):' | |||
|
98 | 98 | else: |
|
99 | 99 | raise Abort('%s not under repository root' % myname) |
|
100 | 100 | |
|
101 |
def matcher(repo, cwd, names, inc, exc, head |
|
|
101 | def matcher(repo, cwd, names, inc, exc, head=''): | |
|
102 | 102 | def patkind(name): |
|
103 | 103 | for prefix in 're:', 'glob:', 'path:', 'relpath:': |
|
104 | 104 | if name.startswith(prefix): return name.split(':', 1) |
General Comments 0
You need to be logged in to leave comments.
Login now