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