comparison mercurial/localrepo.py @ 21596:83bbfb23cb24

localrepo: replace status method with a shim The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly Mercurial's keeper and the finder of robust methods. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy Mercurial's codebase. And you will know my name is the Lord when I lay my vengeance upon thee.
author Sean Farley <sean.michael.farley@gmail.com>
date Fri, 25 Apr 2014 15:44:55 -0500
parents 660ef8ca8c3c
children 0ff44e06275d
comparison
equal deleted inserted replaced
21595:aca692aa0712 21596:83bbfb23cb24
1502 return self[node].walk(match) 1502 return self[node].walk(match)
1503 1503
1504 def status(self, node1='.', node2=None, match=None, 1504 def status(self, node1='.', node2=None, match=None,
1505 ignored=False, clean=False, unknown=False, 1505 ignored=False, clean=False, unknown=False,
1506 listsubrepos=False): 1506 listsubrepos=False):
1507 """return status of files between two nodes or node and working 1507 '''a convenience method that calls node1.status(node2)'''
1508 directory. 1508 return self[node1].status(node2, match, ignored, clean, unknown,
1509 1509 listsubrepos)
1510 If node1 is None, use the first dirstate parent instead.
1511 If node2 is None, compare node1 with working directory.
1512 """
1513
1514 ctx1 = self[node1]
1515 ctx2 = self[node2]
1516
1517 # This next code block is, admittedly, fragile logic that tests for
1518 # reversing the contexts and wouldn't need to exist if it weren't for
1519 # the fast (and common) code path of comparing the working directory
1520 # with its first parent.
1521 #
1522 # What we're aiming for here is the ability to call:
1523 #
1524 # workingctx.status(parentctx)
1525 #
1526 # If we always built the manifest for each context and compared those,
1527 # then we'd be done. But the special case of the above call means we
1528 # just copy the manifest of the parent.
1529 reversed = False
1530 if (not isinstance(ctx1, context.changectx)
1531 and isinstance(ctx2, context.changectx)):
1532 reversed = True
1533 ctx1, ctx2 = ctx2, ctx1
1534
1535 listignored, listclean, listunknown = ignored, clean, unknown
1536
1537 r = [[], [], [], [], [], [], []]
1538 match = ctx2._matchstatus(ctx1, r, match, listignored, listclean,
1539 listunknown)
1540 r = ctx2._prestatus(ctx1, r, match, listignored, listclean, listunknown)
1541 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean,
1542 listunknown)
1543 r = ctx2._poststatus(ctx1, r, match, listignored, listclean,
1544 listunknown)
1545
1546 if reversed:
1547 # since we are maintaining whether we reversed ctx1 and ctx2 (due
1548 # to comparing the workingctx with its parent), we need to switch
1549 # back added files (r[1]) and removed files (r[2])
1550 r[1], r[2] = r[2], r[1]
1551
1552 if listsubrepos:
1553 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
1554 rev2 = ctx2.subrev(subpath)
1555 try:
1556 submatch = matchmod.narrowmatcher(subpath, match)
1557 s = sub.status(rev2, match=submatch, ignored=listignored,
1558 clean=listclean, unknown=listunknown,
1559 listsubrepos=True)
1560 for rfiles, sfiles in zip(r, s):
1561 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
1562 except error.LookupError:
1563 self.ui.status(_("skipping missing subrepository: %s\n")
1564 % subpath)
1565
1566 for l in r:
1567 l.sort()
1568 return r
1569 1510
1570 def heads(self, start=None): 1511 def heads(self, start=None):
1571 heads = self.changelog.heads(start) 1512 heads = self.changelog.heads(start)
1572 # sort the output in rev descending order 1513 # sort the output in rev descending order
1573 return sorted(heads, key=self.changelog.rev, reverse=True) 1514 return sorted(heads, key=self.changelog.rev, reverse=True)