Mercurial > kallithea
comparison rhodecode/lib/vcs/backends/hg/changeset.py @ 3496:58905069da21 beta
Speed up of last_changeset extraction in VCS, in edge cases for git we can get 10x speed improvement by limiting the history extraction if we only need last changeset
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 07 Mar 2013 13:46:24 +0100 |
parents | 0065f7fe60f6 |
children | ca7785fae354 |
comparison
equal
deleted
inserted
replaced
3493:64371c42e2f1 | 3496:58905069da21 |
---|---|
217 | 217 |
218 def get_file_changeset(self, path): | 218 def get_file_changeset(self, path): |
219 """ | 219 """ |
220 Returns last commit of the file at the given ``path``. | 220 Returns last commit of the file at the given ``path``. |
221 """ | 221 """ |
222 node = self.get_node(path) | 222 return self.get_file_history(path, limit=1)[0] |
223 return node.history[0] | 223 |
224 | 224 def get_file_history(self, path, limit=None): |
225 def get_file_history(self, path): | |
226 """ | 225 """ |
227 Returns history of file as reversed list of ``Changeset`` objects for | 226 Returns history of file as reversed list of ``Changeset`` objects for |
228 which file at given ``path`` has been modified. | 227 which file at given ``path`` has been modified. |
229 """ | 228 """ |
230 fctx = self._get_filectx(path) | 229 fctx = self._get_filectx(path) |
231 nodes = [fctx.filectx(x).node() for x in fctx.filelog()] | 230 hist = [] |
232 changesets = [self.repository.get_changeset(hex(node)) | 231 cnt = 0 |
233 for node in reversed(nodes)] | 232 for cs in reversed([x for x in fctx.filelog()]): |
234 return changesets | 233 cnt += 1 |
234 hist.append(hex(fctx.filectx(cs).node())) | |
235 if limit and cnt == limit: | |
236 break | |
237 | |
238 return [self.repository.get_changeset(node) for node in hist] | |
235 | 239 |
236 def get_file_annotate(self, path): | 240 def get_file_annotate(self, path): |
237 """ | 241 """ |
238 Returns a generator of four element tuples with | 242 Returns a generator of four element tuples with |
239 lineno, sha, changeset lazy loader and line | 243 lineno, sha, changeset lazy loader and line |