2
# Copyright (C) 2006 Robey Pointer <robey@lag.net>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
return '%d days' % delta.days
31
seg.append('%d days' % delta.days)
32
hrs = delta.seconds // 3600
33
mins = (delta.seconds % 3600) // 60
38
seg.append('%d hours' % hrs)
42
seg.append('1 minute')
44
seg.append('%d minutes' % mins)
46
seg.append('less than a minute')
50
class Container (object):
52
Convert a dict into an object with attributes.
54
def __init__(self, _dict=None, **kw):
56
for key, value in _dict.iteritems():
57
setattr(self, key, value)
58
for key, value in kw.iteritems():
59
setattr(self, key, value)
62
def clean_revid(revid):
63
if revid == 'missing':
65
return sha.new(revid).hexdigest()
69
return ''.join([ '&#%d;' % ord(c) for c in text ])
72
STANDARD_PATTERN = re.compile(r'^(.*?)\s*<(.*?)>\s*$')
73
EMAIL_PATTERN = re.compile(r'[-\w\d\+_!%\.]+@[-\w\d\+_!%\.]+')
75
def hide_email(email):
77
try to obsure any email address in a bazaar committer's name.
79
m = STANDARD_PATTERN.search(email)
84
m = EMAIL_PATTERN.search(email)
86
# can't find an email address in here
88
username, domain = m.group(0).split('@')
89
domains = domain.split('.')
91
return '%s at %s' % (username, domains[-2])
92
return '%s at %s' % (username, domains[0])
100
yield n * factors[index]
102
if index >= len(factors):
107
def scan_range(pos, max):
109
given a position in a maximum range, return a list of negative and positive
110
jump factors for an hgweb-style triple-factor geometric scan.
112
for example, with pos=20 and max=500, the range would be:
113
[ -10, -3, -1, 1, 3, 10, 30, 100, 300 ]
115
i admit this is a very strange way of jumping through revisions. i didn't
119
for n in triple_factors():