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.branch import Branch
17
from bzrlib import Branch
18
18
from bzrlib.commands import Command
19
19
from bzrlib.errors import BzrCommandError
22
from progress import show_progress
27
26
def iter_anno_data(branch, file_id):
28
max_revno = branch.revno()
29
later_revision = max_revno
27
later_revision = branch.revno()
28
q = range(branch.revno())
33
next_tree = branch.working_tree()
34
later_text_sha1 = next_tree.get_file_sha1(file_id)
30
later_text_id = branch.basis_tree().inventory[file_id].text_id
38
cur_tree = branch.revision_tree(branch.get_rev_id(revno))
34
cur_tree = branch.revision_tree(branch.lookup_revision(revno))
39
35
if file_id not in cur_tree.inventory:
42
text_sha1 = cur_tree.get_file_sha1(file_id)
43
if text_sha1 != later_text_sha1:
44
patch = get_patch(branch, cur_tree, next_tree, file_id)
46
if revno == max_revno:
49
display_id = str(revno+1)
50
yield display_id, patch.iter_inserted(), patch
38
text_id = cur_tree.inventory[file_id].text_id
39
if text_id != later_text_id:
40
patch = get_patch(branch, revno, later_revision, file_id)
41
yield revno, patch.iter_inserted(), patch
51
42
later_revision = revno
52
later_text_sha1 = text_sha1
43
later_text_id = text_id
53
44
yield progress.Progress("revisions", i)
55
def get_patch(branch, old_tree, new_tree, file_id):
46
def get_patch(branch, old_revno, new_revno, file_id):
47
old_tree = branch.revision_tree(branch.lookup_revision(old_revno))
48
new_tree = branch.revision_tree(branch.lookup_revision(new_revno))
56
49
if file_id in old_tree.inventory:
57
50
old_file = old_tree.get_file(file_id).readlines()
67
60
def run(self, filename):
68
61
if not os.path.exists(filename):
69
62
raise BzrCommandError("The file %s does not exist." % filename)
70
branch,relpath = (Branch.open_containing(filename))
71
file_id = branch.working_tree().path2id(relpath)
63
branch = (Branch(filename))
64
file_id = branch.working_tree().path2id(branch.relpath(filename))
72
65
if file_id is None:
73
66
raise BzrCommandError("The file %s is not versioned." % filename)
74
67
lines = branch.basis_tree().get_file(file_id)