4 # |
4 # |
5 # This software may be used and distributed according to the terms |
5 # This software may be used and distributed according to the terms |
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 |
13 class UnknownCommand(Exception): pass |
13 class UnknownCommand(Exception): pass |
14 |
14 |
15 def filterfiles(filters, files): |
15 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] != os.sep: t += os.sep |
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): |
36 def date(c): |
36 def date(c): |
37 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
37 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |