• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


コミットメタ情報

リビジョン830553c95213cf9a9fc87c6ceb037bbad327f599 (tree)
日時2011-04-30 05:11:32
作者John Hoffmann <jwh@geek...>
コミッターJohn Hoffmann

ログメッセージ

[#1692] Merge, conflict in requirements-common.txt

Signed-off-by: John Hoffmann <jwh@geek.net>

変更サマリ

差分

--- a/Allura/allura/command/base.py
+++ b/Allura/allura/command/base.py
@@ -12,6 +12,8 @@ from paste.registry import Registry
1212 import ming
1313 from allura.config.environment import load_environment
1414
15+log = None
16+
1517 class EmptyClass(object): pass
1618
1719 class Command(command.Command):
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -140,14 +140,20 @@ class Repository(Artifact):
140140 def __init__(self, **kw):
141141 if 'name' in kw and 'tool' in kw:
142142 if 'fs_path' not in kw:
143- repos_root = tg.config.get('scm.repos.root', '/')
144- kw['fs_path'] = os.path.join(repos_root,
145- kw['tool'],
146- c.project.url()[1:])
143+ kw['fs_path'] = self.default_fs_path(c.project, kw['tool'])
147144 if 'url_path' not in kw:
148- kw['url_path'] = c.project.url()
145+ kw['url_path'] = self.default_url_path(c.project, kw['tool'])
149146 super(Repository, self).__init__(**kw)
150147
148+ @classmethod
149+ def default_fs_path(cls, project, tool):
150+ repos_root = tg.config.get('scm.repos.root', '/')
151+ return os.path.join(repos_root, tool, project.url()[1:])
152+
153+ @classmethod
154+ def default_url_path(cls, project, tool):
155+ return project.url()
156+
151157 def __repr__(self): # pragma no cover
152158 return '<%s %s>' % (
153159 self.__class__.__name__,
--- a/scripts/backup_project.py
+++ b/scripts/backup_project.py
@@ -47,7 +47,20 @@ def dump_project(project, dirname):
4747 c.project = project
4848 app_config_ids = [
4949 ac._id for ac in M.AppConfig.query.find(dict(project_id=c.project._id)) ]
50+ visited_collections = {}
5051 for name, cls in MappedClass._registry.iteritems():
52+ cname = cls.__mongometa__.name
53+ sess = cls.__mongometa__.session
54+ if sess is None:
55+ log.info('Skipping %s which has no session', cls)
56+ continue
57+ dbname = sess.impl.db.name
58+ fqname = cname + '/' + dbname
59+ if fqname in visited_collections:
60+ log.info('Skipping %s (already dumped collection %s in %s)',
61+ cls, fqname, visited_collections[fqname])
62+ continue
63+ visited_collections[fqname] = cls
5164 if 'project_id' in mapper(cls).property_index:
5265 # Dump the things directly related to the project
5366 oq = cls.query.find(dict(project_id=project._id))
@@ -59,8 +72,11 @@ def dump_project(project, dirname):
5972 continue
6073 num_objs = oq.count()
6174 if num_objs == 0: continue
75+ if not os.path.exists(os.path.join(dirname, dbname)):
76+ os.mkdir(os.path.join(dirname, dbname))
6277 fname = os.path.join(
6378 dirname,
79+ dbname,
6480 '%s.bson' % (cls.__mongometa__.name))
6581 log.info('%s: dumping %s objects to %s',
6682 name, num_objs, fname)
--- a/scripts/restore_project.py
+++ b/scripts/restore_project.py
@@ -3,6 +3,7 @@ import sys
33 import struct
44 import logging
55
6+from ming.schema import Invalid
67 from ming.orm import state, session, mapper, MappedClass
78 from ming.orm.base import instrument, DocumentTracker
89
@@ -36,28 +37,38 @@ def restore_project(dirname, new_shortname, new_unix_group_name):
3637 project.set_tool_data('sfx', unix_group_name=new_unix_group_name)
3738 project.deleted = False
3839 c.project = project
39- for name, cls in MappedClass._registry.iteritems():
40- if session(cls) is None: continue
41- m = mapper(cls)
42- sess = session(cls).impl
43- fname = os.path.join(dirname, '%s.bson' % (cls.__mongometa__.name))
44- if not os.path.exists(fname): continue
45- if ('project_id' not in m.property_index
46- and 'app_config_id' not in m.property_index): continue
47- with open(fname, 'rb') as fp:
48- num_objects = 0
49- while True:
50- doc = _read_bson(fp)
51- if doc is None: break
52- num_objects += 1
53- sess.insert(m.doc_cls(doc))
54- log.info('%s: loaded %s objects from %s',
55- name, num_objects, fname)
40+ conn = M.main_doc_session.db.connection
41+ repo_collections = get_repo_collections()
42+ for dbname in os.listdir(dirname):
43+ if dbname.endswith('.bson'): continue
44+ for fname in os.listdir(os.path.join(dirname, dbname)):
45+ cname = os.path.splitext(fname)[0]
46+ collection = conn[dbname][cname]
47+ with open(os.path.join(dirname, dbname, fname), 'rb') as fp:
48+ num_objects = 0
49+ while True:
50+ doc = _read_bson(fp)
51+ if doc is None: break
52+ if cname in repo_collections:
53+ cls = repo_collections[cname]
54+ doc['fs_path'] = cls.default_fs_path(project, doc['tool'])
55+ doc['url_path'] = cls.default_url_path(project, doc['tool'])
56+ collection.insert(doc)
57+ num_objects += 1
58+ log.info('%s: loaded %s objects from %s',
59+ dbname, num_objects, fname)
5660 session(project).flush()
5761 reindex= ReindexCommand('reindex')
5862 reindex.run(['--project', new_shortname])
5963 return 0
6064
65+def get_repo_collections():
66+ res = {}
67+ for name, cls in MappedClass._registry.iteritems():
68+ cname = cls.__mongometa__.name
69+ if issubclass(cls, M.Repository): res[cname] = cls
70+ return res
71+
6172 def _read_bson(fp):
6273 slen = fp.read(4)
6374 if not slen: return None