Mercurial > hg
comparison mercurial/hg.py @ 679:c11e9a6777ae
Actually move .hg into ignore
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 11 Jul 2005 10:28:20 -0800 |
parents | 6513ba7d858a |
children | 4b7b79d2db2c |
comparison
equal
deleted
inserted
replaced
678:0cfc5966b2c2 | 679:c11e9a6777ae |
---|---|
19 os.path.join("data", path + ".i"), | 19 os.path.join("data", path + ".i"), |
20 os.path.join("data", path + ".d")) | 20 os.path.join("data", path + ".d")) |
21 | 21 |
22 def read(self, node): | 22 def read(self, node): |
23 t = self.revision(node) | 23 t = self.revision(node) |
24 if not t.startswith('\1\n'): | 24 if t[:2] != '\1\n': |
25 return t | 25 return t |
26 s = t.find('\1\n', 2) | 26 s = t.find('\1\n', 2) |
27 return t[s+2:] | 27 return t[s+2:] |
28 | 28 |
29 def readmeta(self, node): | 29 def readmeta(self, node): |
30 t = self.revision(node) | 30 t = self.revision(node) |
31 if not t.startswith('\1\n'): | 31 if t[:2] != '\1\n': |
32 return t | 32 return t |
33 s = t.find('\1\n', 2) | 33 s = t.find('\1\n', 2) |
34 mt = t[2:s] | 34 mt = t[2:s] |
35 for l in mt.splitlines(): | 35 for l in mt.splitlines(): |
36 k, v = l.split(": ", 1) | 36 k, v = l.split(": ", 1) |
37 m[k] = v | 37 m[k] = v |
38 return m | 38 return m |
39 | 39 |
40 def add(self, text, meta, transaction, link, p1=None, p2=None): | 40 def add(self, text, meta, transaction, link, p1=None, p2=None): |
41 if meta or text.startswith('\1\n'): | 41 if meta or text[:2] == '\1\n': |
42 mt = "" | 42 mt = "" |
43 if meta: | 43 if meta: |
44 mt = [ "%s: %s\n" % (k, v) for k,v in meta.items() ] | 44 mt = [ "%s: %s\n" % (k, v) for k,v in meta.items() ] |
45 text = "\1\n" + "".join(mt) + "\1\n" + text | 45 text = "\1\n" + "".join(mt) + "\1\n" + text |
46 return self.addrevision(text, transaction, link, p1, p2) | 46 return self.addrevision(text, transaction, link, p1, p2) |
396 f = os.path.join(self.root, f) | 396 f = os.path.join(self.root, f) |
397 if os.path.isdir(f): | 397 if os.path.isdir(f): |
398 for dir, subdirs, fl in os.walk(f): | 398 for dir, subdirs, fl in os.walk(f): |
399 d = dir[len(self.root) + 1:] | 399 d = dir[len(self.root) + 1:] |
400 for sd in subdirs: | 400 for sd in subdirs: |
401 if sd == ".hg" or ignore(os.path.join(d, sd +'/')): | 401 if ignore(os.path.join(d, sd +'/')): |
402 subdirs.remove(sd) | 402 subdirs.remove(sd) |
403 for fn in fl: | 403 for fn in fl: |
404 fn = util.pconvert(os.path.join(d, fn)) | 404 fn = util.pconvert(os.path.join(d, fn)) |
405 yield fn | 405 yield fn |
406 else: | 406 else: |
434 | 434 |
435 # used to avoid circular references so destructors work | 435 # used to avoid circular references so destructors work |
436 def opener(base): | 436 def opener(base): |
437 p = base | 437 p = base |
438 def o(path, mode="r"): | 438 def o(path, mode="r"): |
439 if p.startswith("http://"): | 439 if p[:7] == "http://": |
440 f = os.path.join(p, urllib.quote(path)) | 440 f = os.path.join(p, urllib.quote(path)) |
441 return httprangereader.httprangereader(f) | 441 return httprangereader.httprangereader(f) |
442 | 442 |
443 f = os.path.join(p, path) | 443 f = os.path.join(p, path) |
444 | 444 |
463 class RepoError(Exception): pass | 463 class RepoError(Exception): pass |
464 | 464 |
465 class localrepository: | 465 class localrepository: |
466 def __init__(self, ui, path=None, create=0): | 466 def __init__(self, ui, path=None, create=0): |
467 self.remote = 0 | 467 self.remote = 0 |
468 if path and path.startswith("http://"): | 468 if path and path[:7] == "http://": |
469 self.remote = 1 | 469 self.remote = 1 |
470 self.path = path | 470 self.path = path |
471 else: | 471 else: |
472 if not path: | 472 if not path: |
473 p = os.getcwd() | 473 p = os.getcwd() |
502 self.ui.readconfig(self.opener("hgrc")) | 502 self.ui.readconfig(self.opener("hgrc")) |
503 except IOError: pass | 503 except IOError: pass |
504 | 504 |
505 def ignore(self, f): | 505 def ignore(self, f): |
506 if not self.ignorefunc: | 506 if not self.ignorefunc: |
507 bigpat = [] | 507 bigpat = ["^.hg/$"] |
508 try: | 508 try: |
509 l = file(self.wjoin(".hgignore")) | 509 l = file(self.wjoin(".hgignore")) |
510 for pat in l: | 510 for pat in l: |
511 if pat != "\n": | 511 if pat != "\n": |
512 p = util.pconvert(pat[:-1]) | 512 p = util.pconvert(pat[:-1]) |
516 self.ui.warn("ignoring invalid ignore" | 516 self.ui.warn("ignoring invalid ignore" |
517 + " regular expression '%s'\n" % p) | 517 + " regular expression '%s'\n" % p) |
518 else: | 518 else: |
519 bigpat.append(util.pconvert(pat[:-1])) | 519 bigpat.append(util.pconvert(pat[:-1])) |
520 except IOError: pass | 520 except IOError: pass |
521 if bigpat: | 521 |
522 s = "(?:%s)" % (")|(?:".join(bigpat)) | 522 s = "(?:%s)" % (")|(?:".join(bigpat)) |
523 r = re.compile(s) | 523 r = re.compile(s) |
524 self.ignorefunc = r.search | 524 self.ignorefunc = r.search |
525 else: | |
526 self.ignorefunc = lambda x: False | |
527 | 525 |
528 return self.ignorefunc(f) | 526 return self.ignorefunc(f) |
529 | 527 |
530 def hook(self, name, **args): | 528 def hook(self, name, **args): |
531 s = self.ui.config("hooks", name) | 529 s = self.ui.config("hooks", name) |