comparison mercurial/context.py @ 16185:352053e6cd8e

context: add followfirst arg to filectx and workingfilectx When _followfirst() revset was introduced it seemed to be the sole user of such an argument, so filectx.ancestors() was duplicated and modified instead. It now appears this argument could be used when computing the set of files to be considered when --patch or --stat are passed along with --follow FILE.
author Patrick Mezard <patrick@mezard.eu>
date Sun, 26 Feb 2012 17:10:57 +0100
parents a01d2fb5ba65
children 329887a7074c
comparison
equal deleted inserted replaced
16184:6863caf01daa 16185:352053e6cd8e
609 f, n = v 609 f, n = v
610 return filectx(self._repo, f, fileid=n, filelog=flcache[f]) 610 return filectx(self._repo, f, fileid=n, filelog=flcache[f])
611 611
612 return None 612 return None
613 613
614 def ancestors(self): 614 def ancestors(self, followfirst=False):
615 visit = {} 615 visit = {}
616 c = self 616 c = self
617 cut = followfirst and 1 or None
617 while True: 618 while True:
618 for parent in c.parents(): 619 for parent in c.parents()[:cut]:
619 visit[(parent.rev(), parent.node())] = parent 620 visit[(parent.rev(), parent.node())] = parent
620 if not visit: 621 if not visit:
621 break 622 break
622 c = visit.pop(max(visit)) 623 c = visit.pop(max(visit))
623 yield c 624 yield c
928 self._repo.dirstate.drop(f) 929 self._repo.dirstate.drop(f)
929 return rejected 930 return rejected
930 finally: 931 finally:
931 wlock.release() 932 wlock.release()
932 933
933 def ancestors(self): 934 def ancestors(self, followfirst=False):
935 cut = followfirst and 1 or None
934 for a in self._repo.changelog.ancestors( 936 for a in self._repo.changelog.ancestors(
935 *[p.rev() for p in self._parents]): 937 *[p.rev() for p in self._parents[:cut]]):
936 yield changectx(self._repo, a) 938 yield changectx(self._repo, a)
937 939
938 def undelete(self, list): 940 def undelete(self, list):
939 pctxs = self.parents() 941 pctxs = self.parents()
940 wlock = self._repo.wlock() 942 wlock = self._repo.wlock()