|
a/ForgeSVN/forgesvn/model/svn.py |
|
b/ForgeSVN/forgesvn/model/svn.py |
|
... |
|
... |
7 |
from cStringIO import StringIO
|
7 |
from cStringIO import StringIO
|
8 |
from datetime import datetime
|
8 |
from datetime import datetime
|
9 |
|
9 |
|
10 |
import tg
|
10 |
import tg
|
11 |
import pysvn
|
11 |
import pysvn
|
|
|
12 |
from pymongo.errors import DuplicateKeyError
|
12 |
|
13 |
|
13 |
from ming.base import Object
|
14 |
from ming.base import Object
|
14 |
from ming.orm import Mapper, FieldProperty, session
|
15 |
from ming.orm import Mapper, FieldProperty, session
|
15 |
from ming.utils import LazyProperty
|
16 |
from ming.utils import LazyProperty
|
16 |
|
17 |
|
|
... |
|
... |
159 |
oid = rev
|
160 |
oid = rev
|
160 |
result = M.Commit.query.get(object_id=oid)
|
161 |
result = M.Commit.query.get(object_id=oid)
|
161 |
if result is None: return None
|
162 |
if result is None: return None
|
162 |
result.set_context(self._repo)
|
163 |
result.set_context(self._repo)
|
163 |
return result
|
164 |
return result
|
|
|
165 |
|
|
|
166 |
def all_commit_ids(self):
|
|
|
167 |
head_revno = self._revno(self._repo.heads[0].object_id)
|
|
|
168 |
return map(self._oid, range(1, head_revno+1))
|
164 |
|
169 |
|
165 |
def new_commits(self, all_commits=False):
|
170 |
def new_commits(self, all_commits=False):
|
166 |
head_revno = self._revno(self._repo.heads[0].object_id)
|
171 |
head_revno = self._revno(self._repo.heads[0].object_id)
|
167 |
oids = [ self._oid(revno) for revno in range(1, head_revno+1) ]
|
172 |
oids = [ self._oid(revno) for revno in range(1, head_revno+1) ]
|
168 |
if all_commits:
|
173 |
if all_commits:
|
|
... |
|
... |
232 |
old=h.really_unicode(path.copyfrom_path),
|
237 |
old=h.really_unicode(path.copyfrom_path),
|
233 |
new=h.really_unicode(path.path)))
|
238 |
new=h.really_unicode(path.path)))
|
234 |
continue
|
239 |
continue
|
235 |
lst[path.action].append(h.really_unicode(path.path))
|
240 |
lst[path.action].append(h.really_unicode(path.path))
|
236 |
|
241 |
|
|
|
242 |
def refresh_commit_info(self, oid, seen_object_ids):
|
|
|
243 |
from alllura.model.repo import CommitDoc
|
|
|
244 |
if CommitDoc.m.find(dict(_id=oid)).count():
|
|
|
245 |
return False
|
|
|
246 |
try:
|
|
|
247 |
log.info('Refresh %r %r', oid, self._repo)
|
|
|
248 |
revno = self._revno(oid)
|
|
|
249 |
rev = self._revision(oid)
|
|
|
250 |
try:
|
|
|
251 |
log_entry = self._svn.log(
|
|
|
252 |
self._url,
|
|
|
253 |
revision_start=rev,
|
|
|
254 |
limit=1,
|
|
|
255 |
discover_changed_paths=True)[0]
|
|
|
256 |
except pysvn.ClientError:
|
|
|
257 |
log.info('ClientError processing %r %r, treating as empty', oid, self._repo, exc_info=True)
|
|
|
258 |
log_entry = Object(date='', message='', changed_paths=[])
|
|
|
259 |
user = Object(
|
|
|
260 |
name=log_entry.get('author', '--none--'),
|
|
|
261 |
email='',
|
|
|
262 |
date=datetime.utcfromtimestamp(log_entry.date))
|
|
|
263 |
ci_doc = CommitDoc(dict(
|
|
|
264 |
_id=oid,
|
|
|
265 |
tree_id=None,
|
|
|
266 |
committed=user,
|
|
|
267 |
authored=user,
|
|
|
268 |
message=log.entry.message,
|
|
|
269 |
parent_ids=[],
|
|
|
270 |
child_ids=[]))
|
|
|
271 |
if revno > 1:
|
|
|
272 |
ci_doc.parent_ids = [ self._oid(revno-1) ]
|
|
|
273 |
ci_doc.m.insert(safe=True)
|
|
|
274 |
except DuplicateKeyError:
|
|
|
275 |
return False
|
|
|
276 |
|
237 |
def compute_tree(self, commit, tree_path='/'):
|
277 |
def compute_tree(self, commit, tree_path='/'):
|
238 |
tree_path = tree_path[:-1]
|
278 |
tree_path = tree_path[:-1]
|
239 |
tree_id = self._tree_oid(commit.object_id, tree_path)
|
279 |
tree_id = self._tree_oid(commit.object_id, tree_path)
|
240 |
tree, isnew = M.Tree.upsert(tree_id)
|
280 |
tree, isnew = M.Tree.upsert(tree_id)
|
241 |
if not isnew: return tree_id
|
281 |
if not isnew: return tree_id
|