##// END OF EJS Templates
cleanup: fix some risky variable redefinitions...
Mads Kiilerich -
r5398:956c5577 default
parent child Browse files
Show More
@@ -339,7 +339,7 b' class PullrequestsController(BaseRepoCon'
339 )
339 )
340 if ancestor_rev is None:
340 if ancestor_rev is None:
341 ancestor_rev = org_repo.scm_instance.EMPTY_CHANGESET
341 ancestor_rev = org_repo.scm_instance.EMPTY_CHANGESET
342 revisions = [cs.raw_id for cs in cs_ranges]
342 revisions = [cs_.raw_id for cs_ in cs_ranges]
343
343
344 # hack: ancestor_rev is not an other_rev but we want to show the
344 # hack: ancestor_rev is not an other_rev but we want to show the
345 # requested destination and have the exact ancestor
345 # requested destination and have the exact ancestor
@@ -87,11 +87,11 b' def canonical_hostname():'
87 parts = url('home', qualified=True).split('://', 1)
87 parts = url('home', qualified=True).split('://', 1)
88 return parts[1].split('/', 1)[0]
88 return parts[1].split('/', 1)[0]
89
89
90 def html_escape(text):
90 def html_escape(s):
91 """Return string with all html escaped.
91 """Return string with all html escaped.
92 This is also safe for javascript in html but not necessarily correct.
92 This is also safe for javascript in html but not necessarily correct.
93 """
93 """
94 return (text
94 return (s
95 .replace('&', '&')
95 .replace('&', '&')
96 .replace(">", ">")
96 .replace(">", ">")
97 .replace("<", "&lt;")
97 .replace("<", "&lt;")
@@ -99,11 +99,11 b' def html_escape(text):'
99 .replace("'", "&apos;")
99 .replace("'", "&apos;")
100 )
100 )
101
101
102 def shorter(text, size=20):
102 def shorter(s, size=20):
103 postfix = '...'
103 postfix = '...'
104 if len(text) > size:
104 if len(s) > size:
105 return text[:size - len(postfix)] + postfix
105 return s[:size - len(postfix)] + postfix
106 return text
106 return s
107
107
108
108
109 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
109 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
@@ -601,8 +601,8 b' def action_parser(user_log, feed=False, '
601
601
602 def lnk(rev, repo_name):
602 def lnk(rev, repo_name):
603 lazy_cs = False
603 lazy_cs = False
604 title = None
604 title_ = None
605 _url = '#'
605 url_ = '#'
606 if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict):
606 if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict):
607 if rev.op and rev.ref_name:
607 if rev.op and rev.ref_name:
608 if rev.op == 'delete_branch':
608 if rev.op == 'delete_branch':
@@ -614,15 +614,15 b' def action_parser(user_log, feed=False, '
614 else:
614 else:
615 lazy_cs = True
615 lazy_cs = True
616 lbl = rev.short_id[:8]
616 lbl = rev.short_id[:8]
617 _url = url('changeset_home', repo_name=repo_name,
617 url_ = url('changeset_home', repo_name=repo_name,
618 revision=rev.raw_id)
618 revision=rev.raw_id)
619 else:
619 else:
620 # changeset cannot be found - it might have been stripped or removed
620 # changeset cannot be found - it might have been stripped or removed
621 lbl = rev[:12]
621 lbl = rev[:12]
622 title = _('Changeset not found')
622 title_ = _('Changeset not found')
623 if parse_cs:
623 if parse_cs:
624 return link_to(lbl, _url, title=title, class_='tooltip')
624 return link_to(lbl, url_, title=title_, class_='tooltip')
625 return link_to(lbl, _url, raw_id=rev.raw_id, repo_name=repo_name,
625 return link_to(lbl, url_, raw_id=rev.raw_id, repo_name=repo_name,
626 class_='lazy-cs' if lazy_cs else '')
626 class_='lazy-cs' if lazy_cs else '')
627
627
628 def _get_op(rev_txt):
628 def _get_op(rev_txt):
@@ -718,8 +718,8 b' def action_parser(user_log, feed=False, '
718
718
719 def get_fork_name():
719 def get_fork_name():
720 repo_name = action_params
720 repo_name = action_params
721 _url = url('summary_home', repo_name=repo_name)
721 url_ = url('summary_home', repo_name=repo_name)
722 return _('Fork name %s') % link_to(action_params, _url)
722 return _('Fork name %s') % link_to(action_params, url_)
723
723
724 def get_user_name():
724 def get_user_name():
725 user_name = action_params
725 user_name = action_params
@@ -938,31 +938,31 b' class Page(_Page):'
938 # and the currently displayed page range
938 # and the currently displayed page range
939 if leftmost_page - self.first_page > 1:
939 if leftmost_page - self.first_page > 1:
940 # Wrap in a SPAN tag if nolink_attr is set
940 # Wrap in a SPAN tag if nolink_attr is set
941 text = '..'
941 text_ = '..'
942 if self.dotdot_attr:
942 if self.dotdot_attr:
943 text = HTML.span(c=text, **self.dotdot_attr)
943 text_ = HTML.span(c=text_, **self.dotdot_attr)
944 nav_items.append(text)
944 nav_items.append(text_)
945
945
946 for thispage in xrange(leftmost_page, rightmost_page + 1):
946 for thispage in xrange(leftmost_page, rightmost_page + 1):
947 # Highlight the current page number and do not use a link
947 # Highlight the current page number and do not use a link
948 text = str(thispage)
948 text_ = str(thispage)
949 if thispage == self.page:
949 if thispage == self.page:
950 # Wrap in a SPAN tag if nolink_attr is set
950 # Wrap in a SPAN tag if nolink_attr is set
951 if self.curpage_attr:
951 if self.curpage_attr:
952 text = HTML.span(c=text, **self.curpage_attr)
952 text_ = HTML.span(c=text_, **self.curpage_attr)
953 nav_items.append(text)
953 nav_items.append(text_)
954 # Otherwise create just a link to that page
954 # Otherwise create just a link to that page
955 else:
955 else:
956 nav_items.append(self._pagerlink(thispage, text))
956 nav_items.append(self._pagerlink(thispage, text_))
957
957
958 # Insert dots if there are pages between the displayed
958 # Insert dots if there are pages between the displayed
959 # page numbers and the end of the page range
959 # page numbers and the end of the page range
960 if self.last_page - rightmost_page > 1:
960 if self.last_page - rightmost_page > 1:
961 text = '..'
961 text_ = '..'
962 # Wrap in a SPAN tag if nolink_attr is set
962 # Wrap in a SPAN tag if nolink_attr is set
963 if self.dotdot_attr:
963 if self.dotdot_attr:
964 text = HTML.span(c=text, **self.dotdot_attr)
964 text_ = HTML.span(c=text_, **self.dotdot_attr)
965 nav_items.append(text)
965 nav_items.append(text_)
966
966
967 # Create a link to the very last page (unless we are on the last
967 # Create a link to the very last page (unless we are on the last
968 # page or there would be no need to insert '..' spacers)
968 # page or there would be no need to insert '..' spacers)
@@ -86,7 +86,7 b' class Command(BasePasterCommand):'
86
86
87 repos_location = Ui.get_repos_location()
87 repos_location = Ui.get_repos_location()
88 to_remove = []
88 to_remove = []
89 for dn, dirs, f in os.walk(safe_str(repos_location)):
89 for dn_, dirs, f in os.walk(safe_str(repos_location)):
90 alldirs = list(dirs)
90 alldirs = list(dirs)
91 del dirs[:]
91 del dirs[:]
92 if ('.hg' in alldirs or
92 if ('.hg' in alldirs or
@@ -94,7 +94,7 b' class Command(BasePasterCommand):'
94 continue
94 continue
95 for loc in alldirs:
95 for loc in alldirs:
96 if REMOVED_REPO_PAT.match(loc):
96 if REMOVED_REPO_PAT.match(loc):
97 to_remove.append([os.path.join(dn, loc),
97 to_remove.append([os.path.join(dn_, loc),
98 self._extract_date(loc)])
98 self._extract_date(loc)])
99 else:
99 else:
100 dirs.append(loc)
100 dirs.append(loc)
@@ -2146,7 +2146,7 b' class _BaseTestApi(object):'
2146 self._compare_error(id_, expected, given=response.body)
2146 self._compare_error(id_, expected, given=response.body)
2147
2147
2148 @mock.patch.object(RepoGroupModel, 'grant_user_group_permission', crash)
2148 @mock.patch.object(RepoGroupModel, 'grant_user_group_permission', crash)
2149 def test_api_grant_user_group_permission_exception_when_adding(self):
2149 def test_api_grant_user_group_permission_exception_when_adding_to_repo_group(self):
2150 perm = 'group.read'
2150 perm = 'group.read'
2151 id_, params = _build_data(self.apikey,
2151 id_, params = _build_data(self.apikey,
2152 'grant_user_group_permission_to_repo_group',
2152 'grant_user_group_permission_to_repo_group',
General Comments 0
You need to be logged in to leave comments. Login now