- tip = self._changectx() # start with tip
-
- def tree_search(tip, repo_file):
- logging.info("Searching for %r", repo_file)
- current = tip
- visited = set()
-
- stack = [current]
- visited.add(current)
-
- while repo_file not in current:
- if not stack:
- raise LookupError
-
- current = stack.pop()
- for parent in current.parents():
- if parent not in visited:
- stack.append(parent)
- visited.add(parent)
-
- fctx = current[repo_file]
- if rev is not None:
- fctx = fctx.filectx(rev)
- fctx.filerev()
- return fctx
-
- try:
- return tree_search(tip, self._title_to_file(title))
- except (IndexError, LookupError) as e:
- logging.info("XML file not found, trying plain")
- try:
- return tree_search(tip, self._title_to_file(title, type=''))
- 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):