Mercurial > kallithea
annotate rhodecode/lib/vcs/backends/git/changeset.py @ 4106:4e429252f3ee
Don't use -p flag together with -s in git calls. Latest
git version changes behaviour of such call changing the output.
In all the calls where -p -s was used we're only interested in
list of changesets and not the diff.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 02 Sep 2013 16:57:30 +0200 |
parents | a5888ca796b5 |
children |
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 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
5 |
2007
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.conf import settings |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
7 from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyChangeset |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
8 from rhodecode.lib.vcs.exceptions import ( |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
9 RepositoryError, ChangesetError, NodeDoesNotExistError, VCSError, |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
10 ChangesetDoesNotExistError, ImproperArchiveTypeError |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
11 ) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
12 from rhodecode.lib.vcs.nodes import ( |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
13 FileNode, DirNode, NodeKind, RootNode, RemovedFileNode, SubModuleNode, |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
14 ChangedFileNodesGenerator, AddedFileNodesGenerator, RemovedFileNodesGenerator |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
15 ) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
16 from rhodecode.lib.vcs.utils import ( |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
17 safe_unicode, safe_str, safe_int, date_fromtimestamp |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
18 ) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 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
|
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 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 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
|
23 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 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
|
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 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 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
|
28 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
|
29 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
|
30 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 try: |
3805
a5c234e934c5
synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
32 commit = self.repository._repo[revision] |
2543
03a770980b55
Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
2537
diff
changeset
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 self._commit = commit |
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 |
3492
0065f7fe60f6
fix spelling of committer
Mads Kiilerich <madski@unity3d.com>
parents:
3394
diff
changeset
|
43 self._committer_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 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 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
|
50 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
|
51 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 @LazyProperty |
3805
a5c234e934c5
synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
53 def message(self): |
a5c234e934c5
synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
54 return safe_unicode(self._commit.message) |
a5c234e934c5
synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
55 |
a5c234e934c5
synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
56 @LazyProperty |
3492
0065f7fe60f6
fix spelling of committer
Mads Kiilerich <madski@unity3d.com>
parents:
3394
diff
changeset
|
57 def committer(self): |
0065f7fe60f6
fix spelling of committer
Mads Kiilerich <madski@unity3d.com>
parents:
3394
diff
changeset
|
58 return safe_unicode(getattr(self._commit, self._committer_property)) |
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
|
59 |
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 @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
|
61 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
|
62 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
|
63 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 def date(self): |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
66 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
|
67 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
|
68 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 @LazyProperty |
2693
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
70 def _timestamp(self): |
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
71 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
|
72 |
66c778b8cb54
Extended commit search schema with date of commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2543
diff
changeset
|
73 @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
|
74 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
|
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 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
|
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 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
|
79 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 @LazyProperty |
2975
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
81 def tags(self): |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
82 _tags = [] |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
83 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
|
84 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
|
85 _tags.append(tname) |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
86 return _tags |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
87 |
e0da2c0ecee1
fixes #625 Git-Tags are not displayed in Shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2968
diff
changeset
|
88 @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
|
89 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
|
90 |
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
91 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
|
92 |
2198
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
93 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
|
94 if ref: |
9784a54a0f5b
display current heads of branches for git in changelog and shortlog
Marcin Kuzminski <marcin@python-works.com>
parents:
2116
diff
changeset
|
95 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
|
96 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 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
|
98 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 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
|
100 needed. |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
106 def _get_id_for_path(self, path): |
3912
91f440a11b94
fixes issues #849 IMC failed for non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
3805
diff
changeset
|
107 path = safe_str(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
|
108 # 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
|
109 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
|
110 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
|
111 # set root tree |
2536
aaa41736ae51
Fixed lookup by Tag sha in git backend
Marcin Kuzminski <marcin@python-works.com>
parents:
2499
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 curdir = '' |
2116
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
119 |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
120 # 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
|
121 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
|
122 if curdir: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
123 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
|
124 else: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
125 name = item |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
126 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
|
127 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
|
128 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 # 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
|
140 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
|
141 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
|
142 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
|
143 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 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
|
145 |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
146 # 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
|
147 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
|
148 if curdir: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
149 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
|
150 else: |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
151 name = item |
048811568c19
temporarly fixed git _get_id_for_path problem in vcs.
Marcin Kuzminski <marcin@python-works.com>
parents:
2089
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 raise NodeDoesNotExistError("There is no file nor directory " |
3575
ca7785fae354
avoid %r markup of unicode strings in user facing messages
Mads Kiilerich <madski@unity3d.com>
parents:
3561
diff
changeset
|
156 "at the given path '%s' at revision %s" |
3912
91f440a11b94
fixes issues #849 IMC failed for non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
3805
diff
changeset
|
157 % (path, safe_str(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
|
158 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
|
159 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
167 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
|
168 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
|
169 if self._get_kind(path) != NodeKind.FILE: |
3575
ca7785fae354
avoid %r markup of unicode strings in user facing messages
Mads Kiilerich <madski@unity3d.com>
parents:
3561
diff
changeset
|
170 raise ChangesetError("File does not exist for revision %s at " |
ca7785fae354
avoid %r markup of unicode strings in user facing messages
Mads Kiilerich <madski@unity3d.com>
parents:
3561
diff
changeset
|
171 " '%s'" % (self.raw_id, path)) |
3039
a520d542697e
Implemented file history page for showing detailed changelog for a given file
Marcin Kuzminski <marcin@python-works.com>
parents:
3004
diff
changeset
|
172 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
|
173 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 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
|
175 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
|
176 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
178 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
|
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 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
|
181 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
182 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
|
183 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
|
184 |
3077
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
185 @LazyProperty |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
186 def children(self): |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
187 """ |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
188 Returns list of children changesets. |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
189 """ |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
190 rev_filter = _git_path = settings.GIT_REV_FILTER |
3077
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
191 so, se = self.repository.run_git_command( |
3561
c04d1d9b6193
made git refs filter configurable ref issue #797
Marcin Kuzminski <marcin@python-works.com>
parents:
3496
diff
changeset
|
192 "rev-list %s --children | grep '^%s'" % (rev_filter, self.raw_id) |
3077
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
193 ) |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
194 |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
195 children = [] |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
196 for l in so.splitlines(): |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
197 childs = l.split(' ')[1:] |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
198 children.extend(childs) |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
199 return [self.repository.get_changeset(cs) for cs in children] |
6d599a3c0d67
implemented children for git changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
200 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
201 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
|
202 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
203 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
|
204 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
|
205 '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
|
206 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
207 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
|
208 try: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
215 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
|
216 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
|
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 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
|
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 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
|
221 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 '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
|
226 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
227 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
|
228 try: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
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 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
|
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 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
|
239 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
|
240 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
241 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
|
242 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
243 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
|
244 |
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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
252 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
|
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 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
|
255 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
256 # ensure path is traversed |
3912
91f440a11b94
fixes issues #849 IMC failed for non-ascii files
Marcin Kuzminski <marcin@python-works.com>
parents:
3805
diff
changeset
|
257 path = safe_str(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
|
258 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
|
259 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
|
260 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
261 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
|
262 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
263 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
|
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 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
|
266 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
|
267 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
|
268 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
269 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
|
270 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
271 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
|
272 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
273 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
|
274 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
|
275 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
|
276 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
277 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
|
278 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
279 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
|
280 """ |
3496
58905069da21
Speed up of last_changeset extraction in VCS, in edge cases for git we can get 10x speed improvement by limiting the history extraction if we only need last changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
3492
diff
changeset
|
281 return self.get_file_history(path, limit=1)[0] |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
282 |
3496
58905069da21
Speed up of last_changeset extraction in VCS, in edge cases for git we can get 10x speed improvement by limiting the history extraction if we only need last changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
3492
diff
changeset
|
283 def get_file_history(self, path, limit=None): |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
284 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
285 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
|
286 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
|
287 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 """ |
3792
63adb3d5233a
fixed some unicode problems with git file path
Marcin Kuzminski <marcin@python-works.com>
parents:
3575
diff
changeset
|
292 self._get_filectx(path) |
63adb3d5233a
fixed some unicode problems with git file path
Marcin Kuzminski <marcin@python-works.com>
parents:
3575
diff
changeset
|
293 cs_id = safe_str(self.id) |
63adb3d5233a
fixed some unicode problems with git file path
Marcin Kuzminski <marcin@python-works.com>
parents:
3575
diff
changeset
|
294 f_path = safe_str(path) |
3496
58905069da21
Speed up of last_changeset extraction in VCS, in edge cases for git we can get 10x speed improvement by limiting the history extraction if we only need last changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
3492
diff
changeset
|
295 |
58905069da21
Speed up of last_changeset extraction in VCS, in edge cases for git we can get 10x speed improvement by limiting the history extraction if we only need last changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
3492
diff
changeset
|
296 if limit: |
4106
4e429252f3ee
Don't use -p flag together with -s in git calls. Latest
Marcin Kuzminski <marcin@python-works.com>
parents:
4089
diff
changeset
|
297 cmd = 'log -n %s --pretty="format: %%H" -s %s -- "%s"' % ( |
4e429252f3ee
Don't use -p flag together with -s in git calls. Latest
Marcin Kuzminski <marcin@python-works.com>
parents:
4089
diff
changeset
|
298 safe_int(limit, 0), cs_id, f_path) |
3792
63adb3d5233a
fixed some unicode problems with git file path
Marcin Kuzminski <marcin@python-works.com>
parents:
3575
diff
changeset
|
299 |
3496
58905069da21
Speed up of last_changeset extraction in VCS, in edge cases for git we can get 10x speed improvement by limiting the history extraction if we only need last changeset
Marcin Kuzminski <marcin@python-works.com>
parents:
3492
diff
changeset
|
300 else: |
4106
4e429252f3ee
Don't use -p flag together with -s in git calls. Latest
Marcin Kuzminski <marcin@python-works.com>
parents:
4089
diff
changeset
|
301 cmd = 'log --pretty="format: %%H" -s %s -- "%s"' % ( |
4e429252f3ee
Don't use -p flag together with -s in git calls. Latest
Marcin Kuzminski <marcin@python-works.com>
parents:
4089
diff
changeset
|
302 cs_id, f_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
|
303 so, se = self.repository.run_git_command(cmd) |
2276
8caaa9955f5e
better regex for history
Marcin Kuzminski <marcin@python-works.com>
parents:
2274
diff
changeset
|
304 ids = re.findall(r'[0-9a-fA-F]{40}', so) |
4106
4e429252f3ee
Don't use -p flag together with -s in git calls. Latest
Marcin Kuzminski <marcin@python-works.com>
parents:
4089
diff
changeset
|
305 return [self.repository.get_changeset(sha) for sha in ids] |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
306 |
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
|
307 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
|
308 """ |
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
|
309 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
|
310 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
|
311 |
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
|
312 """ |
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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 paths=[path], max_entries=1) |
3057
79c5967a1e5c
whitespace and formatting
Marcin Kuzminski <marcin@python-works.com>
parents:
3044
diff
changeset
|
318 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
|
319 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
|
320 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
321 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
|
322 """ |
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
|
323 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
|
324 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
|
325 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
326 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
|
327 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
|
328 commits. |
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 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
|
331 # -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
|
332 # --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
|
333 # -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
|
334 so, se = self.repository.run_git_command(cmd) |
2448
c9b08fdcb788
fixed git annotate
Marcin Kuzminski <marcin@python-works.com>
parents:
2384
diff
changeset
|
335 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
336 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
|
337 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
|
338 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
|
339 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
|
340 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
341 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
|
342 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
|
343 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
344 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
|
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 :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
|
347 :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
|
348 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
|
349 :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
|
350 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
|
351 (``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
|
352 :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
|
353 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
354 :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
|
355 :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
|
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 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
358 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
|
359 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
|
360 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
|
361 '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
|
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 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
|
364 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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
370 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
|
371 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
|
372 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
373 frmt = 'tar' |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
374 _git_path = settings.GIT_EXECUTABLE_PATH |
3394
fe2bb88bf7ac
whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
3376
diff
changeset
|
375 cmd = '%s archive --format=%s --prefix=%s/ %s' % (_git_path, |
3376
e67b2ef07a8e
git executable is now configurable via .ini files
Marcin Kuzminski <marcin@python-works.com>
parents:
3077
diff
changeset
|
376 frmt, prefix, 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
382 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
|
383 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
|
384 ' 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
|
385 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
|
386 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
|
387 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 # 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
|
394 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
|
395 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
396 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
|
397 if self._get_kind(path) != NodeKind.DIR: |
3575
ca7785fae354
avoid %r markup of unicode strings in user facing messages
Mads Kiilerich <madski@unity3d.com>
parents:
3561
diff
changeset
|
398 raise ChangesetError("Directory does not exist for revision %s at " |
ca7785fae354
avoid %r markup of unicode strings in user facing messages
Mads Kiilerich <madski@unity3d.com>
parents:
3561
diff
changeset
|
399 " '%s'" % (self.revision, 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
|
400 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
|
401 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
|
402 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
|
403 dirnodes = [] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
404 filenodes = [] |
2232
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
405 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
|
406 for name, stat, id in tree.iteritems(): |
2232
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
407 if objects.S_ISGITLINK(stat): |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
408 dirnodes.append(SubModuleNode(name, url=None, changeset=id, |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
409 alias=als)) |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
410 continue |
49dc09e9f076
Implements subrepos view inside filebrowser
Marcin Kuzminski <marcin@python-works.com>
parents:
2199
diff
changeset
|
411 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
412 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
|
413 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
|
414 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
|
415 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 else: |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
424 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
|
425 "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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
433 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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 try: |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 "directories for a given path: %s" % path) |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
443 |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
444 _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
|
445 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
|
446 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
|
447 alias=self.repository.alias) |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
448 else: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
449 obj = self.repository._repo.get_object(id_) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
450 |
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
|
451 if isinstance(obj, objects.Tree): |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
452 if path == '': |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
453 node = RootNode(changeset=self) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
454 else: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
455 node = DirNode(path, changeset=self) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
456 node._tree = obj |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
457 elif isinstance(obj, objects.Blob): |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
458 node = FileNode(path, changeset=self) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
459 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
|
460 else: |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
461 raise NodeDoesNotExistError("There is no file nor directory " |
3575
ca7785fae354
avoid %r markup of unicode strings in user facing messages
Mads Kiilerich <madski@unity3d.com>
parents:
3561
diff
changeset
|
462 "at the given path '%s' at revision %s" |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2232
diff
changeset
|
463 % (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
|
464 # 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
|
465 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
|
466 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
|
467 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
468 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
469 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
|
470 """ |
4089
a5888ca796b5
Fixed spelling of get's to gets
Marcin Kuzminski <marcin@python-works.com>
parents:
3912
diff
changeset
|
471 Gets a fast accessible file changes for given changeset |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
472 """ |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
473 added, modified, deleted = self._changes_cache |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
474 return list(added.union(modified).union(deleted)) |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
475 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
476 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
477 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
|
478 output = [] |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
479 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
|
480 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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
486 @LazyProperty |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
487 def _changes_cache(self): |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
488 added = set() |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
489 modified = set() |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
490 deleted = set() |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
491 _r = self.repository._repo |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
492 |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
493 parents = self.parents |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
494 if not self.parents: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
495 parents = [EmptyChangeset()] |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
496 for parent in parents: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
497 if isinstance(parent, EmptyChangeset): |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
498 oid = None |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
499 else: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
500 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
|
501 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
|
502 for (oldpath, newpath), (_, _), (_, _) in changes: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
503 if newpath and oldpath: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
504 modified.add(newpath) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
505 elif newpath and not oldpath: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
506 added.add(newpath) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
507 elif not newpath and oldpath: |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
508 deleted.add(oldpath) |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
509 return added, modified, deleted |
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
510 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
511 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
|
512 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
513 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
|
514 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
515 :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
|
516 """ |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
517 added, modified, deleted = self._changes_cache |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
518 return sorted({ |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
519 'added': list(added), |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
520 'modified': list(modified), |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3792
diff
changeset
|
521 'deleted': list(deleted)}[status] |
2762
ba4fb9c441c6
new dulwich based implementation of added/modified/removed
Marcin Kuzminski <marcin@python-works.com>
parents:
2761
diff
changeset
|
522 ) |
2007
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 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
525 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
|
526 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
527 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
|
528 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 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
|
533 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
534 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
535 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
|
536 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
537 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
|
538 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
539 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
|
540 return [] |
2968
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
541 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
|
542 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
|
543 |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
544 @LazyProperty |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
545 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
|
546 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
547 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
|
548 """ |
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
549 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
|
550 return [] |
2968
4abfb1afd9f5
fixes #630 git statistics do too much work making them slow.
Marcin Kuzminski <marcin@python-works.com>
parents:
2762
diff
changeset
|
551 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
|
552 self._get_paths_for_status('deleted')], self) |