/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Robert Collins
  • Date: 2005-09-30 02:54:51 UTC
  • mfrom: (1395)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050930025451-47b9e412202be44b
symlink and weaves, whaddya know

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
def show_status(branch, show_unchanged=False,
20
20
                specific_files=None,
21
21
                show_ids=False,
22
 
                to_file=None):
23
 
    """Display single-line status for non-ignored working files.
 
22
                to_file=None,
 
23
                show_pending=True,
 
24
                revision=None):
 
25
    """Display status for non-ignored working files.
24
26
 
25
 
    show_all
26
 
        If true, show unmodified files too.
 
27
    show_unchanged
 
28
        If set, includes unchanged files.
27
29
 
28
30
    specific_files
29
31
        If set, only show the status of files in this list.
30
32
 
 
33
    show_ids
 
34
        If set, includes each file's id.
 
35
 
31
36
    to_file
32
37
        If set, write to this file (default stdout.)
 
38
 
 
39
    show_pending
 
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.
33
46
    """
34
47
    import sys
35
48
    from bzrlib.delta import compare_trees
39
52
    
40
53
    branch.lock_read()
41
54
    try:
42
 
 
43
 
        old = branch.basis_tree()
44
 
        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
                
45
75
 
46
76
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
47
77
                              specific_files=specific_files)
50
80
                   show_ids=show_ids,
51
81
                   show_unchanged=show_unchanged)
52
82
 
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
 
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
65
100
    finally:
66
101
        branch.unlock()
67
102