##// END OF EJS Templates
hg: added compat for fetching revision using new hg 4.9 code
marcink -
r660:f4b31a7a default
parent child Browse files
Show More
@@ -32,11 +32,11 b' import vcsserver'
32 from vcsserver import exceptions
32 from vcsserver import exceptions
33 from vcsserver.base import RepoFactory, obfuscate_qs, raise_from_original
33 from vcsserver.base import RepoFactory, obfuscate_qs, raise_from_original
34 from vcsserver.hgcompat import (
34 from vcsserver.hgcompat import (
35 archival, bin, clone, config as hgconfig, diffopts, hex, revsymbol,
35 archival, bin, clone, config as hgconfig, diffopts, hex, get_ctx,
36 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler,
36 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler,
37 makepeer, instance, match, memctx, exchange, memfilectx, nullrev,
37 makepeer, instance, match, memctx, exchange, memfilectx, nullrev,
38 patch, peer, revrange, ui, hg_tag, Abort, LookupError, RepoError,
38 patch, peer, revrange, ui, hg_tag, Abort, LookupError, RepoError,
39 RepoLookupError, ProgrammingError, InterventionRequired, RequirementError)
39 RepoLookupError, InterventionRequired, RequirementError)
40
40
41 log = logging.getLogger(__name__)
41 log = logging.getLogger(__name__)
42
42
@@ -141,6 +141,9 b' class HgRemote(object):'
141 "_file_paths": self.ctx_list,
141 "_file_paths": self.ctx_list,
142 }
142 }
143
143
144 def _get_ctx(self, repo, ref):
145 return get_ctx(repo, ref)
146
144 @reraise_safe_exceptions
147 @reraise_safe_exceptions
145 def discover_hg_version(self):
148 def discover_hg_version(self):
146 from mercurial import util
149 from mercurial import util
@@ -257,74 +260,74 b' class HgRemote(object):'
257 @reraise_safe_exceptions
260 @reraise_safe_exceptions
258 def ctx_branch(self, wire, revision):
261 def ctx_branch(self, wire, revision):
259 repo = self._factory.repo(wire)
262 repo = self._factory.repo(wire)
260 ctx = repo[revision]
263 ctx = self._get_ctx(repo, revision)
261 return ctx.branch()
264 return ctx.branch()
262
265
263 @reraise_safe_exceptions
266 @reraise_safe_exceptions
264 def ctx_children(self, wire, revision):
267 def ctx_children(self, wire, revision):
265 repo = self._factory.repo(wire)
268 repo = self._factory.repo(wire)
266 ctx = repo[revision]
269 ctx = self._get_ctx(repo, revision)
267 return [child.rev() for child in ctx.children()]
270 return [child.rev() for child in ctx.children()]
268
271
269 @reraise_safe_exceptions
272 @reraise_safe_exceptions
270 def ctx_date(self, wire, revision):
273 def ctx_date(self, wire, revision):
271 repo = self._factory.repo(wire)
274 repo = self._factory.repo(wire)
272 ctx = repo[revision]
275 ctx = self._get_ctx(repo, revision)
273 return ctx.date()
276 return ctx.date()
274
277
275 @reraise_safe_exceptions
278 @reraise_safe_exceptions
276 def ctx_description(self, wire, revision):
279 def ctx_description(self, wire, revision):
277 repo = self._factory.repo(wire)
280 repo = self._factory.repo(wire)
278 ctx = repo[revision]
281 ctx = self._get_ctx(repo, revision)
279 return ctx.description()
282 return ctx.description()
280
283
281 @reraise_safe_exceptions
284 @reraise_safe_exceptions
282 def ctx_files(self, wire, revision):
285 def ctx_files(self, wire, revision):
283 repo = self._factory.repo(wire)
286 repo = self._factory.repo(wire)
284 ctx = repo[revision]
287 ctx = self._get_ctx(repo, revision)
285 return ctx.files()
288 return ctx.files()
286
289
287 @reraise_safe_exceptions
290 @reraise_safe_exceptions
288 def ctx_list(self, path, revision):
291 def ctx_list(self, path, revision):
289 repo = self._factory.repo(path)
292 repo = self._factory.repo(path)
290 ctx = repo[revision]
293 ctx = self._get_ctx(repo, revision)
291 return list(ctx)
294 return list(ctx)
292
295
293 @reraise_safe_exceptions
296 @reraise_safe_exceptions
294 def ctx_parents(self, wire, revision):
297 def ctx_parents(self, wire, revision):
295 repo = self._factory.repo(wire)
298 repo = self._factory.repo(wire)
296 ctx = repo[revision]
299 ctx = self._get_ctx(repo, revision)
297 return [parent.rev() for parent in ctx.parents()]
300 return [parent.rev() for parent in ctx.parents()]
298
301
299 @reraise_safe_exceptions
302 @reraise_safe_exceptions
300 def ctx_phase(self, wire, revision):
303 def ctx_phase(self, wire, revision):
301 repo = self._factory.repo(wire)
304 repo = self._factory.repo(wire)
302 ctx = repo[revision]
305 ctx = self._get_ctx(repo, revision)
303 # public=0, draft=1, secret=3
306 # public=0, draft=1, secret=3
304 return ctx.phase()
307 return ctx.phase()
305
308
306 @reraise_safe_exceptions
309 @reraise_safe_exceptions
307 def ctx_obsolete(self, wire, revision):
310 def ctx_obsolete(self, wire, revision):
308 repo = self._factory.repo(wire)
311 repo = self._factory.repo(wire)
309 ctx = repo[revision]
312 ctx = self._get_ctx(repo, revision)
310 return ctx.obsolete()
313 return ctx.obsolete()
311
314
312 @reraise_safe_exceptions
315 @reraise_safe_exceptions
313 def ctx_hidden(self, wire, revision):
316 def ctx_hidden(self, wire, revision):
314 repo = self._factory.repo(wire)
317 repo = self._factory.repo(wire)
315 ctx = repo[revision]
318 ctx = self._get_ctx(repo, revision)
316 return ctx.hidden()
319 return ctx.hidden()
317
320
318 @reraise_safe_exceptions
321 @reraise_safe_exceptions
319 def ctx_substate(self, wire, revision):
322 def ctx_substate(self, wire, revision):
320 repo = self._factory.repo(wire)
323 repo = self._factory.repo(wire)
321 ctx = repo[revision]
324 ctx = self._get_ctx(repo, revision)
322 return ctx.substate
325 return ctx.substate
323
326
324 @reraise_safe_exceptions
327 @reraise_safe_exceptions
325 def ctx_status(self, wire, revision):
328 def ctx_status(self, wire, revision):
326 repo = self._factory.repo(wire)
329 repo = self._factory.repo(wire)
327 ctx = repo[revision]
330 ctx = self._get_ctx(repo, revision)
328 status = repo[ctx.p1().node()].status(other=ctx.node())
331 status = repo[ctx.p1().node()].status(other=ctx.node())
329 # object of status (odd, custom named tuple in mercurial) is not
332 # object of status (odd, custom named tuple in mercurial) is not
330 # correctly serializable, we make it a list, as the underling
333 # correctly serializable, we make it a list, as the underling
@@ -334,7 +337,7 b' class HgRemote(object):'
334 @reraise_safe_exceptions
337 @reraise_safe_exceptions
335 def ctx_user(self, wire, revision):
338 def ctx_user(self, wire, revision):
336 repo = self._factory.repo(wire)
339 repo = self._factory.repo(wire)
337 ctx = repo[revision]
340 ctx = self._get_ctx(repo, revision)
338 return ctx.user()
341 return ctx.user()
339
342
340 @reraise_safe_exceptions
343 @reraise_safe_exceptions
@@ -424,7 +427,7 b' class HgRemote(object):'
424 def node_history(self, wire, revision, path, limit):
427 def node_history(self, wire, revision, path, limit):
425 repo = self._factory.repo(wire)
428 repo = self._factory.repo(wire)
426
429
427 ctx = repo[revision]
430 ctx = self._get_ctx(repo, revision)
428 fctx = ctx.filectx(path)
431 fctx = ctx.filectx(path)
429
432
430 def history_iter():
433 def history_iter():
@@ -445,7 +448,7 b' class HgRemote(object):'
445 @reraise_safe_exceptions
448 @reraise_safe_exceptions
446 def node_history_untill(self, wire, revision, path, limit):
449 def node_history_untill(self, wire, revision, path, limit):
447 repo = self._factory.repo(wire)
450 repo = self._factory.repo(wire)
448 ctx = repo[revision]
451 ctx = self._get_ctx(repo, revision)
449 fctx = ctx.filectx(path)
452 fctx = ctx.filectx(path)
450
453
451 file_log = list(fctx.filelog())
454 file_log = list(fctx.filelog())
@@ -458,7 +461,7 b' class HgRemote(object):'
458 @reraise_safe_exceptions
461 @reraise_safe_exceptions
459 def fctx_annotate(self, wire, revision, path):
462 def fctx_annotate(self, wire, revision, path):
460 repo = self._factory.repo(wire)
463 repo = self._factory.repo(wire)
461 ctx = repo[revision]
464 ctx = self._get_ctx(repo, revision)
462 fctx = ctx.filectx(path)
465 fctx = ctx.filectx(path)
463
466
464 result = []
467 result = []
@@ -472,21 +475,21 b' class HgRemote(object):'
472 @reraise_safe_exceptions
475 @reraise_safe_exceptions
473 def fctx_data(self, wire, revision, path):
476 def fctx_data(self, wire, revision, path):
474 repo = self._factory.repo(wire)
477 repo = self._factory.repo(wire)
475 ctx = repo[revision]
478 ctx = self._get_ctx(repo, revision)
476 fctx = ctx.filectx(path)
479 fctx = ctx.filectx(path)
477 return fctx.data()
480 return fctx.data()
478
481
479 @reraise_safe_exceptions
482 @reraise_safe_exceptions
480 def fctx_flags(self, wire, revision, path):
483 def fctx_flags(self, wire, revision, path):
481 repo = self._factory.repo(wire)
484 repo = self._factory.repo(wire)
482 ctx = repo[revision]
485 ctx = self._get_ctx(repo, revision)
483 fctx = ctx.filectx(path)
486 fctx = ctx.filectx(path)
484 return fctx.flags()
487 return fctx.flags()
485
488
486 @reraise_safe_exceptions
489 @reraise_safe_exceptions
487 def fctx_size(self, wire, revision, path):
490 def fctx_size(self, wire, revision, path):
488 repo = self._factory.repo(wire)
491 repo = self._factory.repo(wire)
489 ctx = repo[revision]
492 ctx = self._get_ctx(repo, revision)
490 fctx = ctx.filectx(path)
493 fctx = ctx.filectx(path)
491 return fctx.size()
494 return fctx.size()
492
495
@@ -555,12 +558,7 b' class HgRemote(object):'
555 if revision <= 0:
558 if revision <= 0:
556 revision = revision + -1
559 revision = revision + -1
557 try:
560 try:
558 try:
561 ctx = self._get_ctx(repo, revision)
559 ctx = repo[revision]
560 except ProgrammingError:
561 # we're unable to find the rev using a regular lookup, we fallback
562 # to slower, but backward compat revsymbol usage
563 ctx = revsymbol(repo, revision)
564 except (TypeError, RepoLookupError) as e:
562 except (TypeError, RepoLookupError) as e:
565 e._org_exc_tb = traceback.format_exc()
563 e._org_exc_tb = traceback.format_exc()
566 raise exceptions.LookupException(e)(revision)
564 raise exceptions.LookupException(e)(revision)
@@ -611,7 +609,7 b' class HgRemote(object):'
611 @reraise_safe_exceptions
609 @reraise_safe_exceptions
612 def revision(self, wire, rev):
610 def revision(self, wire, rev):
613 repo = self._factory.repo(wire)
611 repo = self._factory.repo(wire)
614 ctx = repo[rev]
612 ctx = self._get_ctx(repo, rev)
615 return ctx.rev()
613 return ctx.rev()
616
614
617 @reraise_safe_exceptions
615 @reraise_safe_exceptions
@@ -652,7 +650,7 b' class HgRemote(object):'
652 @reraise_safe_exceptions
650 @reraise_safe_exceptions
653 def strip(self, wire, revision, update, backup):
651 def strip(self, wire, revision, update, backup):
654 repo = self._factory.repo(wire)
652 repo = self._factory.repo(wire)
655 ctx = repo[revision]
653 ctx = self._get_ctx(repo, revision)
656 hgext_strip(
654 hgext_strip(
657 repo.baseui, repo, ctx.node(), update=update, backup=backup)
655 repo.baseui, repo, ctx.node(), update=update, backup=backup)
658
656
@@ -675,7 +673,7 b' class HgRemote(object):'
675 def tag(self, wire, name, revision, message, local, user,
673 def tag(self, wire, name, revision, message, local, user,
676 tag_time, tag_timezone):
674 tag_time, tag_timezone):
677 repo = self._factory.repo(wire)
675 repo = self._factory.repo(wire)
678 ctx = repo[revision]
676 ctx = self._get_ctx(repo, revision)
679 node = ctx.node()
677 node = ctx.node()
680
678
681 date = (tag_time, tag_timezone)
679 date = (tag_time, tag_timezone)
@@ -61,3 +61,14 b' from hgext import largefiles'
61 # those authnadlers are patched for python 2.6.5 bug an
61 # those authnadlers are patched for python 2.6.5 bug an
62 # infinit looping when given invalid resources
62 # infinit looping when given invalid resources
63 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
63 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
64
65
66 def get_ctx(repo, ref):
67 try:
68 ctx = repo[ref]
69 except ProgrammingError:
70 # we're unable to find the rev using a regular lookup, we fallback
71 # to slower, but backward compat revsymbol usage
72 ctx = revsymbol(repo, ref)
73
74 return ctx
@@ -33,6 +33,7 b' import mercurial.node'
33 import simplejson as json
33 import simplejson as json
34
34
35 from vcsserver import exceptions, subprocessio, settings
35 from vcsserver import exceptions, subprocessio, settings
36 from vcsserver.hgcompat import get_ctx
36
37
37 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
38
39
@@ -177,11 +178,11 b' def _rev_range_hash(repo, node, check_he'
177
178
178 commits = []
179 commits = []
179 revs = []
180 revs = []
180 start = repo[node].rev()
181 start = get_ctx(repo, node).rev()
181 end = len(repo)
182 end = len(repo)
182 for rev in range(start, end):
183 for rev in range(start, end):
183 revs.append(rev)
184 revs.append(rev)
184 ctx = repo[rev]
185 ctx = get_ctx(repo, rev)
185 commit_id = mercurial.node.hex(ctx.node())
186 commit_id = mercurial.node.hex(ctx.node())
186 branch = ctx.branch()
187 branch = ctx.branch()
187 commits.append((commit_id, branch))
188 commits.append((commit_id, branch))
@@ -204,12 +205,12 b' def _check_heads(repo, start, end, commi'
204 parents.add(p)
205 parents.add(p)
205
206
206 for p in parents:
207 for p in parents:
207 branch = repo[p].branch()
208 branch = get_ctx(repo, p).branch()
208 # The heads descending from that parent, on the same branch
209 # The heads descending from that parent, on the same branch
209 parent_heads = set([p])
210 parent_heads = set([p])
210 reachable = set([p])
211 reachable = set([p])
211 for x in xrange(p + 1, end):
212 for x in xrange(p + 1, end):
212 if repo[x].branch() != branch:
213 if get_ctx(repo, x).branch() != branch:
213 continue
214 continue
214 for pp in changelog.parentrevs(x):
215 for pp in changelog.parentrevs(x):
215 if pp in reachable:
216 if pp in reachable:
@@ -385,7 +386,7 b' def post_push_ssh(ui, repo, node, **kwar'
385 def key_push(ui, repo, **kwargs):
386 def key_push(ui, repo, **kwargs):
386 if kwargs['new'] != '0' and kwargs['namespace'] == 'bookmarks':
387 if kwargs['new'] != '0' and kwargs['namespace'] == 'bookmarks':
387 # store new bookmarks in our UI object propagated later to post_push
388 # store new bookmarks in our UI object propagated later to post_push
388 ui._rc_pushkey_branches = repo[kwargs['key']].bookmarks()
389 ui._rc_pushkey_branches = get_ctx(repo, kwargs['key']).bookmarks()
389 return
390 return
390
391
391
392
General Comments 0
You need to be logged in to leave comments. Login now