~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patches.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
 
19
19
class PatchSyntax(Exception):
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)
164
164
        return InsertLine(line[1:])
165
165
    elif line.startswith("-"):
166
166
        return RemoveLine(line[1:])
167
 
    elif line == NO_NL:
168
 
        return NO_NL
169
167
    else:
170
168
        raise MalformedLine("Unknown line type", line)
171
169
__pychecker__=""
268
266
        self.hunks = []
269
267
 
270
268
    def __str__(self):
271
 
        ret = self.get_header() 
 
269
        ret = self.get_header()
272
270
        ret += "".join([str(h) for h in self.hunks])
273
271
        return ret
274
272
 
300
298
                return None
301
299
            newpos += shift
302
300
        return newpos
303
 
            
 
301
 
304
302
    def iter_inserted(self):
305
303
        """Iteraties through inserted lines
306
 
        
 
304
 
307
305
        :return: Pair of line number, line
308
306
        :rtype: iterator of (int, InsertLine)
309
307
        """
318
316
 
319
317
 
320
318
def parse_patch(iter_lines):
 
319
    iter_lines = iter_lines_handle_nl(iter_lines)
321
320
    (orig_name, mod_name) = get_patch_names(iter_lines)
322
321
    patch = Patch(orig_name, mod_name)
323
322
    for hunk in iter_hunks(iter_lines):
370
369
 
371
370
 
372
371
def parse_patches(iter_lines):
373
 
    iter_lines = iter_lines_handle_nl(iter_lines)
374
372
    return [parse_patch(f.__iter__()) for f in iter_file_patch(iter_lines)]
375
373
 
376
374