##// END OF EJS Templates
vcs: drop the superfluous and leaky hgcompat "layer"...
Mads Kiilerich -
r7977:f713a375 default
parent child Browse files
Show More
@@ -30,6 +30,7 b' Original author and date, and relevant c'
30 30 import logging
31 31 import re
32 32
33 import mercurial.unionrepo
33 34 from tg import request
34 35 from tg import tmpl_context as c
35 36 from tg.i18n import ugettext as _
@@ -43,7 +44,6 b' from kallithea.lib.auth import HasRepoPe'
43 44 from kallithea.lib.base import BaseRepoController, render
44 45 from kallithea.lib.graphmod import graph_data
45 46 from kallithea.lib.utils2 import ascii_bytes, ascii_str, safe_int, safe_str
46 from kallithea.lib.vcs.utils.hgcompat import unionrepo
47 47 from kallithea.model.db import Repository
48 48
49 49
@@ -97,7 +97,7 b' class CompareController(BaseRepoControll'
97 97 elif alias == 'hg':
98 98 # case two independent repos
99 99 if org_repo != other_repo:
100 hgrepo = unionrepo.makeunionrepository(other_repo.baseui,
100 hgrepo = mercurial.unionrepo.makeunionrepository(other_repo.baseui,
101 101 other_repo.path,
102 102 org_repo.path)
103 103 # all ancestors of other_rev will be in other_repo and
@@ -29,6 +29,7 b' import logging'
29 29 import traceback
30 30
31 31 import formencode
32 import mercurial.unionrepo
32 33 from tg import request
33 34 from tg import tmpl_context as c
34 35 from tg.i18n import ugettext as _
@@ -44,7 +45,6 b' from kallithea.lib.graphmod import graph'
44 45 from kallithea.lib.page import Page
45 46 from kallithea.lib.utils2 import ascii_bytes, safe_bytes, safe_int, safe_str
46 47 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
47 from kallithea.lib.vcs.utils.hgcompat import unionrepo
48 48 from kallithea.model.changeset_status import ChangesetStatusModel
49 49 from kallithea.model.comment import ChangesetCommentsModel
50 50 from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, Repository, User
@@ -533,7 +533,7 b' class PullrequestsController(BaseRepoCon'
533 533 # Note: org_scm_instance.path must come first so all
534 534 # valid revision numbers are 100% org_scm compatible
535 535 # - both for avail_revs and for revset results
536 hgrepo = unionrepo.makeunionrepository(org_scm_instance.baseui,
536 hgrepo = mercurial.unionrepo.makeunionrepository(org_scm_instance.baseui,
537 537 org_scm_instance.path,
538 538 other_scm_instance.path)
539 539 else:
@@ -28,12 +28,13 b' Original author and date, and relevant c'
28 28 import os
29 29 import time
30 30
31 import mercurial.scmutil
32
31 33 from kallithea.lib import helpers as h
32 34 from kallithea.lib.exceptions import UserCreationError
33 35 from kallithea.lib.utils import action_logger, make_ui, setup_cache_regions
34 36 from kallithea.lib.utils2 import ascii_str, get_hook_environment, safe_str, safe_unicode
35 37 from kallithea.lib.vcs.backends.base import EmptyChangeset
36 from kallithea.lib.vcs.utils.hgcompat import revrange
37 38 from kallithea.model.db import Repository, User
38 39
39 40
@@ -108,7 +109,7 b' def log_push_action(ui, repo, node, node'
108 109 Note: This hook is not only logging, but also the side effect invalidating
109 110 cahes! The function should perhaps be renamed.
110 111 """
111 revs = [ascii_str(repo[r].hex()) for r in revrange(repo, [b'%s:%s' % (node, node_last)])]
112 revs = [ascii_str(repo[r].hex()) for r in mercurial.scmutil.revrange(repo, [b'%s:%s' % (node, node_last)])]
112 113 process_pushed_raw_ids(revs)
113 114 return 0
114 115
@@ -32,10 +32,11 b' import logging'
32 32 import os
33 33 import urllib
34 34
35 import mercurial.hgweb
36
35 37 from kallithea.lib.base import BaseVCSController, get_path_info
36 38 from kallithea.lib.utils import make_ui
37 39 from kallithea.lib.utils2 import safe_str, safe_unicode
38 from kallithea.lib.vcs.utils.hgcompat import hgweb_mod
39 40
40 41
41 42 log = logging.getLogger(__name__)
@@ -139,10 +140,10 b' class SimpleHg(BaseVCSController):'
139 140 str_repo_name = safe_str(parsed_request.repo_name)
140 141 repo_path = os.path.join(safe_str(self.basepath), str_repo_name)
141 142 baseui = make_ui(repo_path=repo_path)
142 hgweb_app = hgweb_mod.hgweb(repo_path, name=str_repo_name, baseui=baseui)
143 hgweb_app = mercurial.hgweb.hgweb(repo_path, name=str_repo_name, baseui=baseui)
143 144
144 145 def wrapper_app(environ, start_response):
145 environ['REPO_NAME'] = str_repo_name # used by hgweb_mod.hgweb
146 environ['REPO_NAME'] = str_repo_name # used by mercurial.hgweb.hgweb
146 147 return hgweb_app(environ, start_response)
147 148
148 149 return wrapper_app
@@ -34,6 +34,8 b' import traceback'
34 34 from distutils.version import StrictVersion
35 35
36 36 import beaker
37 import mercurial.config
38 import mercurial.ui
37 39 from beaker.cache import _cache_decorate
38 40 from tg.i18n import ugettext as _
39 41
@@ -46,7 +48,6 b' from kallithea.lib.vcs.conf import setti'
46 48 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError
47 49 from kallithea.lib.vcs.utils.fakemod import create_module
48 50 from kallithea.lib.vcs.utils.helpers import get_scm
49 from kallithea.lib.vcs.utils.hgcompat import config, ui
50 51 from kallithea.model import meta
51 52 from kallithea.model.db import RepoGroup, Repository, Setting, Ui, User, UserGroup, UserLog
52 53
@@ -327,12 +328,12 b' def make_ui(repo_path=None):'
327 328 Create an Mercurial 'ui' object based on database Ui settings, possibly
328 329 augmenting with content from a hgrc file.
329 330 """
330 baseui = ui.ui()
331 baseui = mercurial.ui.ui()
331 332
332 333 # clean the baseui object
333 baseui._ocfg = config.config()
334 baseui._ucfg = config.config()
335 baseui._tcfg = config.config()
334 baseui._ocfg = mercurial.config.config()
335 baseui._ucfg = mercurial.config.config()
336 baseui._tcfg = mercurial.config.config()
336 337
337 338 sa = meta.Session()
338 339 for ui_ in sa.query(Ui).all():
@@ -356,7 +357,7 b' def make_ui(repo_path=None):'
356 357 hgrc_path = os.path.join(repo_path, '.hg', 'hgrc')
357 358 if os.path.isfile(hgrc_path):
358 359 log.debug('reading hgrc from %s', hgrc_path)
359 cfg = config.config()
360 cfg = mercurial.config.config()
360 361 cfg.read(hgrc_path)
361 362 for section in ui_sections:
362 363 for k, v in cfg.items(section):
@@ -18,6 +18,8 b' import urllib'
18 18 import urllib2
19 19 from collections import OrderedDict
20 20
21 import mercurial.url # import httpbasicauthhandler, httpdigestauthhandler
22 import mercurial.util # import url as hg_url
21 23 from dulwich.config import ConfigFile
22 24 from dulwich.objects import Tag
23 25 from dulwich.repo import NotGitRepository, Repo
@@ -28,7 +30,6 b' from kallithea.lib.vcs.conf import setti'
28 30 from kallithea.lib.vcs.exceptions import (
29 31 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError)
30 32 from kallithea.lib.vcs.utils import ascii_str, date_fromtimestamp, makedate, safe_str, safe_unicode
31 from kallithea.lib.vcs.utils.hgcompat import hg_url, httpbasicauthhandler, httpdigestauthhandler
32 33 from kallithea.lib.vcs.utils.lazy import LazyProperty
33 34 from kallithea.lib.vcs.utils.paths import abspath, get_user_home
34 35
@@ -168,7 +169,7 b' class GitRepository(BaseRepository):'
168 169 url = url[url.find('+') + 1:]
169 170
170 171 handlers = []
171 url_obj = hg_url(url)
172 url_obj = mercurial.util.url(url)
172 173 test_uri, authinfo = url_obj.authinfo()
173 174 if not test_uri.endswith('info/refs'):
174 175 test_uri = test_uri.rstrip('/') + '/info/refs'
@@ -181,8 +182,8 b' class GitRepository(BaseRepository):'
181 182 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
182 183 passmgr.add_password(*authinfo)
183 184
184 handlers.extend((httpbasicauthhandler(passmgr),
185 httpdigestauthhandler(passmgr)))
185 handlers.extend((mercurial.url.httpbasicauthhandler(passmgr),
186 mercurial.url.httpdigestauthhandler(passmgr)))
186 187
187 188 o = urllib2.build_opener(*handlers)
188 189 o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git
@@ -9,6 +9,8 b''
9 9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
10 10 """
11 11
12 from kallithea.lib.vcs.utils import hgcompat
13
12 14 from .changeset import MercurialChangeset
13 15 from .inmemory import MercurialInMemoryChangeset
14 16 from .repository import MercurialRepository
@@ -19,3 +21,5 b' from .workdir import MercurialWorkdir'
19 21 'MercurialRepository', 'MercurialChangeset',
20 22 'MercurialInMemoryChangeset', 'MercurialWorkdir',
21 23 ]
24
25 hgcompat.monkey_do()
@@ -1,13 +1,16 b''
1 1 import os
2 2 import posixpath
3 3
4 import mercurial.archival
5 import mercurial.node
6 import mercurial.obsutil
7
4 8 from kallithea.lib.vcs.backends.base import BaseChangeset
5 9 from kallithea.lib.vcs.conf import settings
6 10 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError, NodeDoesNotExistError, VCSError
7 11 from kallithea.lib.vcs.nodes import (
8 12 AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode, NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode)
9 13 from kallithea.lib.vcs.utils import ascii_bytes, ascii_str, date_fromtimestamp, safe_str, safe_unicode
10 from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
11 14 from kallithea.lib.vcs.utils.lazy import LazyProperty
12 15 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
13 16
@@ -72,17 +75,17 b' class MercurialChangeset(BaseChangeset):'
72 75
73 76 @LazyProperty
74 77 def successors(self):
75 successors = obsutil.successorssets(self._ctx._repo, self._ctx.node(), closest=True)
78 successors = mercurial.obsutil.successorssets(self._ctx._repo, self._ctx.node(), closest=True)
76 79 if successors:
77 80 # flatten the list here handles both divergent (len > 1)
78 81 # and the usual case (len = 1)
79 successors = [hex(n)[:12] for sub in successors for n in sub if n != self._ctx.node()]
82 successors = [mercurial.node.hex(n)[:12] for sub in successors for n in sub if n != self._ctx.node()]
80 83
81 84 return successors
82 85
83 86 @LazyProperty
84 87 def predecessors(self):
85 return [hex(n)[:12] for n in obsutil.closestpredecessors(self._ctx._repo, self._ctx.node())]
88 return [mercurial.node.hex(n)[:12] for n in mercurial.obsutil.closestpredecessors(self._ctx._repo, self._ctx.node())]
86 89
87 90 @LazyProperty
88 91 def bookmarks(self):
@@ -271,7 +274,7 b' class MercurialChangeset(BaseChangeset):'
271 274 cnt = 0
272 275 for cs in reversed([x for x in fctx.filelog()]):
273 276 cnt += 1
274 hist.append(hex(fctx.filectx(cs).node()))
277 hist.append(mercurial.node.hex(fctx.filectx(cs).node()))
275 278 if limit is not None and cnt == limit:
276 279 break
277 280
@@ -320,7 +323,7 b' class MercurialChangeset(BaseChangeset):'
320 323 elif prefix.strip() == '':
321 324 raise VCSError("Prefix cannot be empty")
322 325
323 archival.archive(self.repository._repo, stream, ascii_bytes(self.raw_id),
326 mercurial.archival.archive(self.repository._repo, stream, ascii_bytes(self.raw_id),
324 327 kind, prefix=prefix, subrepos=subrepos)
325 328
326 329 def get_nodes(self, path):
@@ -1,9 +1,11 b''
1 1 import datetime
2 2
3 import mercurial.context
4 import mercurial.node
5
3 6 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
4 7 from kallithea.lib.vcs.exceptions import RepositoryError
5 8 from kallithea.lib.vcs.utils import ascii_str, safe_bytes
6 from kallithea.lib.vcs.utils.hgcompat import hex, memctx, memfilectx
7 9
8 10
9 11 class MercurialInMemoryChangeset(BaseInMemoryChangeset):
@@ -51,7 +53,7 b' class MercurialInMemoryChangeset(BaseInM'
51 53 # check if this path is added
52 54 for node in self.added:
53 55 if node.path == path:
54 return memfilectx(_repo, memctx, path=node.path,
56 return mercurial.context.memfilectx(_repo, memctx, path=node.path,
55 57 data=node.content,
56 58 islink=False,
57 59 isexec=node.is_executable,
@@ -60,7 +62,7 b' class MercurialInMemoryChangeset(BaseInM'
60 62 # or changed
61 63 for node in self.changed:
62 64 if node.path == path:
63 return memfilectx(_repo, memctx, path=node.path,
65 return mercurial.context.memfilectx(_repo, memctx, path=node.path,
64 66 data=node.content,
65 67 islink=False,
66 68 isexec=node.is_executable,
@@ -77,7 +79,8 b' class MercurialInMemoryChangeset(BaseInM'
77 79 if date and isinstance(date, datetime.datetime):
78 80 date = date.strftime('%a, %d %b %Y %H:%M:%S')
79 81
80 commit_ctx = memctx(repo=self.repository._repo,
82 commit_ctx = mercurial.context.memctx(
83 repo=self.repository._repo,
81 84 parents=parents,
82 85 text=b'',
83 86 files=self.get_paths(),
@@ -98,7 +101,7 b' class MercurialInMemoryChangeset(BaseInM'
98 101 # Update vcs repository object & recreate mercurial _repo
99 102 # new_ctx = self.repository._repo[node]
100 103 # new_tip = ascii_str(self.repository.get_changeset(new_ctx.hex()))
101 self.repository.revisions.append(ascii_str(hex(n)))
104 self.repository.revisions.append(ascii_str(mercurial.node.hex(n)))
102 105 self._repo = self.repository._get_repo(create=False)
103 106 self.repository.branches = self.repository._get_branches()
104 107 tip = self.repository.get_changeset()
@@ -17,12 +17,27 b' import urllib'
17 17 import urllib2
18 18 from collections import OrderedDict
19 19
20 import mercurial.commands
21 import mercurial.error
22 import mercurial.exchange
23 import mercurial.hg
24 import mercurial.hgweb
25 import mercurial.httppeer
26 import mercurial.match
27 import mercurial.mdiff
28 import mercurial.node
29 import mercurial.patch
30 import mercurial.scmutil
31 import mercurial.sshpeer
32 import mercurial.tags
33 import mercurial.ui
34 import mercurial.url
35 import mercurial.util
36
20 37 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
21 38 from kallithea.lib.vcs.exceptions import (
22 39 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError, VCSError)
23 40 from kallithea.lib.vcs.utils import ascii_str, author_email, author_name, date_fromtimestamp, makedate, safe_bytes, safe_str, safe_unicode
24 from kallithea.lib.vcs.utils.hgcompat import (
25 Abort, RepoError, RepoLookupError, clone, diffopts, get_contact, hex, hg_url, httpbasicauthhandler, httpdigestauthhandler, httppeer, localrepo, match_exact, nullid, patch, peer, scmutil, sshpeer, tag, ui)
26 41 from kallithea.lib.vcs.utils.lazy import LazyProperty
27 42 from kallithea.lib.vcs.utils.paths import abspath
28 43
@@ -62,7 +77,7 b' class MercurialRepository(BaseRepository'
62 77 type(repo_path))
63 78
64 79 self.path = abspath(repo_path)
65 self.baseui = baseui or ui.ui()
80 self.baseui = baseui or mercurial.ui.ui()
66 81 # We've set path and ui, now we can set _repo itself
67 82 self._repo = self._get_repo(create, src_url, update_after_clone)
68 83
@@ -118,10 +133,10 b' class MercurialRepository(BaseRepository'
118 133 for bn, _heads, node, isclosed in sorted(self._repo.branchmap().iterbranches()):
119 134 if isclosed:
120 135 if closed:
121 bt[safe_unicode(bn)] = ascii_str(hex(node))
136 bt[safe_unicode(bn)] = ascii_str(mercurial.node.hex(node))
122 137 else:
123 138 if normal:
124 bt[safe_unicode(bn)] = ascii_str(hex(node))
139 bt[safe_unicode(bn)] = ascii_str(mercurial.node.hex(node))
125 140 return bt
126 141
127 142 @LazyProperty
@@ -136,7 +151,7 b' class MercurialRepository(BaseRepository'
136 151 return {}
137 152
138 153 return OrderedDict(sorted(
139 ((safe_unicode(n), ascii_str(hex(h))) for n, h in self._repo.tags().items()),
154 ((safe_unicode(n), ascii_str(mercurial.node.hex(h))) for n, h in self._repo.tags().items()),
140 155 reverse=True,
141 156 key=lambda x: x[0], # sort by name
142 157 ))
@@ -167,8 +182,8 b' class MercurialRepository(BaseRepository'
167 182 date = datetime.datetime.now().strftime('%a, %d %b %Y %H:%M:%S')
168 183
169 184 try:
170 tag(self._repo, name, changeset._ctx.node(), message, local, user, date)
171 except Abort as e:
185 mercurial.tags.tag(self._repo, name, changeset._ctx.node(), message, local, user, date)
186 except mercurial.error.Abort as e:
172 187 raise RepositoryError(e.message)
173 188
174 189 # Reinitialize tags
@@ -197,9 +212,9 b' class MercurialRepository(BaseRepository'
197 212 local = False
198 213
199 214 try:
200 tag(self._repo, name, nullid, message, local, user, date)
215 mercurial.tags.tag(self._repo, name, mercurial.commands.nullid, message, local, user, date)
201 216 self.tags = self._get_tags()
202 except Abort as e:
217 except mercurial.error.Abort as e:
203 218 raise RepositoryError(e.message)
204 219
205 220 @LazyProperty
@@ -256,12 +271,12 b' class MercurialRepository(BaseRepository'
256 271 self.get_changeset(rev1)
257 272 self.get_changeset(rev2)
258 273 if path:
259 file_filter = match_exact(path)
274 file_filter = mercurial.match.exact(path)
260 275 else:
261 276 file_filter = None
262 277
263 return b''.join(patch.diff(self._repo, rev1, rev2, match=file_filter,
264 opts=diffopts(git=True,
278 return b''.join(mercurial.patch.diff(self._repo, rev1, rev2, match=file_filter,
279 opts=mercurial.mdiff.diffopts(git=True,
265 280 showfunc=True,
266 281 ignorews=ignore_whitespace,
267 282 context=context)))
@@ -284,7 +299,7 b' class MercurialRepository(BaseRepository'
284 299 if url.startswith(b'ssh:'):
285 300 # in case of invalid uri or authentication issues, sshpeer will
286 301 # throw an exception.
287 sshpeer.instance(repoui or ui.ui(), url, False).lookup(b'tip')
302 mercurial.sshpeer.instance(repoui or mercurial.ui.ui(), url, False).lookup(b'tip')
288 303 return True
289 304
290 305 url_prefix = None
@@ -292,7 +307,7 b' class MercurialRepository(BaseRepository'
292 307 url_prefix, url = url.split(b'+', 1)
293 308
294 309 handlers = []
295 url_obj = hg_url(url)
310 url_obj = mercurial.util.url(url)
296 311 test_uri, authinfo = url_obj.authinfo()
297 312 url_obj.passwd = b'*****'
298 313 cleaned_uri = str(url_obj)
@@ -302,8 +317,8 b' class MercurialRepository(BaseRepository'
302 317 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
303 318 passmgr.add_password(*authinfo)
304 319
305 handlers.extend((httpbasicauthhandler(passmgr),
306 httpdigestauthhandler(passmgr)))
320 handlers.extend((mercurial.url.httpbasicauthhandler(passmgr),
321 mercurial.url.httpdigestauthhandler(passmgr)))
307 322
308 323 o = urllib2.build_opener(*handlers)
309 324 o.addheaders = [('Content-Type', 'application/mercurial-0.1'),
@@ -326,7 +341,7 b' class MercurialRepository(BaseRepository'
326 341 if not url_prefix: # skip svn+http://... (and git+... too)
327 342 # now check if it's a proper hg repo
328 343 try:
329 httppeer.instance(repoui or ui.ui(), url, False).lookup(b'tip')
344 mercurial.httppeer.instance(repoui or mercurial.ui.ui(), url, False).lookup(b'tip')
330 345 except Exception as e:
331 346 raise urllib2.URLError(
332 347 "url [%s] does not look like an hg repo org_exc: %s"
@@ -352,12 +367,12 b' class MercurialRepository(BaseRepository'
352 367 if not update_after_clone:
353 368 opts.update({'noupdate': True})
354 369 MercurialRepository._check_url(url, self.baseui)
355 clone(self.baseui, url, self.path, **opts)
370 mercurial.commands.clone(self.baseui, url, self.path, **opts)
356 371
357 372 # Don't try to create if we've already cloned repo
358 373 create = False
359 return localrepo.instance(self.baseui, self.path, create=create)
360 except (Abort, RepoError) as err:
374 return mercurial.localrepo.instance(self.baseui, self.path, create=create)
375 except (mercurial.error.Abort, mercurial.error.RepoError) as err:
361 376 if create:
362 377 msg = "Cannot create repository at %s. Original error was %s" \
363 378 % (self.path, err)
@@ -377,7 +392,7 b' class MercurialRepository(BaseRepository'
377 392
378 393 @LazyProperty
379 394 def contact(self):
380 return safe_unicode(get_contact(self._repo.ui.config)
395 return safe_unicode(mercurial.hgweb.common.get_contact(self._repo.ui.config)
381 396 or b'Unknown')
382 397
383 398 @LazyProperty
@@ -416,8 +431,8 b' class MercurialRepository(BaseRepository'
416 431 try:
417 432 if isinstance(revision, int):
418 433 return ascii_str(self._repo[revision].hex())
419 return ascii_str(scmutil.revsymbol(self._repo, revision).hex())
420 except (IndexError, ValueError, RepoLookupError, TypeError):
434 return ascii_str(mercurial.scmutil.revsymbol(self._repo, revision).hex())
435 except (IndexError, ValueError, mercurial.error.RepoLookupError, TypeError):
421 436 msg = ("Revision %s does not exist for %s" % (revision, self))
422 437 raise ChangesetDoesNotExistError(msg)
423 438 except (LookupError, ):
@@ -445,7 +460,7 b' class MercurialRepository(BaseRepository'
445 460 except LookupError:
446 461 msg = ("Ambiguous identifier %s:%s for %s" % (ref_type, ref_name, self.name))
447 462 raise ChangesetDoesNotExistError(msg)
448 except RepoLookupError:
463 except mercurial.error.RepoLookupError:
449 464 msg = ("Revision %s:%s does not exist for %s" % (ref_type, ref_name, self.name))
450 465 raise ChangesetDoesNotExistError(msg)
451 466 if revs:
@@ -533,7 +548,7 b' class MercurialRepository(BaseRepository'
533 548 revspec = b'all()'
534 549 if max_revisions:
535 550 revspec = b'limit(%s, %d)' % (revspec, max_revisions)
536 revisions = scmutil.revrange(self._repo, [revspec])
551 revisions = mercurial.scmutil.revrange(self._repo, [revspec])
537 552 else:
538 553 revisions = self.revisions
539 554
@@ -550,11 +565,10 b' class MercurialRepository(BaseRepository'
550 565 Tries to pull changes from external location.
551 566 """
552 567 url = self._get_url(url)
553 other = peer(self._repo, {}, url)
568 other = mercurial.hg.peer(self._repo, {}, url)
554 569 try:
555 from mercurial import exchange
556 exchange.pull(self._repo, other, heads=None, force=None)
557 except Abort as err:
570 mercurial.exchange.pull(self._repo, other, heads=None, force=None)
571 except mercurial.error.Abort as err:
558 572 # Propagate error but with vcs's type
559 573 raise RepositoryError(str(err))
560 574
@@ -581,7 +595,7 b' class MercurialRepository(BaseRepository'
581 595
582 596 config = self._repo.ui
583 597 if config_file:
584 config = ui.ui()
598 config = mercurial.ui.ui()
585 599 for path in config_file:
586 600 config.readconfig(path)
587 601 return config.config(section, name)
@@ -14,8 +14,8 b''
14 14
15 15 import logging
16 16
17 from mercurial import hg
18 from mercurial.wireprotoserver import sshserver
17 import mercurial.hg
18 import mercurial.wireprotoserver
19 19
20 20 from kallithea.lib.utils import make_ui
21 21 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
@@ -61,6 +61,6 b' class MercurialSshHandler(BaseSshHandler'
61 61 baseui.setconfig(b'hooks', b'pretxnopen._ssh_reject', b'python:kallithea.lib.hooks.rejectpush')
62 62 baseui.setconfig(b'hooks', b'prepushkey._ssh_reject', b'python:kallithea.lib.hooks.rejectpush')
63 63
64 repo = hg.repository(baseui, safe_bytes(self.db_repo.repo_full_path))
64 repo = mercurial.hg.repository(baseui, safe_bytes(self.db_repo.repo_full_path))
65 65 log.debug("Starting Mercurial sshserver for %s", self.db_repo.repo_full_path)
66 sshserver(baseui, repo).serve_forever()
66 mercurial.wireprotoserver.sshserver(baseui, repo).serve_forever()
@@ -1,7 +1,8 b''
1 import mercurial.merge
2
1 3 from kallithea.lib.vcs.backends.base import BaseWorkdir
2 4 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
3 5 from kallithea.lib.vcs.utils import ascii_bytes, ascii_str
4 from kallithea.lib.vcs.utils.hgcompat import hg_merge
5 6
6 7
7 8 class MercurialWorkdir(BaseWorkdir):
@@ -20,4 +21,4 b' class MercurialWorkdir(BaseWorkdir):'
20 21 raise BranchDoesNotExistError
21 22
22 23 raw_id = self.repository.branches[branch]
23 hg_merge.update(self.repository._repo, ascii_bytes(raw_id), False, False, None)
24 mercurial.merge.update(self.repository._repo, ascii_bytes(raw_id), False, False, None)
@@ -2,28 +2,12 b''
2 2 Mercurial libs compatibility
3 3 """
4 4
5 import mercurial
6 from mercurial import archival, config, demandimport, discovery, httppeer, localrepo
7 from mercurial import merge as hg_merge
8 from mercurial import obsutil, patch, scmutil, sshpeer, ui, unionrepo
9 from mercurial.commands import clone, nullid, pull
10 from mercurial.context import memctx, memfilectx
11 from mercurial.discovery import findcommonoutgoing
12 from mercurial.error import Abort, RepoError, RepoLookupError
13 from mercurial.hg import peer
14 from mercurial.hgweb import hgweb_mod
15 from mercurial.hgweb.common import get_contact
16 from mercurial.match import exact as match_exact
17 from mercurial.match import match
18 from mercurial.mdiff import diffopts
19 from mercurial.node import hex, nullrev
20 from mercurial.scmutil import revrange
21 from mercurial.tags import tag
22 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
23 from mercurial.util import url as hg_url
5 import mercurial.localrepo
24 6
25 7
26 # workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly, and test_archival failing
27 localrepo.localrepository._lfstatuswriters = [lambda *msg, **opts: None]
28 # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
29 localrepo.localrepository.lfstatus = False
8 def monkey_do():
9 """Apply some Mercurial monkey patching"""
10 # workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly, and test_archival failing
11 mercurial.localrepo.localrepository._lfstatuswriters = [lambda *msg, **opts: None]
12 # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
13 mercurial.localrepo.localrepository.lfstatus = False
@@ -235,7 +235,7 b' TODO: To be written...'
235 235 assert node.kind == NodeKind.FILE
236 236 assert node.content == readme
237 237
238 @mock.patch('kallithea.lib.vcs.backends.hg.repository.diffopts')
238 @mock.patch('mercurial.mdiff.diffopts')
239 239 def test_get_diff_does_not_sanitize_zero_context(self, mock_diffopts):
240 240 zero_context = 0
241 241
@@ -243,7 +243,7 b' TODO: To be written...'
243 243
244 244 mock_diffopts.assert_called_once_with(git=True, showfunc=True, ignorews=False, context=zero_context)
245 245
246 @mock.patch('kallithea.lib.vcs.backends.hg.repository.diffopts')
246 @mock.patch('mercurial.mdiff.diffopts')
247 247 def test_get_diff_sanitizes_negative_context(self, mock_diffopts):
248 248 negative_context = -10
249 249 zero_context = 0
General Comments 0
You need to be logged in to leave comments. Login now