Mercurial > public > src > rhodecode
annotate pylons_app/model/hg_model.py @ 222:f7dadd356c79
fixed sorting of repos with big letters
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 25 May 2010 23:40:01 +0200 |
parents | 7109d15c6813 |
children | a83a1799480c |
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 # |
136
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
6 from vcs.exceptions import RepositoryError |
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
|
7 ''' |
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 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
|
9 |
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 @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
|
11 ''' |
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 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
|
13 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
|
14 from pylons.controllers.util import abort |
195
7109d15c6813
cleared prints leftoovers, and changed current user fetching in login controller
Marcin Kuzminski <marcin@python-works.com>
parents:
136
diff
changeset
|
15 import sys |
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 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
|
17 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
|
18 except ImportError: |
195
7109d15c6813
cleared prints leftoovers, and changed current user fetching in login controller
Marcin Kuzminski <marcin@python-works.com>
parents:
136
diff
changeset
|
19 sys.stderr.write('You have to import vcs module') |
95
a214462101d2
Change logic for more vcs based.
Marcin Kuzminski <marcin@python-works.com>
parents:
93
diff
changeset
|
20 raise Exception('Unable to import vcs') |
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
|
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 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
|
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 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
|
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 |
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 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
|
29 """ |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
30 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
|
31 """ |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
32 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
|
33 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
34 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
|
35 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
|
36 |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
37 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
|
38 #skip hidden web repository |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
39 continue |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
40 |
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
41 last_change = mercurial_repo.last_change |
136
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
42 try: |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
43 tip = mercurial_repo.get_changeset('tip') |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
44 except RepositoryError: |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
45 from pylons_app.lib.utils import EmptyChangeset |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
46 tip = EmptyChangeset() |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
47 |
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
|
48 tmp_d = {} |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
49 tmp_d['name'] = mercurial_repo.name |
222
f7dadd356c79
fixed sorting of repos with big letters
Marcin Kuzminski <marcin@python-works.com>
parents:
195
diff
changeset
|
50 tmp_d['name_sort'] = tmp_d['name'].lower() |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
51 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
|
52 tmp_d['description_sort'] = tmp_d['description'] |
80
928416088790
reimplemented summary page,
Marcin Kuzminski <marcin@python-blog.com>
parents:
74
diff
changeset
|
53 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
|
54 tmp_d['last_change_sort'] = last_change[1] - last_change[0] |
136
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
55 tmp_d['tip'] = tip.raw_id |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
56 tmp_d['tip_sort'] = tip.revision |
36102488d634
Added empty changeset to use in newly created repository, and used this inside a hg model in repos list
Marcin Kuzminski <marcin@python-works.com>
parents:
95
diff
changeset
|
57 tmp_d['rev'] = tip.revision |
73
55d7f2502dfb
Updated model with never vcs implementation using MercurialRepo class
Marcin Kuzminski <marcin@python-blog.com>
parents:
68
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 |
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
62 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
|
63 |
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
|
64 def get_repo(self, repo_name): |
80
928416088790
reimplemented summary page,
Marcin Kuzminski <marcin@python-blog.com>
parents:
74
diff
changeset
|
65 path = g.paths[0][1].replace('*', '') |
928416088790
reimplemented summary page,
Marcin Kuzminski <marcin@python-blog.com>
parents:
74
diff
changeset
|
66 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
|
67 return repo |