comparison mercurial/localrepo.py @ 21467:6c90a18dd926

localrepo: use _manifestmatches instead of duplicating logic
author Sean Farley <sean.michael.farley@gmail.com>
date Tue, 11 Mar 2014 18:38:44 -0500
parents 2edb8648c500
children 65cdc6bab91e
comparison
equal deleted inserted replaced
21466:3b1ec3d4ece6 21467:6c90a18dd926
1509 1509
1510 If node1 is None, use the first dirstate parent instead. 1510 If node1 is None, use the first dirstate parent instead.
1511 If node2 is None, compare node1 with working directory. 1511 If node2 is None, compare node1 with working directory.
1512 """ 1512 """
1513 1513
1514 def mfmatches(ctx):
1515 mf = ctx.manifest().copy()
1516 if match.always():
1517 return mf
1518 for fn in mf.keys():
1519 if not match(fn):
1520 del mf[fn]
1521 return mf
1522
1523 ctx1 = self[node1] 1514 ctx1 = self[node1]
1524 ctx2 = self[node2] 1515 ctx2 = self[node2]
1525 1516
1526 # This next code block is, admittedly, fragile logic that tests for 1517 # This next code block is, admittedly, fragile logic that tests for
1527 # reversing the contexts and wouldn't need to exist if it weren't for 1518 # reversing the contexts and wouldn't need to exist if it weren't for
1564 clean=listclean, unknown=listunknown) 1555 clean=listclean, unknown=listunknown)
1565 1556
1566 modified, added, removed, deleted, unknown, ignored, clean = r 1557 modified, added, removed, deleted, unknown, ignored, clean = r
1567 1558
1568 if not parentworking: 1559 if not parentworking:
1569 mf1 = mfmatches(ctx1) 1560 mf1 = ctx1._manifestmatches(match, r)
1570 if working: 1561 if working:
1571 # we are comparing working dir against non-parent 1562 # we are comparing working dir against non-parent
1572 # generate a pseudo-manifest for the working dir 1563 # generate a pseudo-manifest for the working dir
1573 mf2 = mfmatches(self['.']) 1564 mf2 = self['.']._manifestmatches(match, r)
1574 for f in modified + added: 1565 for f in modified + added:
1575 mf2[f] = None 1566 mf2[f] = None
1576 mf2.set(f, ctx2.flags(f)) 1567 mf2.set(f, ctx2.flags(f))
1577 for f in removed: 1568 for f in removed:
1578 if f in mf2: 1569 if f in mf2:
1579 del mf2[f] 1570 del mf2[f]
1580 else: 1571 else:
1581 # we are comparing two revisions 1572 # we are comparing two revisions
1582 deleted, unknown, ignored = [], [], [] 1573 deleted, unknown, ignored = [], [], []
1583 mf2 = mfmatches(ctx2) 1574 mf2 = ctx2._manifestmatches(match, r)
1584 1575
1585 modified, added, clean = [], [], [] 1576 modified, added, clean = [], [], []
1586 withflags = mf1.withflags() | mf2.withflags() 1577 withflags = mf1.withflags() | mf2.withflags()
1587 for fn, mf2node in mf2.iteritems(): 1578 for fn, mf2node in mf2.iteritems():
1588 if fn in mf1: 1579 if fn in mf1: