Changeset 50 for mergebot/trunk


Ignore:
Timestamp:
Feb 23, 2010 6:31:25 PM (15 years ago)
Author:
retracile
Message:

Mergebot: split the merge method based on version; this gets the tests to pass with subversion 1.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mergebot/trunk/mergebot/svn.py

    r48 r50  
    9898
    9999    def merge(self, from_url, workingdir, revision_range, logfile):
     100        if self.svn_version[:2] == [1,4]:
     101            return self.merge14(from_url, workingdir, revision_range, logfile)
     102        return self.merge16(from_url, workingdir, revision_range, logfile)
     103
     104    def merge14(self, from_url, workingdir, revision_range, logfile):
    100105        """Returns a list (status, filename) tuples"""
    101106        # There are a couple of different 'Skipped' messages.
     
    112117                filename = skipped_regex.findall(line)[0]
    113118                status = "C"
     119            else:
     120                assert line[4] == ' ', "Unexpected output from svn merge " \
     121                    "operation; the 5th character should always be a space." \
     122                    "  Output was %r." % line
     123                filename = line[5:-1] # (strip trailing newline)
     124                status = line[:4].rstrip()
     125            results.append((status, filename))
     126        return results
     127
     128    def merge16(self, from_url, workingdir, revision_range, logfile):
     129        """Returns a list (status, filename) tuples"""
     130        # There are a couple of different 'Skipped' messages.
     131        skipped_regex = re.compile("Skipped.* '(.*)'", re.M)
     132        start_rev, end_rev = revision_range
     133        pipe = os.popen("cd %s && svn merge --revision %s:%s %s . 2>>%s" % \
     134            (workingdir, start_rev, end_rev, from_url, logfile))
     135        output = pipe.readlines()
     136        # FIXME: check pipe.close for errors
     137        results = []
     138        for line in output:
     139            if line.startswith("Skipped"):
     140                # This kind of conflict requires special handling.
     141                filename = skipped_regex.findall(line)[0]
     142                status = "C"
     143            elif line.startswith("--- Merging r"):
     144                continue # ignore the line
    114145            else:
    115146                assert line[4] == ' ', "Unexpected output from svn merge " \
Note: See TracChangeset for help on using the changeset viewer.