Show More
@@ -0,0 +1,16 | |||||
|
1 | # util.py - utility functions and platform specfic implementations | |||
|
2 | # | |||
|
3 | # Copyright 2005 K. Thananchayan <thananck@yahoo.com> | |||
|
4 | # | |||
|
5 | # This software may be used and distributed according to the terms | |||
|
6 | # of the GNU General Public License, incorporated herein by reference. | |||
|
7 | ||||
|
8 | import os | |||
|
9 | ||||
|
10 | if os.name == 'nt': | |||
|
11 | def pconvert(path): | |||
|
12 | return path.replace("\\", "/") | |||
|
13 | else: | |||
|
14 | def pconvert(path): | |||
|
15 | return path | |||
|
16 |
@@ -6,7 +6,7 | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | import os, re, sys, signal |
|
8 | import os, re, sys, signal | |
9 | import fancyopts, ui, hg |
|
9 | import fancyopts, ui, hg, util | |
10 | from demandload import * |
|
10 | from demandload import * | |
11 | demandload(globals(), "mdiff time hgweb traceback random signal errno") |
|
11 | demandload(globals(), "mdiff time hgweb traceback random signal errno") | |
12 |
|
12 | |||
@@ -16,20 +16,20 def filterfiles(filters, files): | |||||
16 | l = [ x for x in files if x in filters ] |
|
16 | l = [ x for x in files if x in filters ] | |
17 |
|
17 | |||
18 | for t in filters: |
|
18 | for t in filters: | |
19 |
if t and t[-1] != |
|
19 | if t and t[-1] != "/": t += "/" | |
20 | l += [ x for x in files if x.startswith(t) ] |
|
20 | l += [ x for x in files if x.startswith(t) ] | |
21 | return l |
|
21 | return l | |
22 |
|
22 | |||
23 | def relfilter(repo, files): |
|
23 | def relfilter(repo, files): | |
24 | if os.getcwd() != repo.root: |
|
24 | if os.getcwd() != repo.root: | |
25 | p = os.getcwd()[len(repo.root) + 1: ] |
|
25 | p = os.getcwd()[len(repo.root) + 1: ] | |
26 | return filterfiles([p], files) |
|
26 | return filterfiles([util.pconvert(p)], files) | |
27 | return files |
|
27 | return files | |
28 |
|
28 | |||
29 | def relpath(repo, args): |
|
29 | def relpath(repo, args): | |
30 | if os.getcwd() != repo.root: |
|
30 | if os.getcwd() != repo.root: | |
31 | p = os.getcwd()[len(repo.root) + 1: ] |
|
31 | p = os.getcwd()[len(repo.root) + 1: ] | |
32 | return [ os.path.normpath(os.path.join(p, x)) for x in args ] |
|
32 | return [ util.pconvert(os.path.normpath(os.path.join(p, x))) for x in args ] | |
33 | return args |
|
33 | return args | |
34 |
|
34 | |||
35 | def dodiff(ui, repo, path, files = None, node1 = None, node2 = None): |
|
35 | def dodiff(ui, repo, path, files = None, node1 = None, node2 = None): |
@@ -6,6 +6,7 | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | import sys, struct, os |
|
8 | import sys, struct, os | |
|
9 | import util | |||
9 | from revlog import * |
|
10 | from revlog import * | |
10 | from demandload import * |
|
11 | from demandload import * | |
11 | demandload(globals(), "re lock urllib urllib2 transaction time socket") |
|
12 | demandload(globals(), "re lock urllib urllib2 transaction time socket") | |
@@ -389,7 +390,7 class localrepository: | |||||
389 | l = file(self.wjoin(".hgignore")) |
|
390 | l = file(self.wjoin(".hgignore")) | |
390 | for pat in l: |
|
391 | for pat in l: | |
391 | if pat != "\n": |
|
392 | if pat != "\n": | |
392 | self.ignorelist.append(re.compile(pat[:-1])) |
|
393 | self.ignorelist.append(re.compile(util.pconvert(pat[:-1]))) | |
393 | except IOError: pass |
|
394 | except IOError: pass | |
394 | for pat in self.ignorelist: |
|
395 | for pat in self.ignorelist: | |
395 | if pat.search(f): return True |
|
396 | if pat.search(f): return True | |
@@ -639,7 +640,7 class localrepository: | |||||
639 | if ".hg" in subdirs: subdirs.remove(".hg") |
|
640 | if ".hg" in subdirs: subdirs.remove(".hg") | |
640 |
|
641 | |||
641 | for f in files: |
|
642 | for f in files: | |
642 | fn = os.path.join(d, f) |
|
643 | fn = util.pconvert(os.path.join(d, f)) | |
643 | try: s = os.stat(os.path.join(self.root, fn)) |
|
644 | try: s = os.stat(os.path.join(self.root, fn)) | |
644 | except: continue |
|
645 | except: continue | |
645 | if fn in dc: |
|
646 | if fn in dc: |
General Comments 0
You need to be logged in to leave comments.
Login now