Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 23241:dd610f1d46c9
context.status: inline _poststatus()
By inlining _poststatus() into _buildstatus(), it becomes clearer that
it is only called for the workingctx.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 23 Oct 2014 16:19:56 -0700 |
parents | c26073dfbbe6 |
children | 18168938e1c1 |
comparison
equal
deleted
inserted
replaced
23240:c26073dfbbe6 | 23241:dd610f1d46c9 |
---|---|
90 | 90 |
91 This internal method provides a way for child objects to override the | 91 This internal method provides a way for child objects to override the |
92 match operator. | 92 match operator. |
93 """ | 93 """ |
94 return match or matchmod.always(self._repo.root, self._repo.getcwd()) | 94 return match or matchmod.always(self._repo.root, self._repo.getcwd()) |
95 | |
96 def _poststatus(self, other, s, match, listignored, listclean, listunknown): | |
97 """provide a hook to allow child objects to postprocess status results | |
98 | |
99 For example, this allows other contexts, such as workingctx, to filter | |
100 suspect symlinks in the case of FAT32 and NTFS filesystems. | |
101 """ | |
102 return s | |
103 | 95 |
104 def _buildstatus(self, other, s, match, listignored, listclean, | 96 def _buildstatus(self, other, s, match, listignored, listclean, |
105 listunknown): | 97 listunknown): |
106 """build a status with respect to another context""" | 98 """build a status with respect to another context""" |
107 # load earliest manifest first for caching reasons | 99 # load earliest manifest first for caching reasons |
304 | 296 |
305 match = ctx2._matchstatus(ctx1, match) | 297 match = ctx2._matchstatus(ctx1, match) |
306 r = [[], [], [], [], [], [], []] | 298 r = [[], [], [], [], [], [], []] |
307 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, | 299 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, |
308 listunknown) | 300 listunknown) |
309 r = ctx2._poststatus(ctx1, r, match, listignored, listclean, | |
310 listunknown) | |
311 | 301 |
312 if reversed: | 302 if reversed: |
313 # reverse added and removed | 303 # reverse added and removed |
314 r[1], r[2] = r[2], r[1] | 304 r[1], r[2] = r[2], r[1] |
315 | 305 |
1399 for f in removed: | 1389 for f in removed: |
1400 if f in mf: | 1390 if f in mf: |
1401 del mf[f] | 1391 del mf[f] |
1402 return mf | 1392 return mf |
1403 | 1393 |
1404 def _poststatus(self, other, s, match, listignored, listclean, listunknown): | |
1405 """override the parent hook with a filter for suspect symlinks | |
1406 | |
1407 We use this _poststatus hook to filter out symlinks that might have | |
1408 accidentally ended up with the entire contents of the file they are | |
1409 supposed to be linking to. | |
1410 """ | |
1411 s[0] = self._filtersuspectsymlink(s[0]) | |
1412 self._status = scmutil.status(*s) | |
1413 return s | |
1414 | |
1415 def _dirstatestatus(self, match=None, ignored=False, clean=False, | 1394 def _dirstatestatus(self, match=None, ignored=False, clean=False, |
1416 unknown=False): | 1395 unknown=False): |
1417 '''Gets the status from the dirstate -- internal use only.''' | 1396 '''Gets the status from the dirstate -- internal use only.''' |
1418 listignored, listclean, listunknown = ignored, clean, unknown | 1397 listignored, listclean, listunknown = ignored, clean, unknown |
1419 match = match or matchmod.always(self._repo.root, self._repo.getcwd()) | 1398 match = match or matchmod.always(self._repo.root, self._repo.getcwd()) |
1447 s = self._dirstatestatus(match, listignored, listclean, listunknown) | 1426 s = self._dirstatestatus(match, listignored, listclean, listunknown) |
1448 if other != self._repo['.']: | 1427 if other != self._repo['.']: |
1449 s = super(workingctx, self)._buildstatus(other, s, match, | 1428 s = super(workingctx, self)._buildstatus(other, s, match, |
1450 listignored, listclean, | 1429 listignored, listclean, |
1451 listunknown) | 1430 listunknown) |
1431 # Filter out symlinks that, in the case of FAT32 and NTFS filesytems, | |
1432 # might have accidentally ended up with the entire contents of the file | |
1433 # they are susposed to be linking to. | |
1434 s[0] = self._filtersuspectsymlink(s[0]) | |
1435 self._status = scmutil.status(*s) | |
1452 return s | 1436 return s |
1453 | 1437 |
1454 def _matchstatus(self, other, match): | 1438 def _matchstatus(self, other, match): |
1455 """override the match method with a filter for directory patterns | 1439 """override the match method with a filter for directory patterns |
1456 | 1440 |