##// END OF EJS Templates
localrepo: factor out parentworking logic for comparing files...
Sean Farley -
r21395:f251b92d default
parent child Browse files
Show More
@@ -1197,6 +1197,39 b' class workingctx(committablectx):'
1197 sane.append(f)
1197 sane.append(f)
1198 return sane
1198 return sane
1199
1199
1200 def _checklookup(self, files):
1201 # check for any possibly clean files
1202 if not files:
1203 return [], []
1204
1205 modified = []
1206 fixup = []
1207 pctx = self._parents[0]
1208 # do a full compare of any files that might have changed
1209 for f in sorted(files):
1210 if (f not in pctx or self.flags(f) != pctx.flags(f)
1211 or pctx[f].cmp(self[f])):
1212 modified.append(f)
1213 else:
1214 fixup.append(f)
1215
1216 # update dirstate for files that are actually clean
1217 if fixup:
1218 try:
1219 # updating the dirstate is optional
1220 # so we don't wait on the lock
1221 normal = self._repo.dirstate.normal
1222 wlock = self._repo.wlock(False)
1223 try:
1224 for f in fixup:
1225 normal(f)
1226 finally:
1227 wlock.release()
1228 except error.LockError:
1229 pass
1230 return modified, fixup
1231
1232
1200 class committablefilectx(basefilectx):
1233 class committablefilectx(basefilectx):
1201 """A committablefilectx provides common functionality for a file context
1234 """A committablefilectx provides common functionality for a file context
1202 that wants the ability to commit, e.g. workingfilectx or memfilectx."""
1235 that wants the ability to commit, e.g. workingfilectx or memfilectx."""
@@ -1550,32 +1550,12 b' class localrepository(object):'
1550
1550
1551 # check for any possibly clean files
1551 # check for any possibly clean files
1552 if parentworking and cmp:
1552 if parentworking and cmp:
1553 fixup = []
1553 modified2, fixup = ctx2._checklookup(cmp)
1554 # do a full compare of any files that might have changed
1554 modified += modified2
1555 for f in sorted(cmp):
1556 if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f)
1557 or ctx1[f].cmp(ctx2[f])):
1558 modified.append(f)
1559 else:
1560 fixup.append(f)
1561
1555
1562 # update dirstate for files that are actually clean
1556 # update dirstate for files that are actually clean
1563 if fixup:
1557 if fixup and listclean:
1564 if listclean:
1558 clean += fixup
1565 clean += fixup
1566
1567 try:
1568 # updating the dirstate is optional
1569 # so we don't wait on the lock
1570 normal = self.dirstate.normal
1571 wlock = self.wlock(False)
1572 try:
1573 for f in fixup:
1574 normal(f)
1575 finally:
1576 wlock.release()
1577 except error.LockError:
1578 pass
1579
1559
1580 if not parentworking:
1560 if not parentworking:
1581 mf1 = mfmatches(ctx1)
1561 mf1 = mfmatches(ctx1)
General Comments 0
You need to be logged in to leave comments. Login now