Mercurial > kallithea
annotate rhodecode/lib/vcs/backends/git/changeset.py @ 3057:79c5967a1e5c beta
whitespace and formatting
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 03 Dec 2012 02:56:57 +0100 |
parents | c57a37430dc9 |
children | 6d599a3c0d67 |
rev | line source |
---|---|
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 import re |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 from itertools import chain |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 from dulwich import objects |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from subprocess import Popen, PIPE |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 from rhodecode.lib.vcs.conf import settings |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 from rhodecode.lib.vcs.exceptions import RepositoryError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 from rhodecode.lib.vcs.exceptions import ChangesetError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 from rhodecode.lib.vcs.exceptions import VCSError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 from rhodecode.lib.vcs.exceptions import ImproperArchiveTypeError |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
12 from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyChangeset |
2232
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
13 from rhodecode.lib.vcs.nodes import FileNode, DirNode, NodeKind, RootNode, \ |
2968
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
14 RemovedFileNode, SubModuleNode, ChangedFileNodesGenerator,\ |
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
15 AddedFileNodesGenerator, RemovedFileNodesGenerator |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 from rhodecode.lib.vcs.utils import safe_unicode |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 from rhodecode.lib.vcs.utils import date_fromtimestamp |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 from rhodecode.lib.vcs.utils.lazy import LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 class GitChangeset(BaseChangeset): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 Represents state of the repository at single revision. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 def __init__(self, repository, revision): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 self._stat_modes = {} |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 self.repository = repository |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
29 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 try: |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
31 commit = self.repository._repo.get_object(revision) |
2543
03a770980b55
Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2537
diff
changeset
|
32 if isinstance(commit, objects.Tag): |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
33 revision = commit.object[1] |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
34 commit = self.repository._repo.get_object(commit.object[1]) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 except KeyError: |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
36 raise RepositoryError("Cannot get object with id %s" % revision) |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
37 self.raw_id = revision |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
38 self.id = self.raw_id |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
39 self.short_id = self.raw_id[:12] |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 self._commit = commit |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
41 |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
42 self._tree_id = commit.tree |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
43 self._commiter_property = 'committer' |
3004
3bfd5852c218
implements #649 added two seperate method for author and commiter to VCS changeset class
Marcin Kuzminski <marcin@python-works.com>
parents:
2975
diff
changeset
|
44 self._author_property = 'author' |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
45 self._date_property = 'commit_time' |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
46 self._date_tz_property = 'commit_timezone' |
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
47 self.revision = repository.revisions.index(revision) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 |
2297
4747af4ce203
safe_unicode never fails. No need to catch decode exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
2281
diff
changeset
|
49 self.message = safe_unicode(commit.message) |
2975
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
50 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 self.nodes = {} |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 self._paths = {} |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 @LazyProperty |
3004
3bfd5852c218
implements #649 added two seperate method for author and commiter to VCS changeset class
Marcin Kuzminski <marcin@python-works.com>
parents:
2975
diff
changeset
|
55 def commiter(self): |
3bfd5852c218
implements #649 added two seperate method for author and commiter to VCS changeset class
Marcin Kuzminski <marcin@python-works.com>
parents:
2975
diff
changeset
|
56 return safe_unicode(getattr(self._commit, self._commiter_property)) |
3bfd5852c218
implements #649 added two seperate method for author and commiter to VCS changeset class
Marcin Kuzminski <marcin@python-works.com>
parents:
2975
diff
changeset
|
57 |
3bfd5852c218
implements #649 added two seperate method for author and commiter to VCS changeset class
Marcin Kuzminski <marcin@python-works.com>
parents:
2975
diff
changeset
|
58 @LazyProperty |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 def author(self): |
3004
3bfd5852c218
implements #649 added two seperate method for author and commiter to VCS changeset class
Marcin Kuzminski <marcin@python-works.com>
parents:
2975
diff
changeset
|
60 return safe_unicode(getattr(self._commit, self._author_property)) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 def date(self): |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
64 return date_fromtimestamp(getattr(self._commit, self._date_property), |
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
65 getattr(self._commit, self._date_tz_property)) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 @LazyProperty |
2693
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
68 def _timestamp(self): |
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
69 return getattr(self._commit, self._date_property) |
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
70 |
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
71 @LazyProperty |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 def status(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 Returns modified, added, removed, deleted files for current changeset |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 return self.changed, self.added, self.removed |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 @LazyProperty |
2975
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
79 def tags(self): |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
80 _tags = [] |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
81 for tname, tsha in self.repository.tags.iteritems(): |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
82 if tsha == self.raw_id: |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
83 _tags.append(tname) |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
84 return _tags |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
85 |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
86 @LazyProperty |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 def branch(self): |
2198
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
88 |
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
89 heads = self.repository._heads(reverse=False) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 |
2198
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
91 ref = heads.get(self.raw_id) |
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
92 if ref: |
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
93 return safe_unicode(ref) |
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
94 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 def _fix_path(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
96 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 Paths are stored without trailing slash so we need to get rid off it if |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 needed. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 if path.endswith('/'): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 path = path.rstrip('/') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 return path |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 def _get_id_for_path(self, path): |
2116
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
105 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
106 # FIXME: Please, spare a couple of minutes and make those codes cleaner; |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 if not path in self._paths: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
108 path = path.strip('/') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 # set root tree |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
110 tree = self.repository._repo[self._tree_id] |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 if path == '': |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 self._paths[''] = tree.id |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 return tree.id |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 splitted = path.split('/') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
115 dirs, name = splitted[:-1], splitted[-1] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 curdir = '' |
2116
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
117 |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
118 # initially extract things from root dir |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
119 for item, stat, id in tree.iteritems(): |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
120 if curdir: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
121 name = '/'.join((curdir, item)) |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
122 else: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
123 name = item |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
124 self._paths[name] = id |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
125 self._stat_modes[name] = stat |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
126 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
127 for dir in dirs: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 if curdir: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 curdir = '/'.join((curdir, dir)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 curdir = dir |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
132 dir_id = None |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 for item, stat, id in tree.iteritems(): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
134 if dir == item: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 dir_id = id |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 if dir_id: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 # Update tree |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 tree = self.repository._repo[dir_id] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 if not isinstance(tree, objects.Tree): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 raise ChangesetError('%s is not a directory' % curdir) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
142 raise ChangesetError('%s have not been found' % curdir) |
2116
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
143 |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
144 # cache all items from the given traversed tree |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
145 for item, stat, id in tree.iteritems(): |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
146 if curdir: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
147 name = '/'.join((curdir, item)) |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
148 else: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
149 name = item |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
150 self._paths[name] = id |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
151 self._stat_modes[name] = stat |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
152 if not path in self._paths: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
153 raise NodeDoesNotExistError("There is no file nor directory " |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
154 "at the given path %r at revision %r" |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
155 % (path, self.short_id)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
156 return self._paths[path] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
157 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
158 def _get_kind(self, path): |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
159 obj = self.repository._repo[self._get_id_for_path(path)] |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 if isinstance(obj, objects.Blob): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
161 return NodeKind.FILE |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
162 elif isinstance(obj, objects.Tree): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
163 return NodeKind.DIR |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
164 |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
165 def _get_filectx(self, path): |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
166 path = self._fix_path(path) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
167 if self._get_kind(path) != NodeKind.FILE: |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
168 raise ChangesetError("File does not exist for revision %r at " |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
169 " %r" % (self.raw_id, path)) |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
170 return path |
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
171 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
172 def _get_file_nodes(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
173 return chain(*(t[2] for t in self.walk())) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
175 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
176 def parents(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
178 Returns list of parents changesets. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
179 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
180 return [self.repository.get_changeset(parent) |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
181 for parent in self._commit.parents] |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
182 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
183 def next(self, branch=None): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
184 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
185 if branch and self.branch != branch: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
186 raise VCSError('Branch option used on changeset not belonging ' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
187 'to that branch') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
188 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
189 def _next(changeset, branch): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
190 try: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
191 next_ = changeset.revision + 1 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
192 next_rev = changeset.repository.revisions[next_] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
193 except IndexError: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
194 raise ChangesetDoesNotExistError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
195 cs = changeset.repository.get_changeset(next_rev) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
196 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
197 if branch and branch != cs.branch: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
198 return _next(cs, branch) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
199 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
200 return cs |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
201 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
202 return _next(self, branch) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
203 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
204 def prev(self, branch=None): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
205 if branch and self.branch != branch: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
206 raise VCSError('Branch option used on changeset not belonging ' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
207 'to that branch') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
208 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
209 def _prev(changeset, branch): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
210 try: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
211 prev_ = changeset.revision - 1 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
212 if prev_ < 0: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
213 raise IndexError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
214 prev_rev = changeset.repository.revisions[prev_] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
215 except IndexError: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
216 raise ChangesetDoesNotExistError |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
217 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
218 cs = changeset.repository.get_changeset(prev_rev) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
219 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
220 if branch and branch != cs.branch: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
221 return _prev(cs, branch) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
222 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
223 return cs |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
224 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
225 return _prev(self, branch) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
226 |
2384
5563af834d92
Added diff option into git and hg changeset objects, representing git formated patch against parent1
Marcin Kuzminski <marcin@python-works.com>
parents:
2297
diff
changeset
|
227 def diff(self, ignore_whitespace=True, context=3): |
2499
c919d8c4f6a2
fixed git diff function when initial revision had no parents to compare with
Marcin Kuzminski <marcin@python-works.com>
parents:
2462
diff
changeset
|
228 rev1 = self.parents[0] if self.parents else self.repository.EMPTY_CHANGESET |
c919d8c4f6a2
fixed git diff function when initial revision had no parents to compare with
Marcin Kuzminski <marcin@python-works.com>
parents:
2462
diff
changeset
|
229 rev2 = self |
c919d8c4f6a2
fixed git diff function when initial revision had no parents to compare with
Marcin Kuzminski <marcin@python-works.com>
parents:
2462
diff
changeset
|
230 return ''.join(self.repository.get_diff(rev1, rev2, |
2384
5563af834d92
Added diff option into git and hg changeset objects, representing git formated patch against parent1
Marcin Kuzminski <marcin@python-works.com>
parents:
2297
diff
changeset
|
231 ignore_whitespace=ignore_whitespace, |
5563af834d92
Added diff option into git and hg changeset objects, representing git formated patch against parent1
Marcin Kuzminski <marcin@python-works.com>
parents:
2297
diff
changeset
|
232 context=context)) |
5563af834d92
Added diff option into git and hg changeset objects, representing git formated patch against parent1
Marcin Kuzminski <marcin@python-works.com>
parents:
2297
diff
changeset
|
233 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
234 def get_file_mode(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
235 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
236 Returns stat mode of the file at the given ``path``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
237 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
238 # ensure path is traversed |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
239 self._get_id_for_path(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
240 return self._stat_modes[path] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
241 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
242 def get_file_content(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
243 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
244 Returns content of the file at given ``path``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
245 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
246 id = self._get_id_for_path(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
247 blob = self.repository._repo[id] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
248 return blob.as_pretty_string() |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
249 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
250 def get_file_size(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
251 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
252 Returns size of the file at given ``path``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
253 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
254 id = self._get_id_for_path(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
255 blob = self.repository._repo[id] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
256 return blob.raw_length() |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
257 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
258 def get_file_changeset(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
259 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
260 Returns last commit of the file at the given ``path``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
261 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
262 node = self.get_node(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
263 return node.history[0] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
264 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
265 def get_file_history(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
266 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
267 Returns history of file as reversed list of ``Changeset`` objects for |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
268 which file at given ``path`` has been modified. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
269 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
270 TODO: This function now uses os underlying 'git' and 'grep' commands |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
271 which is generally not good. Should be replaced with algorithm |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
272 iterating commits. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
273 """ |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
274 self._get_filectx(path) |
3044
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
275 |
2276
8caaa9955f5e
better regex for history
Marcin Kuzminski <marcin@python-works.com>
parents:
2274
diff
changeset
|
276 cmd = 'log --pretty="format: %%H" -s -p %s -- "%s"' % ( |
2089
a9f2aa1e15e6
bring back cs id for node history in git as it improves performance. Adding format prevents from crashes of modified gitconfigs
Marcin Kuzminski <marcin@python-works.com>
parents:
2047
diff
changeset
|
277 self.id, path |
2047 | 278 ) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
279 so, se = self.repository.run_git_command(cmd) |
2276
8caaa9955f5e
better regex for history
Marcin Kuzminski <marcin@python-works.com>
parents:
2274
diff
changeset
|
280 ids = re.findall(r'[0-9a-fA-F]{40}', so) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
281 return [self.repository.get_changeset(id) for id in ids] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
282 |
3044
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
283 def get_file_history_2(self, path): |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
284 """ |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
285 Returns history of file as reversed list of ``Changeset`` objects for |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
286 which file at given ``path`` has been modified. |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
287 |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
288 """ |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
289 self._get_filectx(path) |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
290 from dulwich.walk import Walker |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
291 include = [self.id] |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
292 walker = Walker(self.repository._repo.object_store, include, |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
293 paths=[path], max_entries=1) |
3057
79c5967a1e5c
whitespace and formatting
Marcin Kuzminski <marcin@python-works.com>
parents:
3044
diff
changeset
|
294 return [self.repository.get_changeset(sha) |
3044
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
295 for sha in (x.commit.id for x in walker)] |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
296 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
297 def get_file_annotate(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
298 """ |
3044
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
299 Returns a generator of four element tuples with |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
300 lineno, sha, changeset lazy loader and line |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
301 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
302 TODO: This function now uses os underlying 'git' command which is |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
303 generally not good. Should be replaced with algorithm iterating |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
304 commits. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
305 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
306 cmd = 'blame -l --root -r %s -- "%s"' % (self.id, path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
307 # -l ==> outputs long shas (and we need all 40 characters) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
308 # --root ==> doesn't put '^' character for bounderies |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
309 # -r sha ==> blames for the given revision |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
310 so, se = self.repository.run_git_command(cmd) |
2448
c9b08fdcb788
fixed git annotate
Marcin Kuzminski <marcin@python-works.com>
parents:
2384
diff
changeset
|
311 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
312 for i, blame_line in enumerate(so.split('\n')[:-1]): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
313 ln_no = i + 1 |
3044
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
314 sha, line = re.split(r' ', blame_line, 1) |
c57a37430dc9
fixes #652 switch to generator approach when doing file annotation to prevent huge memory consumption when executed on large files. Thanks to ALexey Larikov for patch.
Marcin Kuzminski <marcin@python-works.com>
parents:
3039
diff
changeset
|
315 yield (ln_no, sha, lambda: self.repository.get_changeset(sha), line) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
316 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
317 def fill_archive(self, stream=None, kind='tgz', prefix=None, |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
318 subrepos=False): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
319 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
320 Fills up given stream. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
321 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
322 :param stream: file like object. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
323 :param kind: one of following: ``zip``, ``tgz`` or ``tbz2``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
324 Default: ``tgz``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
325 :param prefix: name of root directory in archive. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
326 Default is repository name and changeset's raw_id joined with dash |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
327 (``repo-tip.<KIND>``). |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
328 :param subrepos: include subrepos in this archive. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
329 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
330 :raise ImproperArchiveTypeError: If given kind is wrong. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
331 :raise VcsError: If given stream is None |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
332 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
333 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
334 allowed_kinds = settings.ARCHIVE_SPECS.keys() |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
335 if kind not in allowed_kinds: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
336 raise ImproperArchiveTypeError('Archive kind not supported use one' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
337 'of %s', allowed_kinds) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
338 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
339 if prefix is None: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
340 prefix = '%s-%s' % (self.repository.name, self.short_id) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
341 elif prefix.startswith('/'): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
342 raise VCSError("Prefix cannot start with leading slash") |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
343 elif prefix.strip() == '': |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
344 raise VCSError("Prefix cannot be empty") |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
345 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
346 if kind == 'zip': |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
347 frmt = 'zip' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
348 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
349 frmt = 'tar' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
350 cmd = 'git archive --format=%s --prefix=%s/ %s' % (frmt, prefix, |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
351 self.raw_id) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
352 if kind == 'tgz': |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
353 cmd += ' | gzip -9' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
354 elif kind == 'tbz2': |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
355 cmd += ' | bzip2 -9' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
356 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
357 if stream is None: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
358 raise VCSError('You need to pass in a valid stream for filling' |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
359 ' with archival data') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
360 popen = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True, |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
361 cwd=self.repository.path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
362 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
363 buffer_size = 1024 * 8 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
364 chunk = popen.stdout.read(buffer_size) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
365 while chunk: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
366 stream.write(chunk) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
367 chunk = popen.stdout.read(buffer_size) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
368 # Make sure all descriptors would be read |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
369 popen.communicate() |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
370 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
371 def get_nodes(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
372 if self._get_kind(path) != NodeKind.DIR: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
373 raise ChangesetError("Directory does not exist for revision %r at " |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
374 " %r" % (self.revision, path)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
375 path = self._fix_path(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
376 id = self._get_id_for_path(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
377 tree = self.repository._repo[id] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
378 dirnodes = [] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
379 filenodes = [] |
2232
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
380 als = self.repository.alias |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
381 for name, stat, id in tree.iteritems(): |
2232
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
382 if objects.S_ISGITLINK(stat): |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
383 dirnodes.append(SubModuleNode(name, url=None, changeset=id, |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
384 alias=als)) |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
385 continue |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
386 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
387 obj = self.repository._repo.get_object(id) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
388 if path != '': |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
389 obj_path = '/'.join((path, name)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
390 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
391 obj_path = name |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
392 if obj_path not in self._stat_modes: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
393 self._stat_modes[obj_path] = stat |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
394 if isinstance(obj, objects.Tree): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
395 dirnodes.append(DirNode(obj_path, changeset=self)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
396 elif isinstance(obj, objects.Blob): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
397 filenodes.append(FileNode(obj_path, changeset=self, mode=stat)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
398 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
399 raise ChangesetError("Requested object should be Tree " |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
400 "or Blob, is %r" % type(obj)) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
401 nodes = dirnodes + filenodes |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
402 for node in nodes: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
403 if not node.path in self.nodes: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
404 self.nodes[node.path] = node |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
405 nodes.sort() |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
406 return nodes |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
407 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
408 def get_node(self, path): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
409 if isinstance(path, unicode): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
410 path = path.encode('utf-8') |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
411 path = self._fix_path(path) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
412 if not path in self.nodes: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
413 try: |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
414 id_ = self._get_id_for_path(path) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
415 except ChangesetError: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
416 raise NodeDoesNotExistError("Cannot find one of parents' " |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
417 "directories for a given path: %s" % path) |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
418 |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
419 _GL = lambda m: m and objects.S_ISGITLINK(m) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
420 if _GL(self._stat_modes.get(path)): |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
421 node = SubModuleNode(path, url=None, changeset=id_, |
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
422 alias=self.repository.alias) |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
423 else: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
424 obj = self.repository._repo.get_object(id_) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
425 |
2537
952dd2c95e45
When using tags in git use the link to Commit instead of messing with Tag object
Marcin Kuzminski <marcin@python-works.com>
parents:
2536
diff
changeset
|
426 if isinstance(obj, objects.Tree): |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
427 if path == '': |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
428 node = RootNode(changeset=self) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
429 else: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
430 node = DirNode(path, changeset=self) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
431 node._tree = obj |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
432 elif isinstance(obj, objects.Blob): |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
433 node = FileNode(path, changeset=self) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
434 node._blob = obj |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
435 else: |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
436 raise NodeDoesNotExistError("There is no file nor directory " |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
437 "at the given path %r at revision %r" |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
438 % (path, self.short_id)) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
439 # cache node |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
440 self.nodes[path] = node |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
441 return self.nodes[path] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
442 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
443 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
444 def affected_files(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
445 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
446 Get's a fast accessible file changes for given changeset |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
447 """ |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
448 a, m, d = self._changes_cache |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
449 return list(a.union(m).union(d)) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
450 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
451 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
452 def _diff_name_status(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
453 output = [] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
454 for parent in self.parents: |
2761
e64c64e2b8aa
re implemented affected_files function for git using dulwich
Marcin Kuzminski <marcin@python-works.com>
parents:
2693
diff
changeset
|
455 cmd = 'diff --name-status %s %s --encoding=utf8' % (parent.raw_id, |
e64c64e2b8aa
re implemented affected_files function for git using dulwich
Marcin Kuzminski <marcin@python-works.com>
parents:
2693
diff
changeset
|
456 self.raw_id) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
457 so, se = self.repository.run_git_command(cmd) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
458 output.append(so.strip()) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
459 return '\n'.join(output) |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
460 |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
461 @LazyProperty |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
462 def _changes_cache(self): |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
463 added = set() |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
464 modified = set() |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
465 deleted = set() |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
466 _r = self.repository._repo |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
467 |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
468 parents = self.parents |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
469 if not self.parents: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
470 parents = [EmptyChangeset()] |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
471 for parent in parents: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
472 if isinstance(parent, EmptyChangeset): |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
473 oid = None |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
474 else: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
475 oid = _r[parent.raw_id].tree |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
476 changes = _r.object_store.tree_changes(oid, _r[self.raw_id].tree) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
477 for (oldpath, newpath), (_, _), (_, _) in changes: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
478 if newpath and oldpath: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
479 modified.add(newpath) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
480 elif newpath and not oldpath: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
481 added.add(newpath) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
482 elif not newpath and oldpath: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
483 deleted.add(oldpath) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
484 return added, modified, deleted |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
485 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
486 def _get_paths_for_status(self, status): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
487 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
488 Returns sorted list of paths for given ``status``. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
489 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
490 :param status: one of: *added*, *modified* or *deleted* |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
491 """ |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
492 a, m, d = self._changes_cache |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
493 return sorted({ |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
494 'added': list(a), |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
495 'modified': list(m), |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
496 'deleted': list(d)}[status] |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
497 ) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
498 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
499 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
500 def added(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
501 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
502 Returns list of added ``FileNode`` objects. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
503 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
504 if not self.parents: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
505 return list(self._get_file_nodes()) |
2968
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
506 return AddedFileNodesGenerator([n for n in |
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
507 self._get_paths_for_status('added')], self) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
508 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
509 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
510 def changed(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
511 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
512 Returns list of modified ``FileNode`` objects. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
513 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
514 if not self.parents: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
515 return [] |
2968
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
516 return ChangedFileNodesGenerator([n for n in |
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
517 self._get_paths_for_status('modified')], self) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
518 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
519 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
520 def removed(self): |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
521 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
522 Returns list of removed ``FileNode`` objects. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
523 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
524 if not self.parents: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
525 return [] |
2968
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
526 return RemovedFileNodesGenerator([n for n in |
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
527 self._get_paths_for_status('deleted')], self) |