annotate pylons_app/lib/utils.py @ 489:460ad816820d celery

fixed bug when new repo had no last commiter, fixed bug when my_account updating information failed, by not uniq email address.
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 20 Sep 2010 22:47:20 +0200
parents 6b934c9607e7
children fefffd6fd5f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
1 #!/usr/bin/env python
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
2 # encoding: utf-8
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
3 # Utilities for hg app
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
5 # This program is free software; you can redistribute it and/or
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
6 # modify it under the terms of the GNU General Public License
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
7 # as published by the Free Software Foundation; version 2
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
8 # of the License or (at your opinion) any later version of the license.
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
9 #
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
10 # This program is distributed in the hope that it will be useful,
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
13 # GNU General Public License for more details.
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
14 #
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
15 # You should have received a copy of the GNU General Public License
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
16 # along with this program; if not, write to the Free Software
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
18 # MA 02110-1301, USA.
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
19 import shutil
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
20
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
21 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
22 Created on April 18, 2010
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
23 Utilities for hg app
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
24 @author: marcink
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
25 """
351
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
26 from beaker.cache import cache_region
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
27 from mercurial import ui, config, hg
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
28 from mercurial.error import RepoError
351
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
29 from pylons_app.model import meta
345
bb8f45f6d8f9 updated hg-app db manage and global settings
Marcin Kuzminski <marcin@python-works.com>
parents: 343
diff changeset
30 from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings
351
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
31 from vcs.backends.base import BaseChangeset
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
32 from vcs.utils.lazy import LazyProperty
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
33 import logging
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
34 import os
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
35 from os.path import dirname as dn, join as jn
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
36 import tarfile
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
37 log = logging.getLogger(__name__)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
38
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
39
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
40 def get_repo_slug(request):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
41 return request.environ['pylons.routes_dict'].get('repo_name')
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
42
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
43 def is_mercurial(environ):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
44 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
45 Returns True if request's target is mercurial server - header
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
46 ``HTTP_ACCEPT`` of such request would start with ``application/mercurial``.
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
47 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
48 http_accept = environ.get('HTTP_ACCEPT')
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
49 if http_accept and http_accept.startswith('application/mercurial'):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
50 return True
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
51 return False
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
52
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
53 def check_repo_dir(paths):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
54 repos_path = paths[0][1].split('/')
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
55 if repos_path[-1] in ['*', '**']:
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
56 repos_path = repos_path[:-1]
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
57 if repos_path[0] != '/':
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
58 repos_path[0] = '/'
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
59 if not os.path.isdir(os.path.join(*repos_path)):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
60 raise Exception('Not a valid repository in %s' % paths[0][1])
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
61
301
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
62 def check_repo_fast(repo_name, base_path):
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
63 if os.path.isdir(os.path.join(base_path, repo_name)):return False
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
64 return True
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
65
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
66 def check_repo(repo_name, base_path, verify=True):
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
67
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
68 repo_path = os.path.join(base_path, repo_name)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
69
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
70 try:
301
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
71 if not check_repo_fast(repo_name, base_path):
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
72 return False
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
73 r = hg.repository(ui.ui(), repo_path)
301
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
74 if verify:
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
75 hg.verify(r)
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
76 #here we hnow that repo exists it was verified
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
77 log.info('%s repo is already created', repo_name)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
78 return False
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
79 except RepoError:
301
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
80 #it means that there is no valid repo there...
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
81 log.info('%s repo is free for creation', repo_name)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
82 return True
301
752675cdd167 made routes verification method based only on paths, since it's much faster and enough
Marcin Kuzminski <marcin@python-works.com>
parents: 297
diff changeset
83
351
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
84 def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
85 while True:
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
86 ok = raw_input(prompt)
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
87 if ok in ('y', 'ye', 'yes'): return True
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
88 if ok in ('n', 'no', 'nop', 'nope'): return False
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
89 retries = retries - 1
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
90 if retries < 0: raise IOError
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
91 print complaint
d09381593b12 updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
92
343
6484963056cd implemented cache for repeated queries in simplehg mercurial requests
Marcin Kuzminski <marcin@python-works.com>
parents: 341
diff changeset
93 @cache_region('super_short_term', 'cached_hg_ui')
6484963056cd implemented cache for repeated queries in simplehg mercurial requests
Marcin Kuzminski <marcin@python-works.com>
parents: 341
diff changeset
94 def get_hg_ui_cached():
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
95 try:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
96 sa = meta.Session
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
97 ret = sa.query(HgAppUi).all()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
98 finally:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
99 meta.Session.remove()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
100 return ret
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
101
343
6484963056cd implemented cache for repeated queries in simplehg mercurial requests
Marcin Kuzminski <marcin@python-works.com>
parents: 341
diff changeset
102
345
bb8f45f6d8f9 updated hg-app db manage and global settings
Marcin Kuzminski <marcin@python-works.com>
parents: 343
diff changeset
103 def get_hg_settings():
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
104 try:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
105 sa = meta.Session
381
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
106 ret = sa.query(HgAppSettings).all()
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
107 finally:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
108 meta.Session.remove()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
109
345
bb8f45f6d8f9 updated hg-app db manage and global settings
Marcin Kuzminski <marcin@python-works.com>
parents: 343
diff changeset
110 if not ret:
bb8f45f6d8f9 updated hg-app db manage and global settings
Marcin Kuzminski <marcin@python-works.com>
parents: 343
diff changeset
111 raise Exception('Could not get application settings !')
381
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
112 settings = {}
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
113 for each in ret:
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
114 settings['hg_app_' + each.app_settings_name] = each.app_settings_value
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
115
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
116 return settings
386
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
117
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
118 def get_hg_ui_settings():
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
119 try:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
120 sa = meta.Session
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
121 ret = sa.query(HgAppUi).all()
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
122 finally:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
123 meta.Session.remove()
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
124
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
125 if not ret:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
126 raise Exception('Could not get application ui settings !')
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
127 settings = {}
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
128 for each in ret:
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
129 k = each.ui_key
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
130 v = each.ui_value
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
131 if k == '/':
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
132 k = 'root_path'
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
133
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
134 if k.find('.') != -1:
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
135 k = k.replace('.', '_')
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
136
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
137 if each.ui_section == 'hooks':
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
138 v = each.ui_active
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
139
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 392
diff changeset
140 settings[each.ui_section + '_' + k] = v
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
141
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
142 return settings
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
143
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
144 #propagated from mercurial documentation
386
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
145 ui_sections = ['alias', 'auth',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
146 'decode/encode', 'defaults',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
147 'diff', 'email',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
148 'extensions', 'format',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
149 'merge-patterns', 'merge-tools',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
150 'hooks', 'http_proxy',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
151 'smtp', 'patch',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
152 'paths', 'profiling',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
153 'server', 'trusted',
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
154 'ui', 'web', ]
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
155
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
156 def make_ui(read_from='file', path=None, checkpaths=True):
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
157 """
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
158 A function that will read python rc files or database
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
159 and make an mercurial ui object from read options
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
160
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
161 @param path: path to mercurial config file
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
162 @param checkpaths: check the path
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
163 @param read_from: read from 'file' or 'db'
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
164 """
386
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
165
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
166 baseui = ui.ui()
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
167
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
168 if read_from == 'file':
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
169 if not os.path.isfile(path):
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
170 log.warning('Unable to read config file %s' % path)
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
171 return False
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
172 log.debug('reading hgrc from %s', path)
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
173 cfg = config.config()
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
174 cfg.read(path)
386
a9a607a58b1c moved out ui_sections out of make ui function
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
175 for section in ui_sections:
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
176 for k, v in cfg.items(section):
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
177 baseui.setconfig(section, k, v)
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 386
diff changeset
178 log.debug('settings ui from file[%s]%s:%s', section, k, v)
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
179 if checkpaths:check_repo_dir(cfg.items('paths'))
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
180
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
181
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
182 elif read_from == 'db':
343
6484963056cd implemented cache for repeated queries in simplehg mercurial requests
Marcin Kuzminski <marcin@python-works.com>
parents: 341
diff changeset
183 hg_ui = get_hg_ui_cached()
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
184 for ui_ in hg_ui:
392
b27d32cb3157 Implemented hooks system,
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
185 if ui_.ui_active:
b27d32cb3157 Implemented hooks system,
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
186 log.debug('settings ui from db[%s]%s:%s', ui_.ui_section, ui_.ui_key, ui_.ui_value)
b27d32cb3157 Implemented hooks system,
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
187 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value)
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
188
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
189
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
190 return baseui
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
191
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
192
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
193 def set_hg_app_config(config):
345
bb8f45f6d8f9 updated hg-app db manage and global settings
Marcin Kuzminski <marcin@python-works.com>
parents: 343
diff changeset
194 hgsettings = get_hg_settings()
381
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
195
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
196 for k, v in hgsettings.items():
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 367
diff changeset
197 config[k] = v
341
1ef52a70f3b7 Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 301
diff changeset
198
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
199 def invalidate_cache(name, *args):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
200 """Invalidates given name cache"""
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
201
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
202 from beaker.cache import region_invalidate
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
203 log.info('INVALIDATING CACHE FOR %s', name)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
204
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
205 """propagate our arguments to make sure invalidation works. First
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
206 argument has to be the name of cached func name give to cache decorator
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
207 without that the invalidation would not work"""
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
208 tmp = [name]
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
209 tmp.extend(args)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
210 args = tuple(tmp)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
211
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
212 if name == 'cached_repo_list':
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
213 from pylons_app.model.hg_model import _get_repos_cached
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
214 region_invalidate(_get_repos_cached, None, *args)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
215
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
216 if name == 'full_changelog':
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
217 from pylons_app.model.hg_model import _full_changelog_cached
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
218 region_invalidate(_full_changelog_cached, None, *args)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
219
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
220 class EmptyChangeset(BaseChangeset):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
221
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
222 revision = -1
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
223 message = ''
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
224 author = ''
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
225
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
226 @LazyProperty
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
227 def raw_id(self):
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
228 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
229 Returns raw string identifing this changeset, useful for web
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
230 representation.
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
231 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
232 return '0' * 12
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
233
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
234
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
235 def repo2db_mapper(initial_repo_list, remove_obsolete=False):
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
236 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
237 maps all found repositories into db
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
238 """
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
239 from pylons_app.model.repo_model import RepoModel
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
240
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
241 sa = meta.Session
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
242 user = sa.query(User).filter(User.admin == True).first()
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
243
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
244 rm = RepoModel()
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
245
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
246 for name, repo in initial_repo_list.items():
367
a26f48ad7a8a fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents: 358
diff changeset
247 if not sa.query(Repository).filter(Repository.repo_name == name).scalar():
297
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
248 log.info('repository %s not found creating default', name)
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
249
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
250 form_data = {
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
251 'repo_name':name,
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
252 'description':repo.description if repo.description != 'unknown' else \
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
253 'auto description for %s' % name,
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
254 'private':False
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
255 }
a074dec6ee40 restored utils, wrongly deleted
Marcin Kuzminski <marcin@python-works.com>
parents: 295
diff changeset
256 rm.create(form_data, user, just_db=True)
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
257
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
258
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
259 if remove_obsolete:
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
260 #remove from database those repositories that are not in the filesystem
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
261 for repo in sa.query(Repository).all():
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
262 if repo.repo_name not in initial_repo_list.keys():
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
263 sa.delete(repo)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
264 sa.commit()
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 345
diff changeset
265
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
266
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
267 meta.Session.remove()
358
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
268
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
269 from UserDict import DictMixin
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
270
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
271 class OrderedDict(dict, DictMixin):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
272
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
273 def __init__(self, *args, **kwds):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
274 if len(args) > 1:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
275 raise TypeError('expected at most 1 arguments, got %d' % len(args))
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
276 try:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
277 self.__end
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
278 except AttributeError:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
279 self.clear()
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
280 self.update(*args, **kwds)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
281
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
282 def clear(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
283 self.__end = end = []
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
284 end += [None, end, end] # sentinel node for doubly linked list
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
285 self.__map = {} # key --> [key, prev, next]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
286 dict.clear(self)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
287
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
288 def __setitem__(self, key, value):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
289 if key not in self:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
290 end = self.__end
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
291 curr = end[1]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
292 curr[2] = end[1] = self.__map[key] = [key, curr, end]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
293 dict.__setitem__(self, key, value)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
294
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
295 def __delitem__(self, key):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
296 dict.__delitem__(self, key)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
297 key, prev, next = self.__map.pop(key)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
298 prev[2] = next
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
299 next[1] = prev
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
300
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
301 def __iter__(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
302 end = self.__end
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
303 curr = end[2]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
304 while curr is not end:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
305 yield curr[0]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
306 curr = curr[2]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
307
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
308 def __reversed__(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
309 end = self.__end
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
310 curr = end[1]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
311 while curr is not end:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
312 yield curr[0]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
313 curr = curr[1]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
314
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
315 def popitem(self, last=True):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
316 if not self:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
317 raise KeyError('dictionary is empty')
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
318 if last:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
319 key = reversed(self).next()
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
320 else:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
321 key = iter(self).next()
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
322 value = self.pop(key)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
323 return key, value
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
324
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
325 def __reduce__(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
326 items = [[k, self[k]] for k in self]
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
327 tmp = self.__map, self.__end
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
328 del self.__map, self.__end
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
329 inst_dict = vars(self).copy()
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
330 self.__map, self.__end = tmp
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
331 if inst_dict:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
332 return (self.__class__, (items,), inst_dict)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
333 return self.__class__, (items,)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
334
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
335 def keys(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
336 return list(self)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
337
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
338 setdefault = DictMixin.setdefault
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
339 update = DictMixin.update
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
340 pop = DictMixin.pop
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
341 values = DictMixin.values
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
342 items = DictMixin.items
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
343 iterkeys = DictMixin.iterkeys
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
344 itervalues = DictMixin.itervalues
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
345 iteritems = DictMixin.iteritems
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
346
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
347 def __repr__(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
348 if not self:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
349 return '%s()' % (self.__class__.__name__,)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
350 return '%s(%r)' % (self.__class__.__name__, self.items())
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
351
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
352 def copy(self):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
353 return self.__class__(self)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
354
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
355 @classmethod
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
356 def fromkeys(cls, iterable, value=None):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
357 d = cls()
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
358 for key in iterable:
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
359 d[key] = value
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
360 return d
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
361
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
362 def __eq__(self, other):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
363 if isinstance(other, OrderedDict):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
364 return len(self) == len(other) and self.items() == other.items()
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
365 return dict.__eq__(self, other)
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
366
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
367 def __ne__(self, other):
23e720be5f44 Added implementation of Ordered Dict.
Marcin Kuzminski <marcin@python-works.com>
parents: 351
diff changeset
368 return not self == other
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
369
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
370 def make_test_env():
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
371 """Makes a fresh database from base64+zlib dump and
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
372 install test repository into tmp dir
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
373 """
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
374 new_db_dump = """
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
375 eJztXN1vE8sVn9nxR+wAIXDpFiiXjSAXfEOc2ElwQkVLPjYf5NNOAklUydrYG3tv1t5ldx0nuUJV\noL
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
376 cPrVr1X7jSfUJ96nMfK1Xty23VqlWlPlRIlahUXbXqFUL0pTNjx5614xAoKEDmJ3t2zpkzM2fO\neHe+
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
377 zno+PqU5qrRmWDnFkXqAB0AIbkkSAKANf8+BKprwFzI0G28ECXQ+PufFEYT+Tehz6L/oaSnK\nwcFxGP
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
378 igFQfHjuMg4CehH7UA9Af0Y2ShWdSPLmOSg+N9x7U9eKf9PiC2nIWm4mTtri4nZ3Z9DE/5\nfOD0+RZY
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
379 VFdXFVstWHoXPOPFvDbKU3TdKCbNgp39GLZ5MPtKW5WtWKmstqFmtqVtzZRWt6NQRFjk\ngkhESJ6kbe
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
380 trim6rcFTAdcfuwqxhrNuprJLPqBnLKJhhSzWNpK1tq+aWkzXyN8wt3cjbScU0w7q2\nGqbyVSHYAXE5
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
381 kSv15RTMtOKo2YxUikjf+SgKg4Dc/38C6Dn6Gn2FnqDH6K+Y5ODgeGfhRRD6/ST0\n+Ujo9ZLQ4yEhQi
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
382 QUBBJCeFy4BLywHaCfCEXM+AJHOWpx39sMrux4IbzQ3gMc1XaSlpop6IoVvRxV\nLke6L4/cmx7vjedG
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
383 4qmVmXvTW5nl7PDaSmFEXR6ejC+YVrpnsNi1fn17fHldj06p6YH84tzaGKBF\n5ZWcSq66Uorn8Iih5W
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
384 /ZBolqejhl5O57mkEPqf6sOFCq3lRsu2hYaayHrTplJeJD/Uu3p7u3Er19\nS4sb26PmemQiE54vLKfn
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
385 I8Wx2/Nd+XurmbH4TOpupHdk25I/sYbmCgDQstK0oHLdpWGmc1U3MqR6\nbICF123RHb/QDNpIm1rFnk
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
386 HaJiWd0/Llpgzq41lzIJMrjMXi2/JmdyGxMDKnjs1FR9WMcduMb3TZ\nfZuZTXVs1uiS53NxY9yan4Vw
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
387 PDNICqEl3dKNlKJnDdshbYh2R7o7uwc6I1EpGr3RHbvREwn3D/T3\nd/fuBFAzaHdpUu7csi6Tw4ou94
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
388 zOLt3JxTNZo7g8muvV1Lg6sNj/SX4dD7srqenpfCJ6d3g5vKRM\njq/Ob3VHIXgJXaKx8PWBvoHrvfdg
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
389 MzhPVDl/vgek1TWloO927tbUdsqeNzfurK5Frq+v5NbHZ1bG\nCnZxdnxxbGStmOudnwub6+rQYNxZku
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
390 Wh28Ph9Nos2C3EfblVvhJlyPjvRY+Z8f91dzUHB8fhYf/x\nv3T/PwL47v87+iX6I45ycHC8dWhFV6Br
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
391 7ukVUQ/cYzroOYnaXZLoBGqD1TmW0IzOw/IUAJL9v6Dg\nA+jP6Ofo+yiBelFA+IvwC2EFMzmOCBJBD/
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
392 huMZsJ41+MZjuqFVYKjpFUUo62oThqosyV8mpRKtg4\nUtScrJTNdCqmSeNGwZFIFqmcRTPydwIeMPwp
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
393 W2ZOyRcU/SVLLWViym1v8oDOLrbcvJGvFpbWbGVV\nV9NhvweEZCyWslRcWVnINGzNMawtiXJxaRX5kM
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
394 8D+rqq8lZFtjaX+i2vB1zoxKL0dhrPSHSmj6u3\nFCzV4cH6fbuavSTFFEJp3KCUatsdqEa4aGkOqyel
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
395 y8IhwQM6BhhhrE2akSVkWfQKxKJ9jGhN8/NG\nWZCM/0H0q5r9P/Q79FvM5ODgeOtBZvLBIAkDARI2Nb
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
396 3E/h/O7wdDAAzBj+Cy8IXwpfAc/eZlat9R\noF+8eBE+bHXIgzSbIQcTyYJWiQjDCXlwQZYWBoemZKnC
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
397 lq4GAwUtqaWliZkFeUxOSDOzC9LM4tTU\nNYmm2GqKPqEX5KWFMmtd3WLJDUUvqCyDjhKqNDQ7OyUPzh
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
398 DmXGJiejCxLE3Ky9JVWl2IsBdnJuKL\nMssZHpeHJymjXMjEjHS1+5oUCYWCoYjgE+WLEGj5tLpp39Px
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
399 MzlJhjtKJytNSkYqUfRgHPlFUYQ/\nMKhZyPhm08DjMgdlUVPgSENj4DSyN1hp6u6Er8Kob3hplGEYrg
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
400 J2dxsrDLrZ6EpO6kYGlzCCdV2Y\nmJbrjVlS2G1Ohlc2aJ012TSqozuJLYpoiK0f8vjEm2Ij61MLJiP0
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
401 4g15XywapRffzpTPL166BB8k\naQeZqpXTbBv/4Gwm6nd1FpNAuqxKNuo4RsLdf1W+buQzrjSXkV1VuO
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
402 zjTgmG+vw+ceJSo5Yzmicj\nDNFE7n8BfQnQ33DAwcHxLqMFLxHEs47mkIGYrKM+xAsBMYZXBnquvLDC
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
403 D4Wsmne0FF3/kPm/gL6m\n8//DVp6Dg+PNo3b+7wOPAHgEH8F/CFfRT9GvD1u/vbFzv8kvdnTAhxF2nW
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
404 GrjqPlM3YNGdxrzbGb\nSOZuLN1o9uaScc3RXCnuVYhr+lZTi2sCd+C08iz4ZsAnxjtesAapZIrUMJpv
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
405 Bl8me7SGcfxBqtkv\ntrfDzwLU+pWdJU212fgJl93ZFGJ06qPWwNg0rWLkuuVPwxm2RfcS2YVOWrVTlm
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
406 a61o6uXimr4bJ4\npfp67r6So7MJeWJshhRcWf1ICXlUTsgzw/L87vpuj4XRrubsOjN2zCdOtjfqJNac
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
407 yQhLtcSOHzhj\nlKVOlsb/fwL0FAccHBzvLQJIhHRpIJAYXRPQ8R+i3wP84eDgeNfRCX3gAoRjGyk7Sc
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
408 78BUDPZdlJ\n0ZphSbvJZPyH6D8Afzg4ON5/HEMX4O7tD0v3/3OAPxwcHEcG1f0/hJ4A9Az9C184ODje
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
409 Q/gQ+WcP\nKPgEevX5IL0GyPiP0Fdl/7/D1pKDg+PNYe/3f+j4/wSP/88OWz8ODo43Ab+H3O0CKl19Qu
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
410 kaoPN/\nD/gcgM+FD4W7ws8OW886PNg+UTp4jlX8aJOOQR0a2XhrnVftbkrFubZM7+dkewA/zgYS9a6x
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
411 1erq\nXWRr0thDZLdfJ3uU7PI+rXcMfYWT6Bq33WtSrVNprGW/Y2VXUyIsdSp28sAZoyx1+kGulXqTfx
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
412 aq\ndrduZOxK5Ex9RxN2pZcx8So9XEozKw4D1Vdn6v0RFLdfeolM0r/U2d9buqRbvekZ/iv0IpulqrYr
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
413 \nl9sRo+rBEAyR+x8/ADg4OI4gyPyf3/8cHEcTJf+fpwB/ODg4jgSaoBfQ/QB+/s/BcSRR3f+H6Bng\n
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
414 e/8cHEcHpf1/CI+jHwEP3AToLtx8e9/9e//w8Hun6bHGDz+tvE+3uwfOxsW69+nYYw2WfjPHGtX9\n5A
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
415 MdfNQo9P+eS7youNdyVuJq4ot2zRsdnLgLCYYip/b7w5jKqUX51IREv4F/FJ7YBy96ja963sJS\n34yd
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
416 OXDGKEud/R8efZUt\n
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
417 """
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
418 newdb = open('test.db', 'wb')
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
419 newdb.write(new_db_dump.decode('base64').decode('zlib'))
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
420 newdb.close()
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
421
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
422
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
423 #PART TWO make test repo
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
424 if os.path.isdir('/tmp/vcs_test'):
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
425 shutil.rmtree('/tmp/vcs_test')
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
426
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
427 cur_dir = dn(dn(os.path.abspath(__file__)))
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
428 tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test.tar.gz"))
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
429 tar.extractall('/tmp')
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
430 tar.close()
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
431
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
432
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
433