/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/patches.py

merge bzr.dev r4042

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    range = int(range)
93
93
    return (pos, range)
94
94
 
95
 
 
 
95
 
96
96
def hunk_from_header(line):
97
97
    import re
98
98
    matches = re.match(r'\@\@ ([^@]*) \@\@( (.*))?\n', line)
268
268
        self.hunks = []
269
269
 
270
270
    def __str__(self):
271
 
        ret = self.get_header() 
 
271
        ret = self.get_header()
272
272
        ret += "".join([str(h) for h in self.hunks])
273
273
        return ret
274
274
 
275
275
    def get_header(self):
276
276
        return "--- %s\n+++ %s\n" % (self.oldname, self.newname)
277
277
 
278
 
    def stats_str(self):
279
 
        """Return a string of patch statistics"""
 
278
    def stats_values(self):
 
279
        """Calculate the number of inserts and removes."""
280
280
        removes = 0
281
281
        inserts = 0
282
282
        for hunk in self.hunks:
285
285
                     inserts+=1;
286
286
                elif isinstance(line, RemoveLine):
287
287
                     removes+=1;
 
288
        return (inserts, removes, len(self.hunks))
 
289
 
 
290
    def stats_str(self):
 
291
        """Return a string of patch statistics"""
288
292
        return "%i inserts, %i removes in %i hunks" % \
289
 
            (inserts, removes, len(self.hunks))
 
293
            self.stats_values()
290
294
 
291
295
    def pos_in_mod(self, position):
292
296
        newpos = position
296
300
                return None
297
301
            newpos += shift
298
302
        return newpos
299
 
            
 
303
 
300
304
    def iter_inserted(self):
301
305
        """Iteraties through inserted lines
302
 
        
 
306
 
303
307
        :return: Pair of line number, line
304
308
        :rtype: iterator of (int, InsertLine)
305
309
        """