##// END OF EJS Templates
diffdir tidy in preparation for arg handling
mpm@selenic.com -
r31:64205829 default
parent child Browse files
Show More
@@ -38,6 +38,24 b' def help():'
38 diff [files...] diff working directory (or selected files)
38 diff [files...] diff working directory (or selected files)
39 """
39 """
40
40
41 def diffdir(node, files = None):
42 (c, a, d) = repo.diffdir(repo.root, node)
43
44 if args:
45 nc = [ x for x in c if x in args ]
46 na = [ x for x in a if x in args ]
47 nd = [ x for x in d if x in args ]
48 for arg in args:
49 if not os.path.isdir(arg): continue
50 if arg[-1] != os.sep: arg += os.sep
51 nc += [ x for x in c if x.startswith(arg) ]
52 na += [ x for x in a if x.startswith(arg) ]
53 nd += [ x for x in d if x.startswith(arg) ]
54 (c, a, d) = (nc, na, nd)
55
56 return (c, a, d)
57
58
41 options = {}
59 options = {}
42 opts = [('v', 'verbose', None, 'verbose'),
60 opts = [('v', 'verbose', None, 'verbose'),
43 ('d', 'debug', None, 'debug')]
61 ('d', 'debug', None, 'debug')]
@@ -88,9 +106,9 b' elif cmd == "remove" or cmd == "rm" or c'
88 elif cmd == "commit" or cmd == "checkin" or cmd == "ci":
106 elif cmd == "commit" or cmd == "checkin" or cmd == "ci":
89 if 1:
107 if 1:
90 if len(args) > 0:
108 if len(args) > 0:
91 repo.commit(args)
109 repo.commit(repo.current, args)
92 else:
110 else:
93 repo.commit()
111 repo.commit(repo.current)
94
112
95 elif cmd == "import" or cmd == "patch":
113 elif cmd == "import" or cmd == "patch":
96 ioptions = {}
114 ioptions = {}
@@ -112,31 +130,19 b' elif cmd == "import" or cmd == "patch":'
112 repo.commit(files)
130 repo.commit(files)
113
131
114 elif cmd == "status":
132 elif cmd == "status":
115 (c, a, d) = repo.diffdir(repo.root, repo.current)
133 (c, a, d) = diffdir(repo.current)
116 for f in c: print "C", f
134 for f in c: print "C", f
117 for f in a: print "?", f
135 for f in a: print "?", f
118 for f in d: print "R", f
136 for f in d: print "R", f
119
137
120 elif cmd == "diff":
138 elif cmd == "diff":
139 (c, a, d) = diffdir(repo.current, args)
140
121 mmap = {}
141 mmap = {}
122 if repo.current:
142 if repo.current:
123 change = repo.changelog.read(repo.current)
143 change = repo.changelog.read(repo.current)
124 mmap = repo.manifest.read(change[0])
144 mmap = repo.manifest.read(change[0])
125
145
126 (c, a, d) = repo.diffdir(repo.root, repo.current)
127
128 if args:
129 nc = [ x for x in c if x in args ]
130 na = [ x for x in a if x in args ]
131 nd = [ x for x in d if x in args ]
132 for arg in args:
133 if not os.path.isdir(arg): continue
134 if arg[-1] != os.sep: arg += os.sep
135 nc += [ x for x in c if x.startswith(arg) ]
136 na += [ x for x in a if x.startswith(arg) ]
137 nd += [ x for x in d if x.startswith(arg) ]
138 (c, a, d) = (nc, na, nd)
139
140 for f in c:
146 for f in c:
141 to = repo.file(f).read(mmap[f])
147 to = repo.file(f).read(mmap[f])
142 tn = file(f).read()
148 tn = file(f).read()
General Comments 0
You need to be logged in to leave comments. Login now