@@ -12,48 +12,49 @@ Changelog
news
++++
- obfuscate db password in logs for engine connection string
- #574 Show pull request status also in shortlog (if any)
- remember selected tab in my account page
- Bumped mercurial version to 2.3.2
fixes
+++++
- Add git version detection to warn users that Git used in system is to
old. Ref #588 - also show git version in system details in settings page
- fixed files quick filter links
- #590 Add GET flag that controls the way the diff are generated, for pull
requests we want to use non-bundle based diffs, That are far better for
doing code reviews. The /compare url still uses bundle compare for full
comparison including the incoming changesets
- Fixed #585, checks for status of revision where to strict, and made
opening pull request with those revision impossible due to previously set
status. Checks now are made also for the repository.
- fixes #591 git backend was causing encoding errors when handling binary
files - added a test case for VCS lib tests
- fixed #597 commits in future get negative age.
1.4.3 (**2012-09-28**)
----------------------
- #558 Added config file to hooks extra data
- bumped mercurial version to 2.3.1
- #518 added possibility of specifying multiple patterns for issues
- update codemirror to latest version
- fixed #570 explicit users group permissions can overwrite owner permissions
- fixed #578 set proper PATH with current Python for Git
hooks to execute within same Python as RhodeCode
- fixed issue with Git bare repos that ends with .git in name
1.4.2 (**2012-09-12**)
@@ -293,51 +293,56 @@ def engine_from_config(configuration, pr
def after_cursor_execute(conn, cursor, statement,
parameters, context, executemany):
total = time.time() - context._query_start_time
log.info(color_sql("<<<<< TOTAL TIME: %f <<<<<" % total))
event.listen(engine, "before_cursor_execute",
before_cursor_execute)
event.listen(engine, "after_cursor_execute",
after_cursor_execute)
return engine
def age(prevdate):
"""
turns a datetime into an age string.
:param prevdate: datetime object
:rtype: unicode
:returns: unicode words describing age
order = ['year', 'month', 'day', 'hour', 'minute', 'second']
deltas = {}
future = False
# Get date parts deltas
now = datetime.datetime.now()
if prevdate > now:
now, prevdate = prevdate, now
future = True
for part in order:
deltas[part] = getattr(now, part) - getattr(prevdate, part)
# Fix negative offsets (there is 1 second between 10:59:59 and 11:00:00,
# not 1 hour, -59 minutes and -59 seconds)
for num, length in [(5, 60), (4, 60), (3, 24)]: # seconds, minutes, hours
part = order[num]
carry_part = order[num - 1]
if deltas[part] < 0:
deltas[part] += length
deltas[carry_part] -= 1
# Same thing for days except that the increment depends on the (variable)
# number of days in the month
month_lengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if deltas['day'] < 0:
if prevdate.month == 2 and (prevdate.year % 4 == 0 and
(prevdate.year % 100 != 0 or prevdate.year % 400 == 0)):
deltas['day'] += 29
else:
deltas['day'] += month_lengths[prevdate.month - 1]
@@ -348,52 +353,58 @@ def age(prevdate):
deltas['year'] -= 1
# Format the result
fmt_funcs = {
'year': lambda d: ungettext(u'%d year', '%d years', d) % d,
'month': lambda d: ungettext(u'%d month', '%d months', d) % d,
'day': lambda d: ungettext(u'%d day', '%d days', d) % d,
'hour': lambda d: ungettext(u'%d hour', '%d hours', d) % d,
'minute': lambda d: ungettext(u'%d minute', '%d minutes', d) % d,
'second': lambda d: ungettext(u'%d second', '%d seconds', d) % d,
}
for i, part in enumerate(order):
value = deltas[part]
if value == 0:
continue
if i < 5:
sub_part = order[i + 1]
sub_value = deltas[sub_part]
sub_value = 0
if sub_value == 0:
return _(u'%s ago') % fmt_funcs[part](value)
return _(u'%s and %s ago') % (fmt_funcs[part](value),
fmt_funcs[sub_part](sub_value))
if future:
return _(u'in %s') % fmt_funcs[part](value)
return _(u'in %s and %s') % (fmt_funcs[part](value),
return _(u'just now')
def uri_filter(uri):
Removes user:password from given url string
:param uri:
:returns: filtered list of strings
if not uri:
return ''
proto = ''
for pat in ('https://', 'http://'):
if uri.startswith(pat):
uri = uri[len(pat):]
proto = pat
break
# remove passwords and username
@@ -483,25 +494,25 @@ class AttributeDict(dict):
__delattr__ = dict.__delitem__
def fix_PATH(os_=None):
Get current active python path, and append it to PATH variable to fix issues
of subprocess calls and different python versions
import sys
if os_ is None:
import os
os = os_
cur_path = os.path.split(sys.executable)[0]
if not os.environ['PATH'].startswith(cur_path):
os.environ['PATH'] = '%s:%s' % (cur_path, os.environ['PATH'])
def obfuscate_url_pw(engine):
from sqlalchemy.engine import url
url = url.make_url(engine)
if url.password:
url.password = 'XXXXX'
return str(url)
\ No newline at end of file
@@ -108,52 +108,67 @@ class TestLibs(unittest.TestCase):
"@first hi there @marcink here's my email marcin@email.com "
"@lukaszb check @one_more22 it pls @ ttwelve @D[] @one@two@three "
"@MARCIN @maRCiN @2one_more22 @john please see this http://org.pl "
"@marian.user just do it @marco-polo and next extract @marco_polo "
"user.dot hej ! not-needed maril@domain.org"
)
s = sorted([
'first', 'marcink', 'lukaszb', 'one_more22', 'MARCIN', 'maRCiN', 'john',
'marian.user', 'marco-polo', 'marco_polo'
], key=lambda k: k.lower())
self.assertEqual(s, extract_mentioned_users(sample))
def test_age(self):
import calendar
from rhodecode.lib.utils2 import age
n = datetime.datetime.now()
delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs)
self.assertEqual(age(n), u'just now')
self.assertEqual(age(n - delt(seconds=1)), u'1 second ago')
self.assertEqual(age(n - delt(seconds=60 * 2)), u'2 minutes ago')
self.assertEqual(age(n - delt(hours=1)), u'1 hour ago')
self.assertEqual(age(n - delt(hours=24)), u'1 day ago')
self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago')
self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[n.month-1] + 2))),
self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[n.month - 1] + 2))),
u'1 month and 2 days ago')
self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago')
def test_age_in_future(self):
self.assertEqual(age(n + delt(seconds=1)), u'in 1 second')
self.assertEqual(age(n + delt(seconds=60 * 2)), u'in 2 minutes')
self.assertEqual(age(n + delt(hours=1)), u'in 1 hour')
self.assertEqual(age(n + delt(hours=24)), u'in 1 day')
self.assertEqual(age(n + delt(hours=24 * 5)), u'in 5 days')
self.assertEqual(age(n + delt(hours=24 * (calendar.mdays[n.month - 1] + 2))),
u'in 1 month and 1 days')
self.assertEqual(age(n + delt(hours=24 * 400)), u'in 1 year and 1 month')
def test_tag_exctrator(self):
sample = (
"hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]"
"[requires] [stale] [see<>=>] [see => http://url.com]"
"[requires => url] [lang => python] [just a tag]"
"[,d] [ => ULR ] [obsolete] [desc]]"
from rhodecode.lib.helpers import desc_stylize
res = desc_stylize(sample)
self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res)
self.assertTrue('<div class="metatag" tag="obsolete">obsolete</div>' in res)
self.assertTrue('<div class="metatag" tag="stale">stale</div>' in res)
self.assertTrue('<div class="metatag" tag="lang">python</div>' in res)
self.assertTrue('<div class="metatag" tag="requires">requires => <a href="/url">url</a></div>' in res)
def test_alternative_gravatar(self):
from rhodecode.lib.helpers import gravatar_url
_md5 = lambda s: hashlib.md5(s).hexdigest()
def fake_conf(**kwargs):
from pylons import config
config['app_conf'] = {}
config['app_conf']['use_gravatar'] = True
Status change: