Show More
@@ -1,60 +1,61 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | # encoding: utf-8 |
|
2 | # encoding: utf-8 | |
3 | # |
|
3 | # | |
4 | # Copyright (c) 2010 marcink. All rights reserved. |
|
4 | # Copyright (c) 2010 marcink. All rights reserved. | |
5 | # |
|
5 | # | |
6 | ''' |
|
6 | ''' | |
7 | Created on Apr 9, 2010 |
|
7 | Created on Apr 9, 2010 | |
8 |
|
8 | |||
9 | @author: marcink |
|
9 | @author: marcink | |
10 | ''' |
|
10 | ''' | |
11 | import os |
|
11 | import os | |
12 | from pylons import tmpl_context as c, app_globals as g, session, request, config |
|
12 | from pylons import tmpl_context as c, app_globals as g, session, request, config | |
13 | from pylons.controllers.util import abort |
|
13 | from pylons.controllers.util import abort | |
14 | try: |
|
14 | try: | |
15 | from vcs.backends.hg import get_repositories, MercurialRepository |
|
15 | from vcs.backends.hg import get_repositories, MercurialRepository | |
16 | except ImportError: |
|
16 | except ImportError: | |
17 | print 'You have to import vcs module' |
|
17 | print 'You have to import vcs module' | |
18 | raise |
|
18 | raise Exception('Unable to import vcs') | |
19 |
|
19 | |||
20 | class HgModel(object): |
|
20 | class HgModel(object): | |
21 | """ |
|
21 | """ | |
22 | Mercurial Model |
|
22 | Mercurial Model | |
23 | """ |
|
23 | """ | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | def __init__(self): |
|
26 | def __init__(self): | |
27 | """ |
|
27 | """ | |
28 | Constructor |
|
28 | Constructor | |
29 | """ |
|
29 | """ | |
30 | pass |
|
30 | pass | |
31 |
|
31 | |||
32 | def get_repos(self): |
|
32 | def get_repos(self): | |
33 | for mercurial_repo in get_repositories(g.paths[0][0], g.paths[0][1], g.baseui): |
|
33 | for mercurial_repo in get_repositories(g.paths[0][0], g.paths[0][1], g.baseui): | |
34 |
|
34 | |||
35 | if mercurial_repo._get_hidden(): |
|
35 | if mercurial_repo._get_hidden(): | |
36 | #skip hidden web repository |
|
36 | #skip hidden web repository | |
37 | continue |
|
37 | continue | |
38 |
|
38 | |||
39 | last_change = mercurial_repo.last_change |
|
39 | last_change = mercurial_repo.last_change | |
40 |
tip = mercurial_repo. |
|
40 | tip_rev = mercurial_repo._get_revision('tip') | |
|
41 | tip = mercurial_repo.get_changeset(tip_rev) | |||
41 | tmp_d = {} |
|
42 | tmp_d = {} | |
42 | tmp_d['name'] = mercurial_repo.name |
|
43 | tmp_d['name'] = mercurial_repo.name | |
43 | tmp_d['name_sort'] = tmp_d['name'] |
|
44 | tmp_d['name_sort'] = tmp_d['name'] | |
44 | tmp_d['description'] = mercurial_repo.description |
|
45 | tmp_d['description'] = mercurial_repo.description | |
45 | tmp_d['description_sort'] = tmp_d['description'] |
|
46 | tmp_d['description_sort'] = tmp_d['description'] | |
46 | tmp_d['last_change'] = last_change |
|
47 | tmp_d['last_change'] = last_change | |
47 | tmp_d['last_change_sort'] = last_change[1] - last_change[0] |
|
48 | tmp_d['last_change_sort'] = last_change[1] - last_change[0] | |
48 |
tmp_d['tip'] = |
|
49 | tmp_d['tip'] = tip._short | |
49 |
tmp_d['tip_sort'] = tip |
|
50 | tmp_d['tip_sort'] = tip_rev | |
50 |
tmp_d['rev'] = tip |
|
51 | tmp_d['rev'] = tip_rev | |
51 | tmp_d['contact'] = mercurial_repo.contact |
|
52 | tmp_d['contact'] = mercurial_repo.contact | |
52 | tmp_d['contact_sort'] = tmp_d['contact'] |
|
53 | tmp_d['contact_sort'] = tmp_d['contact'] | |
53 | tmp_d['repo_archives'] = list(mercurial_repo._get_archives()) |
|
54 | tmp_d['repo_archives'] = list(mercurial_repo._get_archives()) | |
54 |
|
55 | |||
55 | yield tmp_d |
|
56 | yield tmp_d | |
56 |
|
57 | |||
57 | def get_repo(self, repo_name): |
|
58 | def get_repo(self, repo_name): | |
58 | path = g.paths[0][1].replace('*', '') |
|
59 | path = g.paths[0][1].replace('*', '') | |
59 | repo = MercurialRepository(os.path.join(path, repo_name), baseui=g.baseui) |
|
60 | repo = MercurialRepository(os.path.join(path, repo_name), baseui=g.baseui) | |
60 | return repo |
|
61 | return repo |
General Comments 0
You need to be logged in to leave comments.
Login now