~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to annotate.py

  • Committer: Aaron Bentley
  • Date: 2005-09-22 23:30:34 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20050922233034-0bb63c8bef90f19a
Updated NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#    You should have received a copy of the GNU General Public License
15
15
#    along with this program; if not, write to the Free Software
16
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
from bzrlib import Branch
 
17
from bzrlib.branch import Branch
18
18
from bzrlib.commands import Command
 
19
from bzrlib.errors import BzrCommandError
19
20
import os
20
21
import progress
 
22
from progress import show_progress
21
23
import patches
22
24
import difflib
23
25
import sys
30
32
    i = 0
31
33
    for revno in q:
32
34
        i += 1
33
 
        cur_tree = branch.revision_tree(branch.lookup_revision(revno))
 
35
        cur_tree = branch.revision_tree(branch.get_rev_id(revno))
34
36
        if file_id not in cur_tree.inventory:
35
37
            text_id = None
36
38
        else:
37
39
            text_id = cur_tree.inventory[file_id].text_id
38
40
        if text_id != later_text_id:
39
41
            patch = get_patch(branch, revno, later_revision, file_id)
40
 
            yield revno, patch.iter_inserted(), patch
 
42
            yield revno+1, patch.iter_inserted(), patch
41
43
            later_revision = revno
42
44
            later_text_id = text_id
43
45
        yield progress.Progress("revisions", i)
44
46
 
45
47
def get_patch(branch, old_revno, new_revno, file_id):
46
 
    old_tree = branch.revision_tree(branch.lookup_revision(old_revno))
47
 
    new_tree = branch.revision_tree(branch.lookup_revision(new_revno))
 
48
    old_tree = branch.revision_tree(branch.get_rev_id(old_revno))
 
49
    new_tree = branch.revision_tree(branch.get_rev_id(new_revno))
48
50
    if file_id in old_tree.inventory:
49
51
        old_file = old_tree.get_file(file_id).readlines()
50
52
    else:
59
61
    def run(self, filename):
60
62
        if not os.path.exists(filename):
61
63
            raise BzrCommandError("The file %s does not exist." % filename)
62
 
        branch = (Branch(filename))
63
 
        file_id = branch.working_tree().path2id(filename)
 
64
        branch = (Branch.open_containing(filename))
 
65
        file_id = branch.working_tree().path2id(branch.relpath(filename))
64
66
        if file_id is None:
65
67
            raise BzrCommandError("The file %s is not versioned." % filename)
66
68
        lines = branch.basis_tree().get_file(file_id)
71
73
            for result in iter_annotate_file(lines, anno_d_iter):
72
74
                if isinstance(result, progress.Progress):
73
75
                    result.total = total
74
 
                    progress_bar(result)
 
76
                    show_progress(progress_bar, result)
75
77
                else:
76
78
                    anno_lines = result
77
79
        finally: