##// END OF EJS Templates
#109, added manual pull of changes for repositories that have remote location filled in....
marcink -
r1114:4de3fa62 beta
parent child Browse files
Show More
@@ -89,6 +89,10 b' def make_map(config):'
89 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*}",
89 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*}",
90 action="repo_public_journal", conditions=dict(method=["PUT"],
90 action="repo_public_journal", conditions=dict(method=["PUT"],
91 function=check_repo))
91 function=check_repo))
92 m.connect('repo_pull', "/repo_pull/{repo_name:.*}",
93 action="repo_pull", conditions=dict(method=["PUT"],
94 function=check_repo))
95
92
96
93 #ADMIN USER REST ROUTES
97 #ADMIN USER REST ROUTES
94 routes_map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
98 routes_map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
@@ -374,7 +374,22 b' class ReposController(BaseController):'
374 h.flash(_('Token mismatch'), category='error')
374 h.flash(_('Token mismatch'), category='error')
375 return redirect(url('edit_repo', repo_name=repo_name))
375 return redirect(url('edit_repo', repo_name=repo_name))
376
376
377 @HasPermissionAllDecorator('hg.admin')
378 def repo_pull(self, repo_name):
379 """
380 Runs task to update given repository with remote changes,
381 ie. make pull on remote location
377
382
383 :param repo_name:
384 """
385 try:
386 ScmModel().pull_changes(repo_name, c.rhodecode_user.username)
387 h.flash(_('Pulled from remote location'), category='success')
388 except Exception, e:
389 h.flash(_('An error occurred during pull from remote location'),
390 category='error')
391
392 return redirect(url('edit_repo', repo_name=repo_name))
378
393
379 @HasPermissionAllDecorator('hg.admin')
394 @HasPermissionAllDecorator('hg.admin')
380 def show(self, repo_name, format='html'):
395 def show(self, repo_name, format='html'):
@@ -507,6 +507,7 b' def action_parser(user_log, feed=False):'
507 'admin_forked_repo':(_('[forked] repository'), None),
507 'admin_forked_repo':(_('[forked] repository'), None),
508 'admin_updated_repo':(_('[updated] repository'), None),
508 'admin_updated_repo':(_('[updated] repository'), None),
509 'push':(_('[pushed] into'), get_cs_links),
509 'push':(_('[pushed] into'), get_cs_links),
510 'push_remote':(_('[pulled from remote] into'), get_cs_links),
510 'pull':(_('[pulled] from'), None),
511 'pull':(_('[pulled] from'), None),
511 'started_following_repo':(_('[started following] repository'), None),
512 'started_following_repo':(_('[started following] repository'), None),
512 'stopped_following_repo':(_('[stopped following] repository'), None),
513 'stopped_following_repo':(_('[stopped following] repository'), None),
@@ -518,9 +519,10 b' def action_parser(user_log, feed=False):'
518 else:
519 else:
519 action = action_str[0].replace('[', '<span class="journal_highlight">')\
520 action = action_str[0].replace('[', '<span class="journal_highlight">')\
520 .replace(']', '</span>')
521 .replace(']', '</span>')
522
521 action_params_func = lambda :""
523 action_params_func = lambda :""
522
524
523 if action_str[1] is not None:
525 if callable(action_str[1]):
524 action_params_func = action_str[1]
526 action_params_func = action_str[1]
525
527
526 return [literal(action), action_params_func]
528 return [literal(action), action_params_func]
@@ -533,7 +535,7 b' def action_parser_icon(user_log):'
533 if len(x) > 1:
535 if len(x) > 1:
534 action, action_params = x
536 action, action_params = x
535
537
536 tmpl = """<img src="%s/%s" alt="%s"/>"""
538 tmpl = """<img src="%s%s" alt="%s"/>"""
537 map = {'user_deleted_repo':'database_delete.png',
539 map = {'user_deleted_repo':'database_delete.png',
538 'user_created_repo':'database_add.png',
540 'user_created_repo':'database_add.png',
539 'user_forked_repo':'arrow_divide.png',
541 'user_forked_repo':'arrow_divide.png',
@@ -543,6 +545,7 b' def action_parser_icon(user_log):'
543 'admin_forked_repo':'arrow_divide.png',
545 'admin_forked_repo':'arrow_divide.png',
544 'admin_updated_repo':'database_edit.png',
546 'admin_updated_repo':'database_edit.png',
545 'push':'script_add.png',
547 'push':'script_add.png',
548 'push_remote':'connect.png',
546 'pull':'down_16.png',
549 'pull':'down_16.png',
547 'started_following_repo':'heart_add.png',
550 'started_following_repo':'heart_add.png',
548 'stopped_following_repo':'heart_delete.png',
551 'stopped_following_repo':'heart_delete.png',
@@ -91,7 +91,7 b' def log_push_action(ui, repo, **kwargs):'
91 extra_params = dict(repo.ui.configitems('rhodecode_extras'))
91 extra_params = dict(repo.ui.configitems('rhodecode_extras'))
92 username = extra_params['username']
92 username = extra_params['username']
93 repository = extra_params['repository']
93 repository = extra_params['repository']
94 action = 'push:%s'
94 action = extra_params['action'] + ':%s'
95 node = kwargs['node']
95 node = kwargs['node']
96
96
97 def get_revs(repo, rev_opt):
97 def get_revs(repo, rev_opt):
@@ -232,8 +232,6 b' class ScmModel(BaseModel):'
232
232
233 return r, dbr
233 return r, dbr
234
234
235
236
237 def mark_for_invalidation(self, repo_name):
235 def mark_for_invalidation(self, repo_name):
238 """Puts cache invalidation task into db for
236 """Puts cache invalidation task into db for
239 further global cache invalidation
237 further global cache invalidation
@@ -359,6 +357,25 b' class ScmModel(BaseModel):'
359 == RepoModel().get_by_repo_name(repo_id)).count()
357 == RepoModel().get_by_repo_name(repo_id)).count()
360
358
361
359
360 def pull_changes(self, repo_name, username):
361 repo, dbrepo = self.get(repo_name, retval='all')
362
363 try:
364 extras = {'ip':'',
365 'username':username,
366 'action':'push_remote',
367 'repository':repo_name}
368
369 #inject ui extra param to log this action via push logger
370 for k, v in extras.items():
371 repo._repo.ui.setconfig('rhodecode_extras', k, v)
372
373 repo.pull(dbrepo.clone_uri)
374 self.mark_for_invalidation(repo_name)
375 except:
376 log.error(traceback.format_exc())
377 raise
378
362 def get_unread_journal(self):
379 def get_unread_journal(self):
363 return self.sa.query(UserLog).count()
380 return self.sa.query(UserLog).count()
364
381
@@ -1964,6 +1964,14 b' padding-top:1px;'
1964 text-align:left;
1964 text-align:left;
1965 }
1965 }
1966
1966
1967 .pull_icon {
1968 background:url("../images/icons/connect.png") no-repeat scroll 3px;
1969 height:16px;
1970 padding-left:20px;
1971 padding-top:1px;
1972 text-align:left;
1973 }
1974
1967 .rss_icon {
1975 .rss_icon {
1968 background:url("../images/icons/rss_16.png") no-repeat scroll 3px;
1976 background:url("../images/icons/rss_16.png") no-repeat scroll 3px;
1969 height:16px;
1977 height:16px;
@@ -314,12 +314,11 b''
314 </div>
314 </div>
315
315
316 <h3>${_('Statistics')}</h3>
316 <h3>${_('Statistics')}</h3>
317
318 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
317 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
319 <div class="form">
318 <div class="form">
320 <div class="fields">
319 <div class="fields">
321 ${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');")}
320 ${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');")}
322 <div class="field">
321 <div class="field" style="border:none">
323 <ul>
322 <ul>
324 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
323 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
325 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
324 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
@@ -330,6 +329,22 b''
330 </div>
329 </div>
331 ${h.end_form()}
330 ${h.end_form()}
332
331
332 %if c.repo_info.clone_uri:
333 <h3>${_('Remote')}</h3>
334 ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
335 <div class="form">
336 <div class="fields">
337 ${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');")}
338 <div class="field" style="border:none">
339 <ul>
340 <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
341 </ul>
342 </div>
343 </div>
344 </div>
345 ${h.end_form()}
346 %endif
347
333 <h3>${_('Cache')}</h3>
348 <h3>${_('Cache')}</h3>
334 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
349 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
335 <div class="form">
350 <div class="form">
General Comments 0
You need to be logged in to leave comments. Login now