- repo_file = self._title_to_file(title)
- changectx = self._changectx() # start with tip
- visited = set()
-
- stack = [changectx]
- visited.add(changectx)
-
- while repo_file not in changectx:
- if not stack:
- raise DocumentNotFound(title)
-
- changectx = stack.pop()
- for parent in changectx.parents():
- if parent not in visited:
- stack.append(parent)
- visited.add(parent)
-
- try:
- fctx = changectx[repo_file]
-
- if rev is not None:
- fctx = fctx.filectx(rev)
- fctx.filerev()
-
- return fctx
- except (IndexError, LookupError) as e:
- raise DocumentNotFound(title)
-
- def page_history(self, title):
+ if rev is not None:
+ oldest, newest = rev, -1
+ opts = {"follow": True, "rev": ["%s:%s" % (newest, oldest)]}
+ def prepare(ctx, fns):
+ pass
+ xml_file = self._title_to_file(title)
+ matchfn = hg_exact_match(self.repo.root, self.repo.getcwd(), [xml_file])
+ generator = walkchangerevs(self.repo, matchfn, opts, prepare)
+
+ last = None
+ current_name = xml_file
+ for change in generator:
+ fctx = change[current_name]
+ renamed = fctx.renamed()
+ if renamed:
+ current_name = renamed[0]
+ last = change
+
+ if last is not None:
+ return last[current_name]
+
+ # not found
+ raise DocumentNotFound(title)
+
+ def page_history(self, title, oldest=0, newest= -1):