Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 21482:869a28d016e9
workingctx: override _matchstatus for parentworking case
This patch encapsulate the logic for changing the match.bad function when
comparing against the working directory's parent. Future patches will remove
more of the 'if ... else' blocks in localrepo.status that test for this working
directory parent case.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Thu, 24 Apr 2014 08:32:28 -0500 |
parents | 2f1567ef70ba |
children | 8a2637cf1130 |
comparison
equal
deleted
inserted
replaced
21481:2f1567ef70ba | 21482:869a28d016e9 |
---|---|
1349 s = super(workingctx, self)._buildstatus(other, s, match, | 1349 s = super(workingctx, self)._buildstatus(other, s, match, |
1350 listignored, listclean, | 1350 listignored, listclean, |
1351 listunknown) | 1351 listunknown) |
1352 return s | 1352 return s |
1353 | 1353 |
1354 def _matchstatus(self, other, s, match, listignored, listclean, | |
1355 listunknown): | |
1356 """override the match method with a filter for directory patterns | |
1357 | |
1358 We use inheritance to customize the match.bad method only in cases of | |
1359 workingctx since it belongs only to the working directory when | |
1360 comparing against the parent changeset. | |
1361 | |
1362 If we aren't comparing against the working directory's parent, then we | |
1363 just use the default match object sent to us. | |
1364 """ | |
1365 superself = super(workingctx, self) | |
1366 match = superself._matchstatus(other, s, match, listignored, listclean, | |
1367 listunknown) | |
1368 if other != self._repo['.']: | |
1369 def bad(f, msg): | |
1370 # 'f' may be a directory pattern from 'match.files()', | |
1371 # so 'f not in ctx1' is not enough | |
1372 if f not in other and f not in other.dirs(): | |
1373 self._repo.ui.warn('%s: %s\n' % | |
1374 (self._repo.dirstate.pathto(f), msg)) | |
1375 match.bad = bad | |
1376 return match | |
1377 | |
1354 def status(self, ignored=False, clean=False, unknown=False, match=None): | 1378 def status(self, ignored=False, clean=False, unknown=False, match=None): |
1355 """Explicit status query | 1379 """Explicit status query |
1356 Unless this method is used to query the working copy status, the | 1380 Unless this method is used to query the working copy status, the |
1357 _status property will implicitly read the status using its default | 1381 _status property will implicitly read the status using its default |
1358 arguments.""" | 1382 arguments.""" |