~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to branchhistory.py

  • Committer: Aaron Bentley
  • Date: 2006-02-01 04:28:35 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20060201042835-0ff0d7af60662f20
Fixed graph-ancestry

Show diffs side-by-side

added added

removed removed

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