1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2008 CollabNet. All rights reserved.
6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution. The terms
8 # are also available at http://subversion.tigris.org/license-1.html.
9 # If newer versions of this license are posted there, you may use a
10 # newer version instead, at your option.
12 # This software consists of voluntary contributions made by many
13 # individuals. For exact contribution history, see the revision
14 # history and logs, available at http://cvs2svn.tigris.org/.
15 # ====================================================================
17 """This module contains class RepositoryDelegate."""
22 from cvs2svn_lib
.common
import CommandError
23 from cvs2svn_lib
.common
import FatalError
24 from cvs2svn_lib
.context
import Ctx
25 from cvs2svn_lib
.svn_dump
import DumpstreamDelegate
28 class LoaderPipe(object):
29 """A file-like object that writes to 'svnadmin load'.
31 Some error checking and reporting are done when writing."""
33 def __init__(self
, target
):
34 self
.loader_pipe
= subprocess
.Popen(
35 [Ctx().svnadmin_executable
, 'load', '-q', target
],
36 stdin
=subprocess
.PIPE
,
37 stdout
=subprocess
.PIPE
,
38 stderr
=subprocess
.PIPE
,
40 self
.loader_pipe
.stdout
.close()
44 self
.loader_pipe
.stdin
.write(s
)
47 'svnadmin failed with the following output while '
48 'loading the dumpfile:\n%s'
49 % (self
.loader_pipe
.stderr
.read(),)
53 self
.loader_pipe
.stdin
.close()
54 error_output
= self
.loader_pipe
.stderr
.read()
55 exit_status
= self
.loader_pipe
.wait()
58 raise CommandError('svnadmin load', exit_status
, error_output
)
61 def RepositoryDelegate(revision_reader
, target
):
62 loader_pipe
= LoaderPipe(target
)
63 return DumpstreamDelegate(revision_reader
, loader_pipe
)