sphinxcontrib-mercurial / sphinxcontrib / hg_changelog.py

WAKAYAMA shirou f3d7513 
















WAKAYAMA shirou 7d0a52c 
WAKAYAMA shirou f3d7513 




WAKAYAMA shirou 2cc8378 

WAKAYAMA shirou 83e0e1f 
WAKAYAMA shirou 2cc8378 

WAKAYAMA shirou 7d0a52c 

WAKAYAMA shirou 2cc8378 

WAKAYAMA shirou f3d7513 
WAKAYAMA shirou 83e0e1f 




WAKAYAMA shirou f3d7513 




WAKAYAMA shirou 2cc8378 



WAKAYAMA shirou f3d7513 












# -*- coding: utf-8-unix -*-
# Copyright 2012 (C) Takayuki KONDO <tkondou@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from docutils import nodes
from docutils.parsers.rst import directives
from sphinx.util.compat import Directive

from mercurial import ui, hg, util

class HgChangeLog(Directive):
    has_content = True
    required_arguments = 0
    optional_arguments = 2
    final_argument_whitespace = False
    option_spec = {
        'max_commits': directives.positive_int,
        'repo_root_path': directives.unchanged_required
    }
    
    def run(self):
        repo_root_path = "."
        if 'repo_root_path' in self.options:
            repo_root_path = self.options['repo_root_path']

        repo = hg.repository(ui.ui(), repo_root_path)
        l = nodes.bullet_list()

        commits = range(repo.changectx("tip").rev()+1)
        commits.reverse()

        max_commits = 10
        if 'max_commits' in self.options:
            max_commits = self.options['max_commits']
        
        for commit in commits[:max_commits]:
            ctx = repo.changectx(commit)
            item = nodes.list_item()
            item += [ nodes.strong(text=ctx.description()),
                      nodes.inline(text=" by "),
                      nodes.emphasis(text=ctx.user()),
                      nodes.inline(text=" at "),
                      nodes.emphasis(text=util.datestr(ctx.date()))
                      ]
            l.append(item)
        return [l]

def setup(app):
    app.add_directive('hg_changelog', HgChangeLog)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.