Mercurial > kallithea
annotate pylons_app/model/hg_model.py @ 93:aec4c0071cb3
added empty controllers for branches tags files graph, routing and test for them
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 21 Apr 2010 00:26:11 +0200 |
parents | 670713507d03 |
children | a214462101d2 |
rev | line source |
---|---|
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
2 # encoding: utf-8 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
3 # |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
4 # Copyright (c) 2010 marcink. All rights reserved. |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
5 # |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
6 ''' |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
7 Created on Apr 9, 2010 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
8 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
9 @author: marcink |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
10 ''' |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
11 import os |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
12 from pylons import tmpl_context as c, app_globals as g, session, request, config |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
13 from pylons.controllers.util import abort |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
14 try: |
74
cdf4fda66dd9
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
Marcin Kuzminski <marcin@python-blog.com>
parents:
73
diff
changeset
|
15 from vcs.backends.hg import get_repositories, MercurialRepository |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
16 except ImportError: |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
17 print 'You have to import vcs module' |
93
aec4c0071cb3
added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
82
diff
changeset
|
18 raise |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
19 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
20 class HgModel(object): |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
21 """ |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
22 Mercurial Model |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
23 """ |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
24 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
25 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
26 def __init__(self): |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
27 """ |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
28 Constructor |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
29 """ |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
30 pass |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
31 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
32 def get_repos(self): |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
33 for mercurial_repo in get_repositories(g.paths[0][0], g.paths[0][1], g.baseui): |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
34 |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
35 if mercurial_repo._get_hidden(): |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
36 #skip hidden web repository |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
37 continue |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
38 |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
39 last_change = mercurial_repo.last_change |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
40 tip = mercurial_repo.repo.changectx('tip') |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
41 tmp_d = {} |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
42 tmp_d['name'] = mercurial_repo.name |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
43 tmp_d['name_sort'] = tmp_d['name'] |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
44 tmp_d['description'] = mercurial_repo.description |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
45 tmp_d['description_sort'] = tmp_d['description'] |
80
928416088790
reimplemented summary page,
Marcin Kuzminski <marcin@python-blog.com>
parents:
74
diff
changeset
|
46 tmp_d['last_change'] = last_change |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
47 tmp_d['last_change_sort'] = last_change[1] - last_change[0] |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
48 tmp_d['tip'] = str(tip) |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
49 tmp_d['tip_sort'] = tip.rev() |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
50 tmp_d['rev'] = tip.rev() |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
51 tmp_d['contact'] = mercurial_repo.contact |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
52 tmp_d['contact_sort'] = tmp_d['contact'] |
93
aec4c0071cb3
added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
82
diff
changeset
|
53 tmp_d['repo_archives'] = list(mercurial_repo._get_archives()) |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
54 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
55 yield tmp_d |
74
cdf4fda66dd9
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
Marcin Kuzminski <marcin@python-blog.com>
parents:
73
diff
changeset
|
56 |
cdf4fda66dd9
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
Marcin Kuzminski <marcin@python-blog.com>
parents:
73
diff
changeset
|
57 def get_repo(self, repo_name): |
80
928416088790
reimplemented summary page,
Marcin Kuzminski <marcin@python-blog.com>
parents:
74
diff
changeset
|
58 path = g.paths[0][1].replace('*', '') |
928416088790
reimplemented summary page,
Marcin Kuzminski <marcin@python-blog.com>
parents:
74
diff
changeset
|
59 repo = MercurialRepository(os.path.join(path, repo_name), baseui=g.baseui) |
74
cdf4fda66dd9
Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
Marcin Kuzminski <marcin@python-blog.com>
parents:
73
diff
changeset
|
60 return repo |