cmdutil: make walkchangerevs() gracefully handle wdir parents
This code will be completely rewritten, but test-grep.t would fail without
fixing it.
--- a/mercurial/cmdutil.py Thu Sep 10 13:30:34 2020 +0900
+++ b/mercurial/cmdutil.py Fri Sep 11 18:33:41 2020 +0900
@@ -2386,12 +2386,20 @@
def match(self, rev):
def realparents(rev):
- if self.onlyfirst:
- return self.repo.changelog.parentrevs(rev)[0:1]
- else:
- return filter(
- lambda x: x != nullrev, self.repo.changelog.parentrevs(rev)
- )
+ try:
+ if self.onlyfirst:
+ return self.repo.changelog.parentrevs(rev)[0:1]
+ else:
+ return filter(
+ lambda x: x != nullrev,
+ self.repo.changelog.parentrevs(rev),
+ )
+ except error.WdirUnsupported:
+ prevs = [p.rev() for p in self.repo[rev].parents()]
+ if self.onlyfirst:
+ return prevs[:1]
+ else:
+ return prevs
if self.startrev == nullrev:
self.startrev = rev