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