~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to branchhistory.py

  • Committer: Aaron Bentley
  • Date: 2007-06-11 05:08:34 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20070611050834-wcbta2pfitcuopku
fix long-line detection

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from bzrlib import errors
1
2
from bzrlib.branch import Branch
2
3
from bzrlib.config import extract_email_address
3
4
from bzrtools import short_committer
6
7
    b = Branch.open_containing(branch)[0]
7
8
    descriptor = None
8
9
    start = None
9
 
    for revno, revision in iter_revisiondata(b):
10
 
        new_descriptor = (revision.committer, 
11
 
                          revision.properties.get('branch-nick'))
12
 
        if descriptor is None:
 
10
    b.repository.lock_read()
 
11
    try:
 
12
        for revno, revision in iter_revisiondata(b):
 
13
            new_descriptor = (revision.committer,
 
14
                              revision.properties.get('branch-nick'))
 
15
            if descriptor is None:
 
16
                descriptor = new_descriptor
 
17
            if start is None:
 
18
                start = revno
 
19
            if branch_change(descriptor, new_descriptor):
 
20
                print_info(descriptor, start, revno - 1)
 
21
                start = revno
13
22
            descriptor = new_descriptor
14
 
        if start is None:
15
 
            start = revno
16
 
        if branch_change(descriptor, new_descriptor):
17
 
            print_info(descriptor, start, revno - 1)
18
 
            start = revno
19
 
        descriptor = new_descriptor
20
 
    print_info(descriptor, start, revno)
 
23
        print_info(descriptor, start, revno)
 
24
    finally:
 
25
        b.repository.unlock()
21
26
 
22
27
def branch_change(old_descriptor, new_descriptor):
 
28
    try:
 
29
        old_email = extract_email_address(old_descriptor[0])
 
30
    except errors.NoEmailInUsername:
 
31
        old_email = None
 
32
    try:
 
33
        new_email = extract_email_address(new_descriptor[0])
 
34
    except errors.NoEmailInUsername:
 
35
        new_email = None
23
36
    if old_descriptor == new_descriptor:
24
37
        return False
25
38
    elif None not in (old_descriptor[1], new_descriptor[1]) and \
28
41
    elif short_committer(old_descriptor[0]) ==\
29
42
        short_committer(new_descriptor[0]):
30
43
        return False
31
 
    elif old_descriptor[0].strip(' ') == \
32
 
        extract_email_address(new_descriptor[0]):
 
44
    elif old_descriptor[0].strip(' ') == new_email:
33
45
        return False
34
 
    elif new_descriptor[0].strip(' ') == \
35
 
        extract_email_address(old_descriptor[0]):
 
46
    elif new_descriptor[0].strip(' ') == old_email:
36
47
        return False
37
48
    else:
38
49
        return True