~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: John Arbash Meinel
  • Date: 2005-09-15 21:35:53 UTC
  • mfrom: (907.1.57)
  • mto: (1393.2.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050915213552-a6c83a5ef1e20897
(broken) Transport work is merged in. Tests do not pass yet.

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,
24
 
                revision=None):
 
23
                show_pending=True):
25
24
    """Display status for non-ignored working files.
26
25
 
27
26
    show_unchanged
38
37
 
39
38
    show_pending
40
39
        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.
46
40
    """
47
41
    import sys
48
 
    from bzrlib.osutils import is_inside_any
49
42
    from bzrlib.delta import compare_trees
50
43
 
51
44
    if to_file == None:
53
46
    
54
47
    branch.lock_read()
55
48
    try:
56
 
        new_is_working_tree = True
57
 
        if revision is None:
58
 
            old = branch.basis_tree()
59
 
            new = branch.working_tree()
60
 
        elif len(revision) > 0:
61
 
            try:
62
 
                rev_id = revision[0].in_history(branch).rev_id
63
 
                old = branch.revision_tree(rev_id)
64
 
            except NoSuchRevision, e:
65
 
                raise BzrCommandError(str(e))
66
 
            if len(revision) > 1:
67
 
                try:
68
 
                    rev_id = revision[1].in_history(branch).rev_id
69
 
                    new = branch.revision_tree(rev_id)
70
 
                    new_is_working_tree = False
71
 
                except NoSuchRevision, e:
72
 
                    raise BzrCommandError(str(e))
73
 
            else:
74
 
                new = branch.working_tree()
75
 
                
 
49
 
 
50
        old = branch.basis_tree()
 
51
        new = branch.working_tree()
76
52
 
77
53
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
78
54
                              specific_files=specific_files)
81
57
                   show_ids=show_ids,
82
58
                   show_unchanged=show_unchanged)
83
59
 
84
 
        if new_is_working_tree:
85
 
            unknowns = new.unknowns()
86
 
            done_header = False
87
 
            for path in unknowns:
88
 
                if specific_files and not is_inside_any(specific_files, path):
 
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:
89
67
                    continue
90
 
                if not done_header:
91
 
                    print >>to_file, 'unknown:'
92
 
                    done_header = True
93
 
                print >>to_file, ' ', path
94
 
            if show_pending and len(branch.pending_merges()) > 0:
95
 
                print >>to_file, 'pending merges:'
96
 
                for merge in branch.pending_merges():
97
 
                    print >> to_file, ' ', merge
 
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
98
76
    finally:
99
77
        branch.unlock()
100
78