/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

Use new context stuff.

Show diffs side-by-side

added added

removed removed

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