~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Martin Pool
  • Date: 2005-05-06 03:20:15 UTC
  • Revision ID: mbp@sourcefrog.net-20050506032014-decf4918803147d2
- split out notes on storing annotations in revfiles

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
 
19
 
def show_status(branch, show_unchanged=False,
20
 
                specific_files=None,
21
 
                show_ids=False,
22
 
                to_file=None):
23
 
    """Display single-line status for non-ignored working files.
24
 
 
25
 
    show_all
26
 
        If true, show unmodified files too.
27
 
 
28
 
    specific_files
29
 
        If set, only show the status of files in this list.
30
 
 
31
 
    to_file
32
 
        If set, write to this file (default stdout.)
 
19
def find_modified(branch):
 
20
    """Return a list of files that have been modified in the working copy.
 
21
 
 
22
    This does not consider renames and does not include files added or
 
23
    deleted.
 
24
 
 
25
    Each modified file is returned as (PATH, ENTRY).
33
26
    """
34
 
    import sys
35
 
    from bzrlib.diff import compare_trees
 
27
    import cache
36
28
 
37
 
    if to_file == None:
38
 
        to_file = sys.stdout
 
29
    inv = branch.read_working_inventory()
 
30
    cc = cache.update_cache(branch, inv)
 
31
    basis_inv = branch.basis_tree().inventory
39
32
    
40
 
    branch.lock_read()
41
 
    try:
42
 
 
43
 
        old = branch.basis_tree()
44
 
        new = branch.working_tree()
45
 
 
46
 
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
47
 
                              specific_files=specific_files)
48
 
 
49
 
        delta.show(to_file,
50
 
                   show_ids=show_ids,
51
 
                   show_unchanged=show_unchanged)
52
 
 
53
 
        unknowns = new.unknowns()
54
 
        done_header = False
55
 
        for path in unknowns:
56
 
            # FIXME: Should also match if the unknown file is within a
57
 
            # specified directory.
58
 
            if specific_files:
59
 
                if path not in specific_files:
60
 
                    continue
61
 
            if not done_header:
62
 
                print >>to_file, 'unknown:'
63
 
                done_header = True
64
 
            print >>to_file, ' ', path
65
 
    finally:
66
 
        branch.unlock()
 
33
    for path, entry in inv.iter_entries():
 
34
        if entry.kind != 'file':
 
35
            continue
 
36
        
 
37
        file_id = entry.file_id
 
38
        ce = cc.get(file_id)
 
39
        if not ce:
 
40
            continue                    # not in working dir
 
41
 
 
42
        if file_id not in basis_inv:
 
43
            continue                    # newly added
 
44
 
 
45
        old_entry = basis_inv[file_id]
 
46
 
 
47
        if (old_entry.text_size == ce[3]
 
48
            and old_entry.text_sha1 == ce[1]):
 
49
            continue
 
50
 
 
51
        yield path, entry
67
52