annotate rhodecode/lib/vcs/backends/hg/repository.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents a5888ca796b5
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
1 # -*- coding: utf-8 -*-
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
2 """
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
3 vcs.backends.hg.repository
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
5
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
6 Mercurial repository implementation.
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
7
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
8 :created_on: Apr 8, 2010
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
10 """
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
11
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 import os
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 import time
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 import urllib
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 import urllib2
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
16 import logging
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
17 import datetime
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
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
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
20 from rhodecode.lib.vcs.backends.base import BaseRepository, CollectionGenerator
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
21 from rhodecode.lib.vcs.conf import settings
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
23 from rhodecode.lib.vcs.exceptions import (
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
24 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError,
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
25 RepositoryError, VCSError, TagAlreadyExistError, TagDoesNotExistError
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
26 )
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
27 from rhodecode.lib.vcs.utils import (
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
28 author_email, author_name, date_fromtimestamp, makedate, safe_unicode
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
29 )
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 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
31 from rhodecode.lib.vcs.utils.ordered_dict import OrderedDict
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 from rhodecode.lib.vcs.utils.paths import abspath
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
33 from rhodecode.lib.vcs.utils.hgcompat import (
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
34 ui, nullid, match, patch, diffopts, clone, get_contact, pull,
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
35 localrepository, RepoLookupError, Abort, RepoError, hex, scmutil, hg_url,
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
36 httpbasicauthhandler, httpdigestauthhandler, peer, httppeer
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
37 )
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
39 from .changeset import MercurialChangeset
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
40 from .inmemory import MercurialInMemoryChangeset
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
41 from .workdir import MercurialWorkdir
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
42
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
43 log = logging.getLogger(__name__)
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 class MercurialRepository(BaseRepository):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 Mercurial repository backend
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 DEFAULT_BRANCH_NAME = 'default'
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 scm = 'hg'
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 def __init__(self, repo_path, create=False, baseui=None, src_url=None,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 update_after_clone=False):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 Raises RepositoryError if repository could not be find at the given
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 ``repo_path``.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 :param repo_path: local path of the repository
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 :param create=False: if set to True, would try to create repository if
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 it does not exist rather than raising exception
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 :param baseui=None: user data
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 :param src_url=None: would try to clone repository from given location
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 :param update_after_clone=False: sets update of working copy after
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 making a clone
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 if not isinstance(repo_path, str):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 raise VCSError('Mercurial backend requires repository path to '
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 'be instance of <str> got %s instead' %
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 type(repo_path))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 self.path = abspath(repo_path)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 self.baseui = baseui or ui.ui()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 # We've set path and ui, now we can set _repo itself
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 self._repo = self._get_repo(create, src_url, update_after_clone)
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 @property
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 def _empty(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 """
3835
42981614c624 vcs: fixed issues with calling get_changesets method doesn't
Marcin Kuzminski <marcin@python-works.com>
parents: 3805
diff changeset
81 Checks if repository is empty ie. without any changesets
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 # TODO: Following raises errors when using InMemoryChangeset...
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 # return len(self._repo.changelog) == 0
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 return len(self.revisions) == 0
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 def revisions(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 Returns list of revisions' ids, in ascending order. Being lazy
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 attribute allows external tools to inject shas from cache.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 return self._get_all_revisions()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 def name(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 return os.path.basename(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 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 def branches(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 return self._get_branches()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102
3555
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
103 @LazyProperty
4020
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
104 def closed_branches(self):
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
105 return self._get_branches(normal=False, closed=True)
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
106
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
107 @LazyProperty
3555
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
108 def allbranches(self):
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
109 """
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
110 List all branches, including closed branches.
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
111 """
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
112 return self._get_branches(closed=True)
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
113
4020
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
114 def _get_branches(self, normal=True, closed=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
115 """
4089
a5888ca796b5 Fixed spelling of get's to gets
Marcin Kuzminski <marcin@python-works.com>
parents: 4020
diff changeset
116 Gets branches for this repository
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 Returns only not closed branches by default
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 :param closed: return also closed branches for mercurial
4020
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
120 :param normal: return also normal branches
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 if self._empty:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 return {}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126 def _branchtags(localrepo):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 Patched version of mercurial branchtags to not return the closed
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 branches
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 :param localrepo: locarepository instance
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134 bt = {}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 bt_closed = {}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 for bn, heads in localrepo.branchmap().iteritems():
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 tip = heads[-1]
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 'close' in localrepo.changelog.read(tip)[5]:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 bt_closed[bn] = tip
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140 else:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
141 bt[bn] = tip
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
142
4020
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
143 if not normal:
218ed589e44a branch selectors: show closed branches too
Mads Kiilerich <madski@unity3d.com>
parents: 3877
diff changeset
144 return bt_closed
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 if closed:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
146 bt.update(bt_closed)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
147 return bt
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 sortkey = lambda ctx: ctx[0] # sort by name
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 _branches = [(safe_unicode(n), hex(h),) for n, h in
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151 _branchtags(self._repo).items()]
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
153 return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
155 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156 def tags(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 """
4089
a5888ca796b5 Fixed spelling of get's to gets
Marcin Kuzminski <marcin@python-works.com>
parents: 4020
diff changeset
158 Gets tags for this repository
2007
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 return self._get_tags()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
161
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
162 def _get_tags(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
163 if self._empty:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
164 return {}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
165
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
166 sortkey = lambda ctx: ctx[0] # sort by name
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
167 _tags = [(safe_unicode(n), hex(h),) for n, h in
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
168 self._repo.tags().items()]
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
169
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
170 return OrderedDict(sorted(_tags, key=sortkey, reverse=True))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
171
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
172 def tag(self, name, user, revision=None, message=None, date=None,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
173 **kwargs):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
174 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
175 Creates and returns a tag 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
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 :param name: name for new tag
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
178 :param user: full username, i.e.: "Joe Doe <joe.doe@example.com>"
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
179 :param revision: changeset id for which new tag would be created
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
180 :param message: message of the tag's commit
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
181 :param date: date of tag's commit
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
182
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
183 :raises TagAlreadyExistError: if tag with same name already exists
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
184 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
185 if name in self.tags:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
186 raise TagAlreadyExistError("Tag %s already exists" % name)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
187 changeset = self.get_changeset(revision)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
188 local = kwargs.setdefault('local', False)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
189
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
190 if message 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
191 message = "Added tag %s for changeset %s" % (name,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
192 changeset.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
193
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
194 if date 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
195 date = datetime.datetime.now().ctime()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
196
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
197 try:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
198 self._repo.tag(name, changeset._ctx.node(), message, local, user,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
199 date)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
200 except Abort, e:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
201 raise RepositoryError(e.message)
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 # Reinitialize tags
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
204 self.tags = self._get_tags()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
205 tag_id = self.tags[name]
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 return self.get_changeset(revision=tag_id)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
208
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
209 def remove_tag(self, name, user, message=None, date=None):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
210 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
211 Removes tag with the given ``name``.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
212
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
213 :param name: name of the tag to be removed
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
214 :param user: full username, i.e.: "Joe Doe <joe.doe@example.com>"
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
215 :param message: message of the tag's removal commit
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
216 :param date: date of tag's removal commit
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 :raises TagDoesNotExistError: if tag with given name does not exists
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
219 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
220 if name not in self.tags:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
221 raise TagDoesNotExistError("Tag %s does not exist" % name)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
222 if message 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
223 message = "Removed tag %s" % name
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
224 if date 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
225 date = datetime.datetime.now().ctime()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
226 local = False
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
227
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 self._repo.tag(name, nullid, message, local, user, date)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
230 self.tags = self._get_tags()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
231 except Abort, e:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
232 raise RepositoryError(e.message)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
233
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
234 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
235 def bookmarks(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
236 """
4089
a5888ca796b5 Fixed spelling of get's to gets
Marcin Kuzminski <marcin@python-works.com>
parents: 4020
diff changeset
237 Gets bookmarks for this repository
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
238 """
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 self._get_bookmarks()
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 def _get_bookmarks(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
242 if self._empty:
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 {}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
244
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
245 sortkey = lambda ctx: ctx[0] # sort by name
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
246 _bookmarks = [(safe_unicode(n), hex(h),) for n, h in
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
247 self._repo._bookmarks.items()]
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
248 return OrderedDict(sorted(_bookmarks, key=sortkey, reverse=True))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
249
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
250 def _get_all_revisions(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
251
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
252 return map(lambda x: hex(x[7]), self._repo.changelog.index)[:-1]
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 def get_diff(self, rev1, rev2, path='', ignore_whitespace=False,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
255 context=3):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
256 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
257 Returns (git like) *diff*, as plain text. Shows changes introduced by
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
258 ``rev2`` since ``rev1``.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
259
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
260 :param rev1: Entry point from which diff is shown. Can be
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
261 ``self.EMPTY_CHANGESET`` - in this case, patch showing all
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
262 the changes since empty state of the repository until ``rev2``
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
263 :param rev2: Until which revision changes should be shown.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
264 :param ignore_whitespace: If set to ``True``, would not show whitespace
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
265 changes. Defaults to ``False``.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
266 :param context: How many lines before/after changed lines should be
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
267 shown. Defaults to ``3``.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
268 """
2386
ed8c2fc8dd3b Add support for vcs Changeset objects in get_diff method
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
269 if hasattr(rev1, 'raw_id'):
ed8c2fc8dd3b Add support for vcs Changeset objects in get_diff method
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
270 rev1 = getattr(rev1, 'raw_id')
ed8c2fc8dd3b Add support for vcs Changeset objects in get_diff method
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
271
ed8c2fc8dd3b Add support for vcs Changeset objects in get_diff method
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
272 if hasattr(rev2, 'raw_id'):
ed8c2fc8dd3b Add support for vcs Changeset objects in get_diff method
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
273 rev2 = getattr(rev2, 'raw_id')
ed8c2fc8dd3b Add support for vcs Changeset objects in get_diff method
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
274
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
275 # Check if given revisions are present at repository (may raise
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
276 # ChangesetDoesNotExistError)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
277 if rev1 != self.EMPTY_CHANGESET:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
278 self.get_changeset(rev1)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
279 self.get_changeset(rev2)
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2706
diff changeset
280 if path:
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2706
diff changeset
281 file_filter = match(self.path, '', [path])
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2706
diff changeset
282 else:
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2706
diff changeset
283 file_filter = 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 return ''.join(patch.diff(self._repo, rev1, rev2, match=file_filter,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
286 opts=diffopts(git=True,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
287 ignorews=ignore_whitespace,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
288 context=context)))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
289
2704
959d0daa44da Added url validator for git
Marcin Kuzminski <marcin@python-works.com>
parents: 2700
diff changeset
290 @classmethod
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
291 def _check_url(cls, url, repoui=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
292 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
293 Function will check given url and try to verify if it's a valid
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
294 link. Sometimes it may happened that mercurial will issue basic
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
295 auth request that can cause whole API to hang when used from python
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
296 or other external calls.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
297
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
298 On failures it'll raise urllib2.HTTPError, exception is also thrown
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
299 when the return code is non 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
300 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
301 # check first if it's not an local url
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
302 if os.path.isdir(url) or url.startswith('file:'):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
303 return True
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
304
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
305 if '+' in url[:url.find('://')]:
2704
959d0daa44da Added url validator for git
Marcin Kuzminski <marcin@python-works.com>
parents: 2700
diff changeset
306 url = url[url.find('+') + 1:]
2700
f4b20558ae16 allow cloning with hgsubversion (reimplementing pull request 46)
domruf <dominikruf@gmail.com>
parents: 2543
diff changeset
307
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
308 handlers = []
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
309 url_obj = hg_url(url)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
310 test_uri, authinfo = url_obj.authinfo()
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
311 url_obj.passwd = '*****'
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
312 cleaned_uri = str(url_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
313
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
314 if authinfo:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
315 #create a password manager
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
316 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
317 passmgr.add_password(*authinfo)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
318
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
319 handlers.extend((httpbasicauthhandler(passmgr),
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
320 httpdigestauthhandler(passmgr)))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
321
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
322 o = urllib2.build_opener(*handlers)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
323 o.addheaders = [('Content-Type', 'application/mercurial-0.1'),
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
324 ('Accept', 'application/mercurial-0.1')]
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 q = {"cmd": 'between'}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
327 q.update({'pairs': "%s-%s" % ('0' * 40, '0' * 40)})
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
328 qs = '?%s' % urllib.urlencode(q)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
329 cu = "%s%s" % (test_uri, qs)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
330 req = urllib2.Request(cu, None, {})
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
331
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
332 try:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
333 resp = o.open(req)
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
334 if resp.code != 200:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
335 raise Exception('Return Code is not 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
336 except Exception, e:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
337 # means it cannot be cloned
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
338 raise urllib2.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
339
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
340 # now check if it's a proper hg repo
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
341 try:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
342 repo_id = httppeer(repoui or ui.ui(), url).lookup('tip')
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
343 except Exception, e:
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
344 raise urllib2.URLError(
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
345 "url [%s] does not look like an hg repo org_exc: %s"
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
346 % (cleaned_uri, e))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
347
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
348 return True
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
349
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
350 def _get_repo(self, create, src_url=None, update_after_clone=False):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
351 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
352 Function will check for mercurial repository in given path and return
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
353 a localrepo object. If there is no repository in that path it will
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 an exception unless ``create`` parameter is set to True - in
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
355 that case repository would be created and returned.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
356 If ``src_url`` is given, would try to clone repository from the
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
357 location at given clone_point. Additionally it'll make update to
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
358 working copy accordingly to ``update_after_clone`` flag
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
359 """
2706
22f79562836c Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2704
diff changeset
360
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
361 try:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
362 if src_url:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
363 url = str(self._get_url(src_url))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
364 opts = {}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
365 if not update_after_clone:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
366 opts.update({'noupdate': True})
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
367 try:
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
368 MercurialRepository._check_url(url, self.baseui)
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
369 clone(self.baseui, url, self.path, **opts)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
370 # except urllib2.URLError:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
371 # raise Abort("Got HTTP 404 error")
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
372 except Exception:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
373 raise
2706
22f79562836c Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2704
diff changeset
374
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
375 # Don't try to create if we've already cloned repo
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
376 create = False
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
377 return localrepository(self.baseui, self.path, create=create)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
378 except (Abort, RepoError), err:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
379 if create:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
380 msg = "Cannot create repository at %s. Original error was %s"\
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
381 % (self.path, err)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
382 else:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
383 msg = "Not valid repository at %s. Original error was %s"\
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
384 % (self.path, err)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
385 raise RepositoryError(msg)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
386
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
387 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
388 def in_memory_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
389 return MercurialInMemoryChangeset(self)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
390
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
391 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
392 def description(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
393 undefined_description = u'unknown'
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
394 _desc = self._repo.ui.config('web', 'description', None, untrusted=True)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
395 return safe_unicode(_desc or undefined_description)
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
396
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
397 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
398 def contact(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
399 undefined_contact = u'Unknown'
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
400 return safe_unicode(get_contact(self._repo.ui.config)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
401 or undefined_contact)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
402
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
403 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
404 def last_change(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
405 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
406 Returns last change made on this repository as datetime object
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
407 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
408 return date_fromtimestamp(self._get_mtime(), makedate()[1])
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
409
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
410 def _get_mtime(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
411 try:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
412 return time.mktime(self.get_changeset().date.timetuple())
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
413 except RepositoryError:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
414 #fallback to filesystem
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
415 cl_path = os.path.join(self.path, '.hg', "00changelog.i")
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
416 st_path = os.path.join(self.path, '.hg', "store")
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 os.path.exists(cl_path):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
418 return os.stat(cl_path).st_mtime
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
419 else:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
420 return os.stat(st_path).st_mtime
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
421
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
422 def _get_hidden(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
423 return self._repo.ui.configbool("web", "hidden", untrusted=True)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
424
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
425 def _get_revision(self, revision):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
426 """
4089
a5888ca796b5 Fixed spelling of get's to gets
Marcin Kuzminski <marcin@python-works.com>
parents: 4020
diff changeset
427 Gets an ID revision given as str. This will always return a fill
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
428 40 char revision number
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
429
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
430 :param revision: str or int or None
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
431 """
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 if self._empty:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
434 raise EmptyRepositoryError("There are no changesets yet")
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
435
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
436 if revision in [-1, 'tip', None]:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
437 revision = 'tip'
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
438
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
439 try:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
440 revision = hex(self._repo.lookup(revision))
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
441 except (LookupError, ):
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
442 msg = ("Ambiguous identifier `%s` for %s" % (revision, self))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
443 raise ChangesetDoesNotExistError(msg)
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
444 except (IndexError, ValueError, RepoLookupError, TypeError):
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
445 msg = ("Revision %s does not exist for %s" % (revision, self))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
446 raise ChangesetDoesNotExistError(msg)
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
447
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
448 return revision
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
449
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
450 def _get_archives(self, archive_name='tip'):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
451 allowed = self.baseui.configlist("web", "allow_archive",
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
452 untrusted=True)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
453 for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
454 if i[0] in allowed or self._repo.ui.configbool("web",
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
455 "allow" + i[0],
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
456 untrusted=True):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
457 yield {"type": i[0], "extension": i[1], "node": archive_name}
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
458
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
459 def _get_url(self, url):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
460 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
461 Returns normalized url. If schema is not given, would fall
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
462 to filesystem
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
463 (``file:///``) schema.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
464 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
465 url = str(url)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
466 if url != 'default' and not '://' in url:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
467 url = "file:" + urllib.pathname2url(url)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
468 return url
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
469
3456
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
470 def get_hook_location(self):
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
471 """
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
472 returns absolute path to location where hooks are stored
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
473 """
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
474 return os.path.join(self.path, '.hg', '.hgrc')
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
475
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
476 def get_changeset(self, revision=None):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
477 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
478 Returns ``MercurialChangeset`` object representing repository's
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
479 changeset at 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
480 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
481 revision = self._get_revision(revision)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
482 changeset = MercurialChangeset(repository=self, revision=revision)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
483 return changeset
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
484
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
485 def get_changesets(self, start=None, end=None, start_date=None,
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
486 end_date=None, branch_name=None, reverse=False):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
487 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
488 Returns iterator of ``MercurialChangeset`` objects from start to end
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
489 (both are inclusive)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
490
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
491 :param start: None, str, int or mercurial lookup format
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
492 :param end: None, str, int or mercurial lookup format
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
493 :param start_date:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
494 :param end_date:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
495 :param branch_name:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
496 :param reversed: return changesets in reversed order
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
497 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
498
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
499 start_raw_id = self._get_revision(start)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
500 start_pos = self.revisions.index(start_raw_id) if start else None
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
501 end_raw_id = self._get_revision(end)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
502 end_pos = self.revisions.index(end_raw_id) if end else None
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
503
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
504 if None not in [start, end] and start_pos > end_pos:
3554
189ce0d7b7c6 hg: improve 'Such branch %s does not exists' message
Mads Kiilerich <madski@unity3d.com>
parents: 3456
diff changeset
505 raise RepositoryError("Start revision '%s' cannot be "
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
506 "after end revision '%s'" % (start, end))
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
507
3555
ff0646d1a1b4 changelog: make it possible to use closed branches in ?branch=...
Mads Kiilerich <madski@unity3d.com>
parents: 3554
diff changeset
508 if branch_name and branch_name not in self.allbranches.keys():
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
509 msg = ("Branch %s not found in %s" % (branch_name, self))
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4089
diff changeset
510 raise BranchDoesNotExistError(msg)
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 if end_pos is not None:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
512 end_pos += 1
3746
76b935e7427d get_changeset uses now mercurial revrange to filter out branches.
Marcin Kuzminski <marcin@python-works.com>
parents: 3575
diff changeset
513 #filter branches
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
514 filter_ = []
3746
76b935e7427d get_changeset uses now mercurial revrange to filter out branches.
Marcin Kuzminski <marcin@python-works.com>
parents: 3575
diff changeset
515 if branch_name:
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
516 filter_.append('branch("%s")' % (branch_name))
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
517
3805
a5c234e934c5 synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
518 if start_date and not end_date:
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
519 filter_.append('date(">%s")' % start_date)
3805
a5c234e934c5 synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
520 if end_date and not start_date:
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
521 filter_.append('date("<%s")' % end_date)
3805
a5c234e934c5 synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
522 if start_date and end_date:
a5c234e934c5 synced with latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
523 filter_.append('date(">%s") and date("<%s")' % (start_date, end_date))
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
524 if filter_:
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
525 revisions = scmutil.revrange(self._repo, filter_)
3746
76b935e7427d get_changeset uses now mercurial revrange to filter out branches.
Marcin Kuzminski <marcin@python-works.com>
parents: 3575
diff changeset
526 else:
76b935e7427d get_changeset uses now mercurial revrange to filter out branches.
Marcin Kuzminski <marcin@python-works.com>
parents: 3575
diff changeset
527 revisions = self.revisions
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
528
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
529 revs = revisions[start_pos:end_pos]
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
530 if reverse:
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3747
diff changeset
531 revs = reversed(revs)
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
532
3747
600ffde2634c changelog pagination with branch filtering now uses
Marcin Kuzminski <marcin@python-works.com>
parents: 3746
diff changeset
533 return CollectionGenerator(self, revs)
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
534
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 pull(self, url):
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 Tries to pull changes from external location.
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 url = self._get_url(url)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
540 try:
3877
5070c840dc23 Use lower level API from mercurial when doing a pull
Marcin Kuzminski <marcin@python-works.com>
parents: 3835
diff changeset
541 other = peer(self._repo, {}, url)
5070c840dc23 Use lower level API from mercurial when doing a pull
Marcin Kuzminski <marcin@python-works.com>
parents: 3835
diff changeset
542 self._repo.pull(other, heads=None, force=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
543 except Abort, err:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
544 # Propagate error but with vcs's type
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
545 raise RepositoryError(str(err))
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 @LazyProperty
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
548 def workdir(self):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
549 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
550 Returns ``Workdir`` instance for this repository.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
551 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
552 return MercurialWorkdir(self)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
553
3456
cf1fbc9fed89 Added get_hook_location method for easier hook extraction
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
554 def get_config_value(self, section, name=None, config_file=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
555 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
556 Returns configuration value for a given [``section``] and ``name``.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
557
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
558 :param section: Section we want to retrieve value from
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
559 :param name: Name of configuration we want to retrieve
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
560 :param config_file: A path to file which should be used to retrieve
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
561 configuration from (might also be a list of file paths)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
562 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
563 if config_file 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
564 config_file = []
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
565 elif isinstance(config_file, basestring):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
566 config_file = [config_file]
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
567
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
568 config = self._repo.ui
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
569 for path in config_file:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
570 config.readconfig(path)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
571 return config.config(section, name)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
572
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
573 def get_user_name(self, config_file=None):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
574 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
575 Returns user's name from global configuration file.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
576
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
577 :param config_file: A path to file which should be used to retrieve
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
578 configuration from (might also be a list of file paths)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
579 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
580 username = self.get_config_value('ui', 'username')
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
581 if username:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
582 return author_name(username)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
583 return None
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
584
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
585 def get_user_email(self, config_file=None):
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
586 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
587 Returns user's email from global configuration file.
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
588
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
589 :param config_file: A path to file which should be used to retrieve
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
590 configuration from (might also be a list of file paths)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
591 """
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
592 username = self.get_config_value('ui', 'username')
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
593 if username:
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
594 return author_email(username)
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
595 return None