def _commit(self, date, author, patchname, changelog=None, entries=None, tags=[], isinitialcommit=False): """ Commit the changeset. """ from os import rename, unlink logmessage = [] logmessage.append( date.astimezone(UTC).strftime('%Y/%m/%d %H:%M:%S UTC')) # Paranoid protection against newlines in author logmessage.append(''.join(author.split('\n'))) # Patchname cannot start with a newline patchname = patchname.lstrip('\n') if patchname: logmessage.append(patchname) else: # This is possibile also when REMOVE_FIRST_LOG_LINE is in # effect and the changelog starts with newlines: discard # those, otherwise darcs will complain about invalid patch # name if changelog: while changelog.startswith('\n'): changelog = changelog[1:] if not changelog: # No patch name and no changelog: force non empty one logmessage.append(' ') if changelog: logmessage.append(changelog) cmd = self.repository.command("record", "--all", "--pipe", "--ignore-times") if not entries: entries = ['.'] record = ExternalCommand(cwd=self.repository.basedir, command=cmd) output = record.execute(input=self.repository.encode( '\n'.join(logmessage)), stdout=PIPE, stderr=STDOUT)[0] # Repair afterwards, for http://bugs.darcs.net/issue693 # # Verified that this is still needed for darcs 2.1.2 (+ 343 patches) # using the config.tailor file that is attached to issue693 above. if record.exit_status == 2: self.log.debug("Trying to repair record failure...") cmd = self.repository.command("repair") repair = ExternalCommand(cwd=self.repository.basedir, command=cmd) repairoutput = repair.execute(stdout=PIPE, stderr=STDOUT)[0] if not repair.exit_status: record.exit_status = repair.exit_status else: self.log.warning("%s returned status %d, saying %s", str(repair), repair.exit_status, repairoutput.read()) if record.exit_status: pending = join(self.repository.metadir, 'patches', 'pending') if exists(pending): wrongpending = pending + '.wrong' if exists(wrongpending): unlink(wrongpending) rename(pending, wrongpending) self.log.debug("Pending file renamed to %s", wrongpending) raise ChangesetReplayFailure( "%s returned status %d, saying: %s" % (str(record), record.exit_status, output.read()))
def _commit(self, date, author, patchname, changelog=None, entries=None, tags = [], isinitialcommit = False): """ Commit the changeset. """ from os import rename, unlink logmessage = [] logmessage.append(date.astimezone(UTC).strftime('%Y/%m/%d %H:%M:%S UTC')) # Paranoid protection against newlines in author logmessage.append(''.join(author.split('\n'))) # Patchname cannot start with a newline patchname = patchname.lstrip('\n') if patchname: logmessage.append(patchname) else: # This is possibile also when REMOVE_FIRST_LOG_LINE is in # effect and the changelog starts with newlines: discard # those, otherwise darcs will complain about invalid patch # name if changelog: while changelog.startswith('\n'): changelog = changelog[1:] if not changelog: # No patch name and no changelog: force non empty one logmessage.append(' ') if changelog: logmessage.append(changelog) cmd = self.repository.command("record", "--all", "--pipe", "--ignore-times") if not entries: entries = ['.'] record = ExternalCommand(cwd=self.repository.basedir, command=cmd) output = record.execute(input=self.repository.encode('\n'.join(logmessage)), stdout=PIPE, stderr=STDOUT)[0] # Repair afterwards, for http://bugs.darcs.net/issue693 # # Verified that this is still needed for darcs 2.1.2 (+ 343 patches) # using the config.tailor file that is attached to issue693 above. if record.exit_status == 2: self.log.debug("Trying to repair record failure...") cmd = self.repository.command("repair") repair = ExternalCommand(cwd=self.repository.basedir, command=cmd) repairoutput = repair.execute(stdout=PIPE, stderr=STDOUT)[0] if not repair.exit_status: record.exit_status = repair.exit_status else: self.log.warning("%s returned status %d, saying %s", str(repair), repair.exit_status, repairoutput.read()) if record.exit_status: pending = join(self.repository.metadir, 'patches', 'pending') if exists(pending): wrongpending = pending + '.wrong' if exists(wrongpending): unlink(wrongpending) rename(pending, wrongpending) self.log.debug("Pending file renamed to %s", wrongpending) raise ChangesetReplayFailure( "%s returned status %d, saying: %s" % (str(record), record.exit_status, output.read()))