##// END OF EJS Templates
Merge latest round of walk fixes.
Bryan O'Sullivan -
r885:6594ba2a merge default
parent child Browse files
Show More
@@ -40,22 +40,12 b' def matchpats(repo, cwd, pats = [], opts'
40 return util.matcher(repo, cwd, pats or ['.'], opts.get('include'),
40 return util.matcher(repo, cwd, pats or ['.'], opts.get('include'),
41 opts.get('exclude'), head)
41 opts.get('exclude'), head)
42
42
43 def pathto(n1, n2):
44 '''return the relative path from one place to another'''
45 if not n1: return n2
46 a, b = n1.split(os.sep), n2.split(os.sep)
47 a.reverse(), b.reverse()
48 while a and b and a[-1] == b[-1]:
49 a.pop(), b.pop()
50 b.reverse()
51 return os.sep.join((['..'] * len(a)) + b)
52
53 def makewalk(repo, pats, opts, head = ''):
43 def makewalk(repo, pats, opts, head = ''):
54 cwd = repo.getcwd()
44 cwd = repo.getcwd()
55 files, matchfn = matchpats(repo, cwd, pats, opts, head)
45 files, matchfn = matchpats(repo, cwd, pats, opts, head)
56 def walk():
46 def walk():
57 for src, fn in repo.walk(files = files, match = matchfn):
47 for src, fn in repo.walk(files = files, match = matchfn):
58 yield src, fn, pathto(cwd, fn)
48 yield src, fn, util.pathto(cwd, fn)
59 return files, matchfn, walk()
49 return files, matchfn, walk()
60
50
61 def walk(repo, pats, opts, head = ''):
51 def walk(repo, pats, opts, head = ''):
@@ -1078,7 +1068,7 b' def status(ui, repo, *pats, **opts):'
1078
1068
1079 cwd = repo.getcwd()
1069 cwd = repo.getcwd()
1080 files, matchfn = matchpats(repo, cwd, pats, opts)
1070 files, matchfn = matchpats(repo, cwd, pats, opts)
1081 (c, a, d, u) = [[pathto(cwd, x) for x in n]
1071 (c, a, d, u) = [[util.pathto(cwd, x) for x in n]
1082 for n in repo.changes(files=files, match=matchfn)]
1072 for n in repo.changes(files=files, match=matchfn)]
1083
1073
1084 changetypes = [('modified', 'M', c),
1074 changetypes = [('modified', 'M', c),
@@ -11,7 +11,7 b' from revlog import *'
11 from demandload import *
11 from demandload import *
12 demandload(globals(), "re lock urllib urllib2 transaction time socket")
12 demandload(globals(), "re lock urllib urllib2 transaction time socket")
13 demandload(globals(), "tempfile httprangereader bdiff urlparse")
13 demandload(globals(), "tempfile httprangereader bdiff urlparse")
14 demandload(globals(), "bisect select")
14 demandload(globals(), "bisect errno select stat")
15
15
16 class filelog(revlog):
16 class filelog(revlog):
17 def __init__(self, opener, path):
17 def __init__(self, opener, path):
@@ -489,9 +489,16 b' class dirstate:'
489 if fn in known: return True
489 if fn in known: return True
490 known[fn] = 1
490 known[fn] = 1
491 def traverse():
491 def traverse():
492 for f in util.unique(files):
492 for ff in util.unique(files):
493 f = os.path.join(self.root, f)
493 f = os.path.join(self.root, ff)
494 if os.path.isdir(f):
494 try:
495 st = os.stat(f)
496 except OSError, inst:
497 if ff not in dc: self.ui.warn('%s: %s\n' % (
498 util.pathto(self.getcwd(), ff),
499 inst.strerror))
500 continue
501 if stat.S_ISDIR(st.st_mode):
495 for dir, subdirs, fl in os.walk(f):
502 for dir, subdirs, fl in os.walk(f):
496 d = dir[len(self.root) + 1:]
503 d = dir[len(self.root) + 1:]
497 nd = os.path.normpath(d)
504 nd = os.path.normpath(d)
@@ -507,8 +514,18 b' class dirstate:'
507 for fn in fl:
514 for fn in fl:
508 fn = util.pconvert(os.path.join(d, fn))
515 fn = util.pconvert(os.path.join(d, fn))
509 yield 'f', fn
516 yield 'f', fn
517 elif stat.S_ISREG(st.st_mode):
518 yield 'f', ff
510 else:
519 else:
511 yield 'f', f[len(self.root) + 1:]
520 kind = 'unknown'
521 if stat.S_ISCHR(st.st_mode): kind = 'character device'
522 elif stat.S_ISBLK(st.st_mode): kind = 'block device'
523 elif stat.S_ISFIFO(st.st_mode): kind = 'fifo'
524 elif stat.S_ISLNK(st.st_mode): kind = 'symbolic link'
525 elif stat.S_ISSOCK(st.st_mode): kind = 'socket'
526 self.ui.warn('%s: unsupported file type (type is %s)\n' % (
527 util.pathto(self.getcwd(), ff),
528 kind))
512
529
513 ks = dc.keys()
530 ks = dc.keys()
514 ks.sort()
531 ks.sort()
@@ -708,7 +708,12 b' def create_server(path, name, templates,'
708 import BaseHTTPServer
708 import BaseHTTPServer
709
709
710 class IPv6HTTPServer(BaseHTTPServer.HTTPServer):
710 class IPv6HTTPServer(BaseHTTPServer.HTTPServer):
711 address_family = socket.AF_INET6
711 address_family = getattr(socket, 'AF_INET6', None)
712
713 def __init__(self, *args, **kwargs):
714 if self.address_family is None:
715 raise RepoError('IPv6 not available on this system')
716 BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs)
712
717
713 class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler):
718 class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler):
714 def log_error(self, format, *args):
719 def log_error(self, format, *args):
@@ -69,6 +69,16 b" def globre(pat, head = '^', tail = '$'):"
69
69
70 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
70 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
71
71
72 def pathto(n1, n2):
73 '''return the relative path from one place to another'''
74 if not n1: return n2
75 a, b = n1.split(os.sep), n2.split(os.sep)
76 a.reverse(), b.reverse()
77 while a and b and a[-1] == b[-1]:
78 a.pop(), b.pop()
79 b.reverse()
80 return os.sep.join((['..'] * len(a)) + b)
81
72 def canonpath(repo, cwd, myname):
82 def canonpath(repo, cwd, myname):
73 rootsep = repo.root + os.sep
83 rootsep = repo.root + os.sep
74 name = myname
84 name = myname
General Comments 0
You need to be logged in to leave comments. Login now