~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Robert Collins
  • Date: 2005-09-28 05:25:54 UTC
  • mfrom: (1185.1.42)
  • mto: (1092.2.18)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050928052554-beb985505f77ea6a
update symlink branch to integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
                specific_files=None,
21
21
                show_ids=False,
22
22
                to_file=None,
23
 
                show_pending=True):
 
23
                show_pending=True,
 
24
                revision=None):
24
25
    """Display status for non-ignored working files.
25
26
 
26
27
    show_unchanged
37
38
 
38
39
    show_pending
39
40
        If set, write pending merges.
 
41
 
 
42
    revision
 
43
        If None the compare latest revision with working tree
 
44
        If one revision show compared it with working tree.
 
45
        If two revisions show status between first and second.
40
46
    """
41
47
    import sys
42
48
    from bzrlib.delta import compare_trees
46
52
    
47
53
    branch.lock_read()
48
54
    try:
49
 
 
50
 
        old = branch.basis_tree()
51
 
        new = branch.working_tree()
 
55
        new_is_working_tree = True
 
56
        if revision is None:
 
57
            old = branch.basis_tree()
 
58
            new = branch.working_tree()
 
59
        elif len(revision) > 0:
 
60
            try:
 
61
                rev_id = revision[0].in_history(branch).rev_id
 
62
                old = branch.revision_tree(rev_id)
 
63
            except NoSuchRevision, e:
 
64
                raise BzrCommandError(str(e))
 
65
            if len(revision) > 1:
 
66
                try:
 
67
                    rev_id = revision[1].in_history(branch).rev_id
 
68
                    new = branch.revision_tree(rev_id)
 
69
                    new_is_working_tree = False
 
70
                except NoSuchRevision, e:
 
71
                    raise BzrCommandError(str(e))
 
72
            else:
 
73
                new = branch.working_tree()
 
74
                
52
75
 
53
76
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
54
77
                              specific_files=specific_files)
57
80
                   show_ids=show_ids,
58
81
                   show_unchanged=show_unchanged)
59
82
 
60
 
        unknowns = new.unknowns()
61
 
        done_header = False
62
 
        for path in unknowns:
63
 
            # FIXME: Should also match if the unknown file is within a
64
 
            # specified directory.
65
 
            if specific_files:
66
 
                if path not in specific_files:
67
 
                    continue
68
 
            if not done_header:
69
 
                print >>to_file, 'unknown:'
70
 
                done_header = True
71
 
            print >>to_file, ' ', path
72
 
        if show_pending and len(branch.pending_merges()) > 0:
73
 
            print >>to_file, 'pending merges:'
74
 
            for merge in branch.pending_merges():
75
 
                print >> to_file, ' ', merge
 
83
        if new_is_working_tree:
 
84
            unknowns = new.unknowns()
 
85
            done_header = False
 
86
            for path in unknowns:
 
87
                # FIXME: Should also match if the unknown file is within a
 
88
                # specified directory.
 
89
                if specific_files:
 
90
                    if path not in specific_files:
 
91
                        continue
 
92
                if not done_header:
 
93
                    print >>to_file, 'unknown:'
 
94
                    done_header = True
 
95
                print >>to_file, ' ', path
 
96
            if show_pending and len(branch.pending_merges()) > 0:
 
97
                print >>to_file, 'pending merges:'
 
98
                for merge in branch.pending_merges():
 
99
                    print >> to_file, ' ', merge
76
100
    finally:
77
101
        branch.unlock()
78
102