Please provide "download at revision" feature in mercurial repository

Issue #128 new
Alexander Nikitin created an issue

Hello Kallithea/RhodeCode/Python gurus!

I'm in the process of transferring my RhodeCode 1.7.1 installation to Kallithea 0.2.1 and have a small enhancement request.

In RhodeCode 1.7.1 I "patched" _get_download_links method (in summary.py) to be able to download mercurial repo (in zip format) at specified revision:

def _get_download_links(self, repo):
    download_l = []
    branches_group = ([], _("Branches"))
    tags_group = ([], _("Tags"))
    ////////////////////////////////////////////////////// patch start /////////////////////////////////////////
revisions_group = ([], _("Revisions"))
    new_collection = reversed(list(c.rhodecode_repo))
    for cs in new_collection:
        revisions_group[0].append(( cs.raw_id, h.show_id(cs) ),)
    download_l.append(revisions_group)
    ////////////////////////////////////////////////////////// patch end  /////////////////////////////////////////
    for name, chs in c.rhodecode_repo.branches.items():
        #chs = chs.split(':')[-1]
        branches_group[0].append((chs, name),)
    download_l.append(branches_group)
    for name, chs in c.rhodecode_repo.tags.items():
        #chs = chs.split(':')[-1]
        tags_group[0].append((chs, name),)
    download_l.append(tags_group)
    return download_l

I've tried to do the same trick in Kallithea 0.2.1 but it looks like that Branches/Tags/etc "download code" has moved somewhere in home.py (repo_refs_data method) which I failed to patch due to my zero skills in python. So is there are any chance to make it work in Kallithea 0.2.1 ?

PS Sorry for my weird code above - I'm C++/Java coder - not Python :)

Thanks in advance !

Comments (3)

  1. Mads Kiilerich

    something like

    --- a/kallithea/controllers/home.py
    +++ b/kallithea/controllers/home.py
    @@ -142,6 +142,10 @@ class HomeController(BaseController):
                     'text': _('Bookmark'),
                     'children': [{'id': rev, 'text': name, 'type': 'book'} for name, rev in _bookmarks]
                 })
    +        res.append({
    +            'text': _('Revisions'),
    +            'children': [{'id': cs.short_id, 'text': cs.short_id, 'type': 'revision'} for cs in repo]
    +        })
             data = {
                 'more': False,
                 'results': res
    

    might work for you.

    It does however not scale to large repos.

    A proper fix for this doesn't require a python programmer. It requires a front end programmer who knows how to implement this with or without select2.

  2. Alexander Nikitin reporter

    Thanks kiilerix ! I've applied your diff into home.py source code in my test environment and your patch works - now I can see my "hg revsions" in download list. I will try to make some enhancements in your code (displaying revisions in form of "mercurial_revision_number":"cs.short_id" and sorting data in "revisions list" )

  3. Alexander Nikitin reporter

    Here is the final code that allows 'download at revision'. I've tested it on 350+ commits mercurial repo and it didn't hang :)

    diff --git a/kallithea/controllers/home.py b/kallithea/controllers/home.py
    --- a/kallithea/controllers/home.py
    +++ b/kallithea/controllers/home.py
    @@ -142,6 +142,10 @@
                     'text': _('Bookmark'),
                     'children': [{'id': rev, 'text': name, 'type': 'book'} for name, rev in _bookmarks]
                 })
    +        res.append({
    +            'text': _('Revisions'),
    +            'children': [{'id': cs.raw_id, 'text': 'r' + str(index) + ':' + cs.short_id, 'type': 'revision'} for index, cs in reversed (list(enumerate(repo)))]
    +        })
             data = {
                 'more': False,
                 'results': res
    

    PS Sorry for my weird code above - I'm C++/Java coder - not Python :)

  4. Log in to comment