##// END OF EJS Templates
Mercurial: fixed lookup for hg 4.9
marcink -
r657:377e31e9 default
parent child Browse files
Show More
@@ -20,6 +20,7 b' import logging'
20 import stat
20 import stat
21 import urllib
21 import urllib
22 import urllib2
22 import urllib2
23 import traceback
23
24
24 from hgext import largefiles, rebase
25 from hgext import largefiles, rebase
25 from hgext.strip import strip as hgext_strip
26 from hgext.strip import strip as hgext_strip
@@ -31,11 +32,11 b' import vcsserver'
31 from vcsserver import exceptions
32 from vcsserver import exceptions
32 from vcsserver.base import RepoFactory, obfuscate_qs, raise_from_original
33 from vcsserver.base import RepoFactory, obfuscate_qs, raise_from_original
33 from vcsserver.hgcompat import (
34 from vcsserver.hgcompat import (
34 archival, bin, clone, config as hgconfig, diffopts, hex,
35 archival, bin, clone, config as hgconfig, diffopts, hex, revsymbol,
35 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler,
36 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler,
36 makepeer, instance, match, memctx, exchange, memfilectx, nullrev,
37 makepeer, instance, match, memctx, exchange, memfilectx, nullrev,
37 patch, peer, revrange, ui, hg_tag, Abort, LookupError, RepoError,
38 patch, peer, revrange, ui, hg_tag, Abort, LookupError, RepoError,
38 RepoLookupError, InterventionRequired, RequirementError)
39 RepoLookupError, ProgrammingError, InterventionRequired, RequirementError)
39
40
40 log = logging.getLogger(__name__)
41 log = logging.getLogger(__name__)
41
42
@@ -55,6 +56,9 b' def make_ui_from_config(repo_config):'
55 baseui.setconfig('ui', 'quiet', 'true')
56 baseui.setconfig('ui', 'quiet', 'true')
56
57
57 baseui.setconfig('ui', 'paginate', 'never')
58 baseui.setconfig('ui', 'paginate', 'never')
59 # for better Error reporting of Mercurial
60 baseui.setconfig('ui', 'message-output', 'stderr')
61
58 # force mercurial to only use 1 thread, otherwise it may try to set a
62 # force mercurial to only use 1 thread, otherwise it may try to set a
59 # signal in a non-main thread, thus generating a ValueError.
63 # signal in a non-main thread, thus generating a ValueError.
60 baseui.setconfig('worker', 'numcpus', 1)
64 baseui.setconfig('worker', 'numcpus', 1)
@@ -266,15 +270,6 b' class HgRemote(object):'
266 ctx = repo[revision]
270 ctx = repo[revision]
267 return ctx.description()
271 return ctx.description()
268
272
269 # @reraise_safe_exceptions
270 # def ctx_diff(
271 # self, wire, revision, git=True, ignore_whitespace=True, context=3):
272 # repo = self._factory.repo(wire)
273 # ctx = repo[revision]
274 # result = ctx.diff(
275 # git=git, ignore_whitespace=ignore_whitespace, context=context)
276 # return list(result)
277
278 @reraise_safe_exceptions
273 @reraise_safe_exceptions
279 def ctx_files(self, wire, revision):
274 def ctx_files(self, wire, revision):
280 repo = self._factory.repo(wire)
275 repo = self._factory.repo(wire)
@@ -490,8 +485,9 b' class HgRemote(object):'
490 @reraise_safe_exceptions
485 @reraise_safe_exceptions
491 def get_all_commit_ids(self, wire, name):
486 def get_all_commit_ids(self, wire, name):
492 repo = self._factory.repo(wire)
487 repo = self._factory.repo(wire)
493 revs = repo.filtered(name).changelog.index
488 repo = repo.filtered(name)
494 return map(lambda x: hex(x[7]), revs)[:-1]
489 revs = map(lambda x: hex(x[7]), repo.changelog.index)
490 return revs
495
491
496 @reraise_safe_exceptions
492 @reraise_safe_exceptions
497 def get_config_value(self, wire, section, name, untrusted=False):
493 def get_config_value(self, wire, section, name, untrusted=False):
@@ -544,22 +540,24 b' class HgRemote(object):'
544
540
545 if isinstance(revision, int):
541 if isinstance(revision, int):
546 # NOTE(marcink):
542 # NOTE(marcink):
547 # since Mercurial doesn't support indexes properly
543 # since Mercurial doesn't support negative indexes properly
548 # we need to shift accordingly by one to get proper index, e.g
544 # we need to shift accordingly by one to get proper index, e.g
549 # repo[-1] => repo[-2]
545 # repo[-1] => repo[-2]
550 # repo[0] => repo[-1]
546 # repo[0] => repo[-1]
551 # repo[1] => repo[2] we also never call repo[0] because
552 # it's actually second commit
553 if revision <= 0:
547 if revision <= 0:
554 revision = revision + -1
548 revision = revision + -1
555 else:
549 try:
556 revision = revision + 1
557
558 try:
550 try:
559 ctx = repo[revision]
551 ctx = repo[revision]
560 except RepoLookupError as e:
552 except ProgrammingError:
553 # we're unable to find the rev using a regular lookup, we fallback
554 # to slower, but backward compat revsymbol usage
555 ctx = revsymbol(repo, revision)
556 except (TypeError, RepoLookupError) as e:
557 e._org_exc_tb = traceback.format_exc()
561 raise exceptions.LookupException(e)(revision)
558 raise exceptions.LookupException(e)(revision)
562 except LookupError as e:
559 except LookupError as e:
560 e._org_exc_tb = traceback.format_exc()
563 raise exceptions.LookupException(e)(e.name)
561 raise exceptions.LookupException(e)(e.name)
564
562
565 if not both:
563 if not both:
@@ -42,7 +42,7 b' from mercurial.commands import clone, nu'
42 from mercurial.context import memctx, memfilectx
42 from mercurial.context import memctx, memfilectx
43 from mercurial.error import (
43 from mercurial.error import (
44 LookupError, RepoError, RepoLookupError, Abort, InterventionRequired,
44 LookupError, RepoError, RepoLookupError, Abort, InterventionRequired,
45 RequirementError)
45 RequirementError, ProgrammingError)
46 from mercurial.hgweb import hgweb_mod
46 from mercurial.hgweb import hgweb_mod
47 from mercurial.localrepo import instance
47 from mercurial.localrepo import instance
48 from mercurial.match import match
48 from mercurial.match import match
@@ -53,7 +53,7 b' from mercurial.discovery import findcomm'
53 from mercurial.hg import peer
53 from mercurial.hg import peer
54 from mercurial.httppeer import makepeer
54 from mercurial.httppeer import makepeer
55 from mercurial.util import url as hg_url
55 from mercurial.util import url as hg_url
56 from mercurial.scmutil import revrange
56 from mercurial.scmutil import revrange, revsymbol
57 from mercurial.node import nullrev
57 from mercurial.node import nullrev
58 from mercurial import exchange
58 from mercurial import exchange
59 from hgext import largefiles
59 from hgext import largefiles
General Comments 0
You need to be logged in to leave comments. Login now