/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/stats/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2017-08-31 05:37:51 UTC
  • mfrom: (6754.8.15 lock-context)
  • Revision ID: jelmer@jelmer.uk-20170831053751-9pem67h9hu2p8lg2
Merge lp:~jelmer/brz/lock-context.

Show diffs side-by-side

added added

removed removed

Lines of Context:
267
267
            if len(revision) > 1:
268
268
                alternate_rev = revision[1].in_history(a_branch).rev_id
269
269
 
270
 
        a_branch.lock_read()
271
 
        try:
 
270
        with a_branch.lock_read():
272
271
            if alternate_rev:
273
272
                info = get_diff_info(a_branch.repository, last_rev,
274
273
                                     alternate_rev)
275
274
            else:
276
275
                info = get_info(a_branch.repository, last_rev)
277
 
        finally:
278
 
            a_branch.unlock()
279
276
        if show_class:
280
277
            def fetch_class_stats(revs):
281
278
                return gather_class_stats(a_branch.repository, revs)
301
298
            a_branch = wt.branch
302
299
            last_rev = wt.last_revision()
303
300
 
304
 
        a_branch.lock_read()
305
 
        try:
 
301
        with a_branch.lock_read():
306
302
            graph = a_branch.repository.get_graph()
307
303
            revno = 0
308
304
            cur_parents = 0
313
309
                if depth == 0:
314
310
                    revno += 1
315
311
                    self.outf.write('%4d, %4d\n' % (revno, cur_parents))
316
 
        finally:
317
 
            a_branch.unlock()
318
312
 
319
313
 
320
314
def gather_class_stats(repository, revs):
322
316
    total = 0
323
317
    pb = ui.ui_factory.nested_progress_bar()
324
318
    try:
325
 
        repository.lock_read()
326
 
        try:
 
319
        with repository.lock_read():
327
320
            i = 0
328
321
            for delta in repository.get_deltas_for_revisions(revs):
329
322
                pb.update("classifying commits", i, len(revs))
333
326
                    ret[c] += 1
334
327
                    total += 1
335
328
                i += 1
336
 
        finally:
337
 
            repository.unlock()
338
329
    finally:
339
330
        pb.finished()
340
331
    return ret, total
371
362
           "translation": {},
372
363
           None: {}
373
364
           }
374
 
    repository.lock_read()
375
 
    try:
 
365
    with repository.lock_read():
376
366
        graph = repository.get_graph()
377
367
        ancestry = [r for (r, ps) in graph.iter_ancestry([revid])
378
368
                    if ps is not None and r != NULL_REVISION]
392
382
                        ret[c][author] += 1
393
383
        finally:
394
384
            pb.finished()
395
 
    finally:
396
 
        repository.unlock()
397
385
    def sort_class(name):
398
386
        return [author
399
387
            for author, _  in sorted(ret[name].items(), key=classify_key)]
421
409
        if revision is not None:
422
410
            last_rev = revision[0].in_history(a_branch).rev_id
423
411
 
424
 
        a_branch.lock_read()
425
 
        try:
 
412
        with a_branch.lock_read():
426
413
            credits = find_credits(a_branch.repository, last_rev)
427
414
            display_credits(credits, self.outf)
428
 
        finally:
429
 
            a_branch.unlock()