Changeset 1498 in tailor for vcpx/repository/darcs/source.py


Ignore:
Timestamp:
05/17/08 17:16:54 (5 years ago)
Author:
lele@…
Hash name:
20080517151654-97f81-96c224ffd0fe38351643cf205778bc1eaf958f17
Message:

Use the newer 'darcs pull --xml-output'
Now that "darcs pull" accepts the "--xml-output" option, use that
instead of re-computing the patch hash from the normal "pull" output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/repository/darcs/source.py

    r1489 r1498  
    298298        """ 
    299299 
    300         cmd = self.repository.command("pull", "--dry-run") 
     300        # Use the newer pull --xml-output, if possible 
     301        cmd = self.repository.command("pull", "--dry-run", "--xml-output") 
    301302        pull = ExternalCommand(cwd=self.repository.basedir, command=cmd) 
    302303        output = pull.execute(self.repository.repository, 
    303304                              stdout=PIPE, stderr=STDOUT, TZ='UTC0')[0] 
    304  
    305         if pull.exit_status: 
    306             raise GetUpstreamChangesetsFailure( 
    307                 "%s returned status %d saying\n%s" % 
    308                 (str(pull), pull.exit_status, output.read())) 
    309  
    310         return self._parseDarcsPull(output) 
    311  
     305        if pull.exit_status and "unrecognized option `--xml-output'" in output: 
     306            # No way, fall back to old behaviour, that will possibly fail, 
     307            # on patches recorded before 2003-11-01... :-| 
     308            cmd = self.repository.command("pull", "--dry-run") 
     309            pull = ExternalCommand(cwd=self.repository.basedir, command=cmd) 
     310            output = pull.execute(self.repository.repository, 
     311                                  stdout=PIPE, stderr=STDOUT, TZ='UTC0')[0] 
     312 
     313            if pull.exit_status: 
     314                raise GetUpstreamChangesetsFailure( 
     315                    "%s returned status %d saying\n%s" % 
     316                    (str(pull), pull.exit_status, output.read())) 
     317 
     318            return self._parseDarcsPull(output) 
     319        else: 
     320            # Skip initial verbosity, as well as the one at end 
     321            from cStringIO import StringIO 
     322 
     323            output.readline() # Would pull from "/home/lele/wip/darcs-2.0"... 
     324            output.readline() # Would pull the following changes: 
     325            xml = StringIO(''.join(output.readlines()[:-2])) 
     326            xml.seek(0) 
     327            badchars = self.repository.replace_badchars 
     328            return changesets_from_darcschanges(xml, replace_badchars=badchars) 
    312329 
    313330    def _parseDarcsPull(self, output): 
Note: See TracChangeset for help on using the changeset viewer.