~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-07 21:39:19 UTC
  • mfrom: (2168.1.3 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20061207213919-1cc5d101c30fda65
(Keir Mierle) Add support for 'bzr status --short'

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        return False
92
92
            
93
93
 
94
 
    def show(self, to_file, show_ids=False, show_unchanged=False):
 
94
    def show(self, to_file, show_ids=False, show_unchanged=False, short_status=False):
95
95
        """output this delta in status-like form to to_file."""
96
 
        def show_list(files):
 
96
        def show_list(files, short_status_letter=''):
97
97
            for item in files:
98
98
                path, fid, kind = item[:3]
99
99
 
106
106
                    path += '*'
107
107
 
108
108
                if show_ids:
109
 
                    print >>to_file, '  %-30s %s' % (path, fid)
 
109
                    print >>to_file, '%s  %-30s %s' % (short_status_letter, path, fid)
110
110
                else:
111
 
                    print >>to_file, ' ', path
 
111
                    print >>to_file, '%s  %s' % (short_status_letter, path)
112
112
            
113
113
        if self.removed:
114
 
            print >>to_file, 'removed:'
115
 
            show_list(self.removed)
 
114
            if not short_status:
 
115
                print >>to_file, 'removed:'
 
116
                show_list(self.removed)
 
117
            else:
 
118
                show_list(self.removed, 'D')
116
119
                
117
120
        if self.added:
118
 
            print >>to_file, 'added:'
119
 
            show_list(self.added)
 
121
            if not short_status:
 
122
                print >>to_file, 'added:'
 
123
                show_list(self.added)
 
124
            else:
 
125
                show_list(self.added, 'A')
120
126
 
121
127
        extra_modified = []
122
128
 
123
129
        if self.renamed:
124
 
            print >>to_file, 'renamed:'
 
130
            short_status_letter = 'R'
 
131
            if not short_status:
 
132
                print >>to_file, 'renamed:'
 
133
                short_status_letter = ''
125
134
            for (oldpath, newpath, fid, kind,
126
135
                 text_modified, meta_modified) in self.renamed:
127
136
                if text_modified or meta_modified:
130
139
                if meta_modified:
131
140
                    newpath += '*'
132
141
                if show_ids:
133
 
                    print >>to_file, '  %s => %s %s' % (oldpath, newpath, fid)
 
142
                    print >>to_file, '%s  %s => %s %s' % (short_status_letter,
 
143
                                                          oldpath, newpath, fid)
134
144
                else:
135
 
                    print >>to_file, '  %s => %s' % (oldpath, newpath)
 
145
                    print >>to_file, '%s  %s => %s' % (short_status_letter,
 
146
                                                       oldpath, newpath)
136
147
                    
137
148
        if self.modified or extra_modified:
138
 
            print >>to_file, 'modified:'
139
 
            show_list(self.modified)
140
 
            show_list(extra_modified)
 
149
            short_status_letter = 'M'
 
150
            if not short_status:
 
151
                print >>to_file, 'modified:'
 
152
                short_status_letter = ''
 
153
            show_list(self.modified, short_status_letter)
 
154
            show_list(extra_modified, short_status_letter)
141
155
            
142
156
        if show_unchanged and self.unchanged:
143
 
            print >>to_file, 'unchanged:'
144
 
            show_list(self.unchanged)
 
157
            if not short_status:
 
158
                print >>to_file, 'unchanged:'
 
159
                show_list(self.unchanged)
 
160
            else:
 
161
                show_list(self.unchanged, 'S')
145
162
 
146
163
 
147
164
@deprecated_function(zero_nine)