-
- filectx_tip = self._find_filectx(title)
- if filectx_tip is None:
- return
- maxrev = filectx_tip.filerev()
- minrev = 0
- for rev in range(maxrev, minrev-1, -1):
- filectx = filectx_tip.filectx(rev)
- date = datetime.datetime.fromtimestamp(filectx.date()[0])
- author = unicode(filectx.user(), "utf-8",
- 'replace').split('<')[0].strip()
- comment = unicode(filectx.description(), "utf-8", 'replace')
- yield rev, date, author, comment
-
- def page_revision(self, title, rev):
- """Get unicode contents of specified revision of the page."""
-
- filectx_tip = self._find_filectx(title)
- if filectx_tip is None:
- raise DocumentNotFound()
- try:
- data = filectx_tip.filectx(rev).data()
- except IndexError:
- raise DocumentNotFound()
- return data
-
- def revision_text(self, title, rev):
- data = self.page_revision(title, rev)
- text = unicode(data, self.charset, 'replace')
- return text
-
- def history(self):
+ opts = {"follow": True, "rev": ["%s:%s" % (newest, oldest)]}
+ prepare = lambda * args: True
+ repo_file = self._title_to_file(title)
+ matchfn = hg_exact_match(self.repo.root, self.repo.getcwd(), [repo_file])
+ generator = walkchangerevs(self.repo, matchfn, opts, prepare)
+
+ for changeset in generator:
+ changeset
+ date = datetime.datetime.fromtimestamp(changeset.date()[0])
+ author = changeset.user().decode('utf-8', 'replace')
+ comment = changeset.description().decode("utf-8", 'replace')
+ tags = [t.rsplit('#', 1)[-1] for t in changeset.tags() if '#' in t]
+
+ yield {
+ "version": changeset.rev(),
+ "date": date,
+ "author": author,
+ "description": comment,
+ "tag": tags,
+ }
+
+ @with_working_copy_locked
+ def add_page_tag(self, title, rev, tag, user, doctag=True):
+ ctitle = self._title_to_file(title)
+
+ if doctag:
+ tag = u"{ctitle}#{tag}".format(**locals()).encode('utf-8')
+
+ message = u"Assigned tag {tag!r} to version {rev!r} of {ctitle!r}".format(**locals()).encode('utf-8')
+
+ fctx = self._find_filectx(title, rev)
+ self.repo.tag(
+ names=tag, node=fctx.node(), local=False,
+ user=user, message=message, date=None,
+ )
+
+ def history(self, newest=None):