Changeset - 4de3fa6290a7
[Not reviewed]
beta
0 7 0
Marcin Kuzminski - 15 years ago 2011-03-05 22:59:41
marcin@python-works.com
#109, added manual pull of changes for repositories that have remote location filled in.
This also logs this action in journal
7 files changed with 69 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -89,6 +89,10 @@ def make_map(config):
 
        m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*}",
 
             action="repo_public_journal", conditions=dict(method=["PUT"],
 
                                                        function=check_repo))
 
        m.connect('repo_pull', "/repo_pull/{repo_name:.*}",
 
             action="repo_pull", conditions=dict(method=["PUT"],
 
                                                        function=check_repo))
 

	
 

	
 
    #ADMIN USER REST ROUTES
 
    routes_map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
rhodecode/controllers/admin/repos.py
Show inline comments
 
@@ -374,7 +374,22 @@ class ReposController(BaseController):
 
            h.flash(_('Token mismatch'), category='error')
 
        return redirect(url('edit_repo', repo_name=repo_name))
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def repo_pull(self, repo_name):
 
        """
 
        Runs task to update given repository with remote changes,
 
        ie. make pull on remote location
 
        
 
        :param repo_name:
 
        """
 
        try:
 
            ScmModel().pull_changes(repo_name, c.rhodecode_user.username)
 
            h.flash(_('Pulled from remote location'), category='success')
 
        except Exception, e:
 
            h.flash(_('An error occurred during pull from remote location'),
 
                    category='error')
 

	
 
        return redirect(url('edit_repo', repo_name=repo_name))
 

	
 
    @HasPermissionAllDecorator('hg.admin')
 
    def show(self, repo_name, format='html'):
rhodecode/lib/helpers.py
Show inline comments
 
@@ -507,6 +507,7 @@ def action_parser(user_log, feed=False):
 
           'admin_forked_repo':(_('[forked] repository'), None),
 
           'admin_updated_repo':(_('[updated] repository'), None),
 
           'push':(_('[pushed] into'), get_cs_links),
 
           'push_remote':(_('[pulled from remote] into'), get_cs_links),
 
           'pull':(_('[pulled] from'), None),
 
           'started_following_repo':(_('[started following] repository'), None),
 
           'stopped_following_repo':(_('[stopped following] repository'), None),
 
@@ -518,9 +519,10 @@ def action_parser(user_log, feed=False):
 
    else:
 
        action = action_str[0].replace('[', '<span class="journal_highlight">')\
 
                   .replace(']', '</span>')
 

	
 
    action_params_func = lambda :""
 

	
 
    if action_str[1] is not None:
 
    if callable(action_str[1]):
 
        action_params_func = action_str[1]
 

	
 
    return [literal(action), action_params_func]
 
@@ -533,7 +535,7 @@ def action_parser_icon(user_log):
 
    if len(x) > 1:
 
        action, action_params = x
 

	
 
    tmpl = """<img src="%s/%s" alt="%s"/>"""
 
    tmpl = """<img src="%s%s" alt="%s"/>"""
 
    map = {'user_deleted_repo':'database_delete.png',
 
           'user_created_repo':'database_add.png',
 
           'user_forked_repo':'arrow_divide.png',
 
@@ -543,6 +545,7 @@ def action_parser_icon(user_log):
 
           'admin_forked_repo':'arrow_divide.png',
 
           'admin_updated_repo':'database_edit.png',
 
           'push':'script_add.png',
 
           'push_remote':'connect.png',
 
           'pull':'down_16.png',
 
           'started_following_repo':'heart_add.png',
 
           'stopped_following_repo':'heart_delete.png',
rhodecode/lib/hooks.py
Show inline comments
 
@@ -91,7 +91,7 @@ def log_push_action(ui, repo, **kwargs):
 
    extra_params = dict(repo.ui.configitems('rhodecode_extras'))
 
    username = extra_params['username']
 
    repository = extra_params['repository']
 
    action = 'push:%s'
 
    action = extra_params['action'] + ':%s'
 
    node = kwargs['node']
 

	
 
    def get_revs(repo, rev_opt):
rhodecode/model/scm.py
Show inline comments
 
@@ -232,8 +232,6 @@ class ScmModel(BaseModel):
 

	
 
        return r, dbr
 

	
 

	
 

	
 
    def mark_for_invalidation(self, repo_name):
 
        """Puts cache invalidation task into db for 
 
        further global cache invalidation
 
@@ -359,6 +357,25 @@ class ScmModel(BaseModel):
 
                        == RepoModel().get_by_repo_name(repo_id)).count()
 

	
 

	
 
    def pull_changes(self, repo_name, username):
 
        repo, dbrepo = self.get(repo_name, retval='all')
 

	
 
        try:
 
            extras = {'ip':'',
 
                      'username':username,
 
                      'action':'push_remote',
 
                      'repository':repo_name}
 

	
 
            #inject ui extra param to log this action via push logger        
 
            for k, v in extras.items():
 
                repo._repo.ui.setconfig('rhodecode_extras', k, v)
 

	
 
            repo.pull(dbrepo.clone_uri)
 
            self.mark_for_invalidation(repo_name)
 
        except:
 
            log.error(traceback.format_exc())
 
            raise
 

	
 
    def get_unread_journal(self):
 
        return self.sa.query(UserLog).count()
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -1964,6 +1964,14 @@ padding-top:1px;
 
text-align:left;
 
}
 
 
.pull_icon {
 
background:url("../images/icons/connect.png") no-repeat scroll 3px;
 
height:16px;
 
padding-left:20px;
 
padding-top:1px;
 
text-align:left;
 
}
 
 
.rss_icon {
 
background:url("../images/icons/rss_16.png") no-repeat scroll 3px;
 
height:16px;
rhodecode/templates/admin/repos/repo_edit.html
Show inline comments
 
@@ -314,12 +314,11 @@
 
    </div>
 
    
 
        <h3>${_('Statistics')}</h3>
 
        
 
        ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
 
        <div class="form">
 
           <div class="fields">
 
               ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="refresh_icon action_button",onclick="return confirm('Confirm to remove current statistics');")}
 
               <div class="field">
 
               <div class="field" style="border:none">
 
               <ul>
 
                    <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
 
                    <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
 
@@ -330,6 +329,22 @@
 
        </div>                    
 
        ${h.end_form()}
 
        
 
        %if c.repo_info.clone_uri:
 
        <h3>${_('Remote')}</h3>
 
        ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
 
        <div class="form">
 
           <div class="fields">
 
               ${h.submit('remote_pull_%s' % c.repo_info.repo_name,_('Pull changes from remote location'),class_="pull_icon action_button",onclick="return confirm('Confirm to pull changes from remote side');")}
 
               <div class="field" style="border:none">
 
               <ul>
 
                    <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
 
               </ul> 
 
               </div>              
 
           </div>
 
        </div>                    
 
        ${h.end_form()}
 
        %endif
 
        
 
        <h3>${_('Cache')}</h3>
 
        ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
 
        <div class="form">
0 comments (0 inline, 0 general)