##// END OF EJS Templates
Fixed lookup by Tag sha in git backend
marcink -
r2536:aaa41736 beta
parent child Browse files
Show More
@@ -32,7 +32,6 from pylons import request, response, tm
32 32 from pylons.i18n.translation import _
33 33 from pylons.controllers.util import redirect
34 34 from pylons.decorators import jsonify
35 from paste.fileapp import FileApp, _FileIter
36 35
37 36 from rhodecode.lib import diffs
38 37 from rhodecode.lib import helpers as h
@@ -61,7 +60,6 log = logging.getLogger(__name__)
61 60
62 61 class FilesController(BaseRepoController):
63 62
64
65 63 def __before__(self):
66 64 super(FilesController, self).__before__()
67 65 c.cut_off_limit = self.cut_off_limit
@@ -166,7 +164,7 class FilesController(BaseRepoController
166 164 except RepositoryError, e:
167 165 h.flash(str(e), category='warning')
168 166 redirect(h.url('files_home', repo_name=repo_name,
169 revision=revision))
167 revision='tip'))
170 168
171 169 return render('files/files.html')
172 170
@@ -15,6 +15,7 from rhodecode.lib.vcs.nodes import File
15 15 from rhodecode.lib.vcs.utils import safe_unicode
16 16 from rhodecode.lib.vcs.utils import date_fromtimestamp
17 17 from rhodecode.lib.vcs.utils.lazy import LazyProperty
18 from dulwich.objects import Commit, Tag
18 19
19 20
20 21 class GitChangeset(BaseChangeset):
@@ -26,8 +27,6 class GitChangeset(BaseChangeset):
26 27 self._stat_modes = {}
27 28 self.repository = repository
28 29 self.raw_id = revision
29 self.revision = repository.revisions.index(revision)
30
31 30 self.short_id = self.raw_id[:12]
32 31 self.id = self.raw_id
33 32 try:
@@ -35,7 +34,19 class GitChangeset(BaseChangeset):
35 34 except KeyError:
36 35 raise RepositoryError("Cannot get object with id %s" % self.raw_id)
37 36 self._commit = commit
37
38 if isinstance(commit, Commit):
38 39 self._tree_id = commit.tree
40 self._commiter_property = 'committer'
41 self._date_property = 'commit_time'
42 self._date_tz_property = 'commit_timezone'
43 self.revision = repository.revisions.index(revision)
44 elif isinstance(commit, Tag):
45 self._commiter_property = 'tagger'
46 self._tree_id = commit.id
47 self._date_property = 'tag_time'
48 self._date_tz_property = 'tag_timezone'
49 self.revision = 'tag'
39 50
40 51 self.message = safe_unicode(commit.message)
41 52 #self.branch = None
@@ -45,12 +56,12 class GitChangeset(BaseChangeset):
45 56
46 57 @LazyProperty
47 58 def author(self):
48 return safe_unicode(self._commit.committer)
59 return safe_unicode(getattr(self._commit, self._commiter_property))
49 60
50 61 @LazyProperty
51 62 def date(self):
52 return date_fromtimestamp(self._commit.commit_time,
53 self._commit.commit_timezone)
63 return date_fromtimestamp(getattr(self._commit, self._date_property),
64 getattr(self._commit, self._date_tz_property))
54 65
55 66 @LazyProperty
56 67 def status(self):
@@ -83,7 +94,7 class GitChangeset(BaseChangeset):
83 94 if not path in self._paths:
84 95 path = path.strip('/')
85 96 # set root tree
86 tree = self.repository._repo[self._commit.tree]
97 tree = self.repository._repo[self._tree_id]
87 98 if path == '':
88 99 self._paths[''] = tree.id
89 100 return tree.id
@@ -132,8 +143,7 class GitChangeset(BaseChangeset):
132 143 return self._paths[path]
133 144
134 145 def _get_kind(self, path):
135 id = self._get_id_for_path(path)
136 obj = self.repository._repo[id]
146 obj = self.repository._repo[self._get_id_for_path(path)]
137 147 if isinstance(obj, objects.Blob):
138 148 return NodeKind.FILE
139 149 elif isinstance(obj, objects.Tree):
@@ -371,14 +381,14 class GitChangeset(BaseChangeset):
371 381 raise NodeDoesNotExistError("Cannot find one of parents' "
372 382 "directories for a given path: %s" % path)
373 383
374 als = self.repository.alias
375 384 _GL = lambda m: m and objects.S_ISGITLINK(m)
376 385 if _GL(self._stat_modes.get(path)):
377 node = SubModuleNode(path, url=None, changeset=id_, alias=als)
386 node = SubModuleNode(path, url=None, changeset=id_,
387 alias=self.repository.alias)
378 388 else:
379 389 obj = self.repository._repo.get_object(id_)
380 390
381 if isinstance(obj, objects.Tree):
391 if isinstance(obj, (objects.Tree, objects.Tag)):
382 392 if path == '':
383 393 node = RootNode(changeset=self)
384 394 else:
@@ -196,10 +196,16 class GitRepository(BaseRepository):
196 196 "for this repository %s" % (revision, self))
197 197
198 198 elif is_bstr(revision):
199 # get by branch/tag name
199 200 _ref_revision = self._parsed_refs.get(revision)
201 _tags_shas = self.tags.values()
200 202 if _ref_revision: # and _ref_revision[1] in ['H', 'RH', 'T']:
201 203 return _ref_revision[0]
202 204
205 # maybe it's a tag ? we don't have them in self.revisions
206 elif revision in _tags_shas:
207 return _tags_shas[_tags_shas.index(revision)]
208
203 209 elif not pattern.match(revision) or revision not in self.revisions:
204 210 raise ChangesetDoesNotExistError("Revision %r does not exist "
205 211 "for this repository %s" % (revision, self))
General Comments 0
You need to be logged in to leave comments. Login now