Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 16151:a01d2fb5ba65
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 22 Feb 2012 17:36:33 -0600 |
parents | 004982e5d782 616c2e278f18 |
children | 352053e6cd8e |
comparison
equal
deleted
inserted
replaced
16150:0424f3c7d7ac | 16151:a01d2fb5ba65 |
---|---|
204 fset = set(match.files()) | 204 fset = set(match.files()) |
205 # for dirstate.walk, files=['.'] means "walk the whole tree". | 205 # for dirstate.walk, files=['.'] means "walk the whole tree". |
206 # follow that here, too | 206 # follow that here, too |
207 fset.discard('.') | 207 fset.discard('.') |
208 for fn in self: | 208 for fn in self: |
209 for ffn in fset: | 209 if fn in fset: |
210 # match if the file is the exact name or a directory | 210 # specified pattern is the exact name |
211 if ffn == fn or fn.startswith("%s/" % ffn): | 211 fset.remove(fn) |
212 fset.remove(ffn) | |
213 break | |
214 if match(fn): | 212 if match(fn): |
215 yield fn | 213 yield fn |
216 for fn in sorted(fset): | 214 for fn in sorted(fset): |
215 if fn in self._dirs: | |
216 # specified pattern is a directory | |
217 continue | |
217 if match.bad(fn, _('no such file in rev %s') % self) and match(fn): | 218 if match.bad(fn, _('no such file in rev %s') % self) and match(fn): |
218 yield fn | 219 yield fn |
219 | 220 |
220 def sub(self, path): | 221 def sub(self, path): |
221 return subrepo.subrepo(self, path) | 222 return subrepo.subrepo(self, path) |
233 if ctx2 is not None and not isinstance(ctx2, changectx): | 234 if ctx2 is not None and not isinstance(ctx2, changectx): |
234 ctx2 = self._repo[ctx2] | 235 ctx2 = self._repo[ctx2] |
235 diffopts = patch.diffopts(self._repo.ui, opts) | 236 diffopts = patch.diffopts(self._repo.ui, opts) |
236 return patch.diff(self._repo, ctx2.node(), self.node(), | 237 return patch.diff(self._repo, ctx2.node(), self.node(), |
237 match=match, opts=diffopts) | 238 match=match, opts=diffopts) |
239 | |
240 @propertycache | |
241 def _dirs(self): | |
242 dirs = set() | |
243 for f in self._manifest: | |
244 pos = f.rfind('/') | |
245 while pos != -1: | |
246 f = f[:pos] | |
247 if f in dirs: | |
248 break # dirs already contains this and above | |
249 dirs.add(f) | |
250 pos = f.rfind('/') | |
251 return dirs | |
252 | |
253 def dirs(self): | |
254 return self._dirs | |
238 | 255 |
239 class filectx(object): | 256 class filectx(object): |
240 """A filecontext object makes access to data related to a particular | 257 """A filecontext object makes access to data related to a particular |
241 filerevision convenient.""" | 258 filerevision convenient.""" |
242 def __init__(self, repo, path, changeid=None, fileid=None, | 259 def __init__(self, repo, path, changeid=None, fileid=None, |
947 self._repo.dirstate.add(dest) | 964 self._repo.dirstate.add(dest) |
948 self._repo.dirstate.copy(source, dest) | 965 self._repo.dirstate.copy(source, dest) |
949 finally: | 966 finally: |
950 wlock.release() | 967 wlock.release() |
951 | 968 |
969 def dirs(self): | |
970 return self._repo.dirstate.dirs() | |
971 | |
952 class workingfilectx(filectx): | 972 class workingfilectx(filectx): |
953 """A workingfilectx object makes access to data related to a particular | 973 """A workingfilectx object makes access to data related to a particular |
954 file in the working directory convenient.""" | 974 file in the working directory convenient.""" |
955 def __init__(self, repo, path, filelog=None, workingctx=None): | 975 def __init__(self, repo, path, filelog=None, workingctx=None): |
956 """changeid can be a changeset revision, node, or tag. | 976 """changeid can be a changeset revision, node, or tag. |