##// END OF EJS Templates
largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk -
r22515:b4e251b7 default
parent child Browse files
Show More
@@ -86,175 +86,174 b' def reposetup(ui, repo):'
86 86 if not self.lfstatus:
87 87 return super(lfilesrepo, self).status(node1, node2, match,
88 88 listignored, listclean, listunknown, listsubrepos)
89 else:
90 # some calls in this function rely on the old version of status
91 self.lfstatus = False
92 ctx1 = self[node1]
93 ctx2 = self[node2]
94 working = ctx2.rev() is None
95 parentworking = working and ctx1 == self['.']
89
90 # some calls in this function rely on the old version of status
91 self.lfstatus = False
92 ctx1 = self[node1]
93 ctx2 = self[node2]
94 working = ctx2.rev() is None
95 parentworking = working and ctx1 == self['.']
96 96
97 def inctx(file, ctx):
98 try:
99 if ctx.rev() is None:
100 return file in ctx.manifest()
101 ctx[file]
102 return True
103 except KeyError:
104 return False
97 def inctx(file, ctx):
98 try:
99 if ctx.rev() is None:
100 return file in ctx.manifest()
101 ctx[file]
102 return True
103 except KeyError:
104 return False
105 105
106 if match is None:
107 match = match_.always(self.root, self.getcwd())
106 if match is None:
107 match = match_.always(self.root, self.getcwd())
108 108
109 wlock = None
109 wlock = None
110 try:
110 111 try:
111 try:
112 # updating the dirstate is optional
113 # so we don't wait on the lock
114 wlock = self.wlock(False)
115 except error.LockError:
116 pass
112 # updating the dirstate is optional
113 # so we don't wait on the lock
114 wlock = self.wlock(False)
115 except error.LockError:
116 pass
117 117
118 # First check if there were files specified on the
119 # command line. If there were, and none of them were
120 # largefiles, we should just bail here and let super
121 # handle it -- thus gaining a big performance boost.
122 lfdirstate = lfutil.openlfdirstate(ui, self)
123 if match.files() and not match.anypats():
124 for f in lfdirstate:
125 if match(f):
126 break
127 else:
128 return super(lfilesrepo, self).status(node1, node2,
129 match, listignored, listclean,
130 listunknown, listsubrepos)
118 # First check if there were files specified on the
119 # command line. If there were, and none of them were
120 # largefiles, we should just bail here and let super
121 # handle it -- thus gaining a big performance boost.
122 lfdirstate = lfutil.openlfdirstate(ui, self)
123 if match.files() and not match.anypats():
124 for f in lfdirstate:
125 if match(f):
126 break
127 else:
128 return super(lfilesrepo, self).status(node1, node2,
129 match, listignored, listclean,
130 listunknown, listsubrepos)
131 131
132 # Create a copy of match that matches standins instead
133 # of largefiles.
134 def tostandins(files):
135 if not working:
136 return files
137 newfiles = []
138 dirstate = self.dirstate
139 for f in files:
140 sf = lfutil.standin(f)
141 if sf in dirstate:
142 newfiles.append(sf)
143 elif sf in dirstate.dirs():
144 # Directory entries could be regular or
145 # standin, check both
146 newfiles.extend((f, sf))
147 else:
148 newfiles.append(f)
149 return newfiles
132 # Create a copy of match that matches standins instead
133 # of largefiles.
134 def tostandins(files):
135 if not working:
136 return files
137 newfiles = []
138 dirstate = self.dirstate
139 for f in files:
140 sf = lfutil.standin(f)
141 if sf in dirstate:
142 newfiles.append(sf)
143 elif sf in dirstate.dirs():
144 # Directory entries could be regular or
145 # standin, check both
146 newfiles.extend((f, sf))
147 else:
148 newfiles.append(f)
149 return newfiles
150 150
151 m = copy.copy(match)
152 m._files = tostandins(m._files)
151 m = copy.copy(match)
152 m._files = tostandins(m._files)
153
154 result = super(lfilesrepo, self).status(node1, node2, m,
155 ignored, clean, unknown, listsubrepos)
156 if working:
153 157
154 result = super(lfilesrepo, self).status(node1, node2, m,
155 ignored, clean, unknown, listsubrepos)
156 if working:
157
158 def sfindirstate(f):
159 sf = lfutil.standin(f)
160 dirstate = self.dirstate
161 return sf in dirstate or sf in dirstate.dirs()
158 def sfindirstate(f):
159 sf = lfutil.standin(f)
160 dirstate = self.dirstate
161 return sf in dirstate or sf in dirstate.dirs()
162 162
163 match._files = [f for f in match._files
164 if sfindirstate(f)]
165 # Don't waste time getting the ignored and unknown
166 # files from lfdirstate
167 s = lfdirstate.status(match, [], False,
168 listclean, False)
169 (unsure, modified, added, removed, missing, _unknown,
170 _ignored, clean) = s
171 if parentworking:
172 for lfile in unsure:
173 standin = lfutil.standin(lfile)
174 if standin not in ctx1:
175 # from second parent
176 modified.append(lfile)
177 elif ctx1[standin].data().strip() \
178 != lfutil.hashfile(self.wjoin(lfile)):
163 match._files = [f for f in match._files
164 if sfindirstate(f)]
165 # Don't waste time getting the ignored and unknown
166 # files from lfdirstate
167 s = lfdirstate.status(match, [], False,
168 listclean, False)
169 (unsure, modified, added, removed, missing, _unknown,
170 _ignored, clean) = s
171 if parentworking:
172 for lfile in unsure:
173 standin = lfutil.standin(lfile)
174 if standin not in ctx1:
175 # from second parent
176 modified.append(lfile)
177 elif ctx1[standin].data().strip() \
178 != lfutil.hashfile(self.wjoin(lfile)):
179 modified.append(lfile)
180 else:
181 clean.append(lfile)
182 lfdirstate.normal(lfile)
183 else:
184 tocheck = unsure + modified + added + clean
185 modified, added, clean = [], [], []
186
187 for lfile in tocheck:
188 standin = lfutil.standin(lfile)
189 if inctx(standin, ctx1):
190 if ctx1[standin].data().strip() != \
191 lfutil.hashfile(self.wjoin(lfile)):
179 192 modified.append(lfile)
180 193 else:
181 194 clean.append(lfile)
182 lfdirstate.normal(lfile)
183 else:
184 tocheck = unsure + modified + added + clean
185 modified, added, clean = [], [], []
195 else:
196 added.append(lfile)
186 197
187 for lfile in tocheck:
188 standin = lfutil.standin(lfile)
189 if inctx(standin, ctx1):
190 if ctx1[standin].data().strip() != \
191 lfutil.hashfile(self.wjoin(lfile)):
192 modified.append(lfile)
193 else:
194 clean.append(lfile)
195 else:
196 added.append(lfile)
198 # Standins no longer found in lfdirstate has been
199 # removed
200 for standin in ctx1.manifest():
201 if not lfutil.isstandin(standin):
202 continue
203 lfile = lfutil.splitstandin(standin)
204 if not match(lfile):
205 continue
206 if lfile not in lfdirstate:
207 removed.append(lfile)
197 208
198 # Standins no longer found in lfdirstate has been
199 # removed
200 for standin in ctx1.manifest():
201 if not lfutil.isstandin(standin):
202 continue
203 lfile = lfutil.splitstandin(standin)
204 if not match(lfile):
205 continue
206 if lfile not in lfdirstate:
207 removed.append(lfile)
209 # Filter result lists
210 result = list(result)
208 211
209 # Filter result lists
210 result = list(result)
212 # Largefiles are not really removed when they're
213 # still in the normal dirstate. Likewise, normal
214 # files are not really removed if they are still in
215 # lfdirstate. This happens in merges where files
216 # change type.
217 removed = [f for f in removed
218 if f not in self.dirstate]
219 result[2] = [f for f in result[2]
220 if f not in lfdirstate]
211 221
212 # Largefiles are not really removed when they're
213 # still in the normal dirstate. Likewise, normal
214 # files are not really removed if they are still in
215 # lfdirstate. This happens in merges where files
216 # change type.
217 removed = [f for f in removed
218 if f not in self.dirstate]
219 result[2] = [f for f in result[2]
220 if f not in lfdirstate]
222 lfiles = set(lfdirstate._map)
223 # Unknown files
224 result[4] = set(result[4]).difference(lfiles)
225 # Ignored files
226 result[5] = set(result[5]).difference(lfiles)
227 # combine normal files and largefiles
228 normals = [[fn for fn in filelist
229 if not lfutil.isstandin(fn)]
230 for filelist in result]
231 lfiles = (modified, added, removed, missing, [], [], clean)
232 result = [sorted(list1 + list2)
233 for (list1, list2) in zip(normals, lfiles)]
234 else:
235 def toname(f):
236 if lfutil.isstandin(f):
237 return lfutil.splitstandin(f)
238 return f
239 result = [[toname(f) for f in items]
240 for items in result]
221 241
222 lfiles = set(lfdirstate._map)
223 # Unknown files
224 result[4] = set(result[4]).difference(lfiles)
225 # Ignored files
226 result[5] = set(result[5]).difference(lfiles)
227 # combine normal files and largefiles
228 normals = [[fn for fn in filelist
229 if not lfutil.isstandin(fn)]
230 for filelist in result]
231 lfiles = (modified, added, removed, missing, [], [],
232 clean)
233 result = [sorted(list1 + list2)
234 for (list1, list2) in zip(normals, lfiles)]
235 else:
236 def toname(f):
237 if lfutil.isstandin(f):
238 return lfutil.splitstandin(f)
239 return f
240 result = [[toname(f) for f in items]
241 for items in result]
242 if wlock:
243 lfdirstate.write()
244
245 finally:
246 if wlock:
247 wlock.release()
242 248
243 if wlock:
244 lfdirstate.write()
245
246 finally:
247 if wlock:
248 wlock.release()
249
250 if not listunknown:
251 result[4] = []
252 if not listignored:
253 result[5] = []
254 if not listclean:
255 result[6] = []
256 self.lfstatus = True
257 return result
249 if not listunknown:
250 result[4] = []
251 if not listignored:
252 result[5] = []
253 if not listclean:
254 result[6] = []
255 self.lfstatus = True
256 return result
258 257
259 258 # As part of committing, copy all of the largefiles into the
260 259 # cache.
General Comments 0
You need to be logged in to leave comments. Login now