comparison mercurial/context.py @ 19564:f0ed47b73d37

basectx: move diff from changectx
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 05 Aug 2013 18:41:12 -0500
parents 87503cd824fa
children bd1580a9c133
comparison
equal deleted inserted replaced
19563:87503cd824fa 19564:f0ed47b73d37
125 def match(self, pats=[], include=None, exclude=None, default='glob'): 125 def match(self, pats=[], include=None, exclude=None, default='glob'):
126 r = self._repo 126 r = self._repo
127 return matchmod.match(r.root, r.getcwd(), pats, 127 return matchmod.match(r.root, r.getcwd(), pats,
128 include, exclude, default, 128 include, exclude, default,
129 auditor=r.auditor, ctx=self) 129 auditor=r.auditor, ctx=self)
130
131 def diff(self, ctx2=None, match=None, **opts):
132 """Returns a diff generator for the given contexts and matcher"""
133 if ctx2 is None:
134 ctx2 = self.p1()
135 if ctx2 is not None and not isinstance(ctx2, changectx):
136 ctx2 = self._repo[ctx2]
137 diffopts = patch.diffopts(self._repo.ui, opts)
138 return patch.diff(self._repo, ctx2.node(), self.node(),
139 match=match, opts=diffopts)
130 140
131 class changectx(basectx): 141 class changectx(basectx):
132 """A changecontext object makes access to data related to a particular 142 """A changecontext object makes access to data related to a particular
133 changeset convenient. It represents a read-only context already presnt in 143 changeset convenient. It represents a read-only context already presnt in
134 the repo.""" 144 the repo."""
386 if fn in self._dirs: 396 if fn in self._dirs:
387 # specified pattern is a directory 397 # specified pattern is a directory
388 continue 398 continue
389 if match.bad(fn, _('no such file in rev %s') % self) and match(fn): 399 if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
390 yield fn 400 yield fn
391
392 def diff(self, ctx2=None, match=None, **opts):
393 """Returns a diff generator for the given contexts and matcher"""
394 if ctx2 is None:
395 ctx2 = self.p1()
396 if ctx2 is not None and not isinstance(ctx2, changectx):
397 ctx2 = self._repo[ctx2]
398 diffopts = patch.diffopts(self._repo.ui, opts)
399 return patch.diff(self._repo, ctx2.node(), self.node(),
400 match=match, opts=diffopts)
401 401
402 @propertycache 402 @propertycache
403 def _dirs(self): 403 def _dirs(self):
404 return scmutil.dirs(self._manifest) 404 return scmutil.dirs(self._manifest)
405 405