I've attached 3 changes that I required to do a large subversion->git
transition.
First and most serious is a workaround to the error OSError: [Errno 7]
Argument list too long. I modified shwrap to split long argument lists
up and rerun the command multiple times. I'm sure this breaks
assumptions in many places about the input and the output, but it
appears to have worked for me. To do this properly, we'll probably have
to change the signature of the class.
The other patches are minor. I added --ignore-externals to svn update,
and git's "nothing to commit" message must have changed slightly over time.
Bryan
diff -rN -u old-tailor/vcpx/git.py new-tailor/vcpx/git.py
--- old-tailor/vcpx/git.py 2005-12-06 19:36:17.000000000 -0500
+++ new-tailor/vcpx/git.py 2005-12-07 12:01:08.000000000 -0500
@@ -226,11 +226,12 @@
logmessage = encode('\n'.join(logmessage))
if not logmessage.endswith('\n'):
logmessage += '\n'
- (out, _) = c.execute(stdout=PIPE, env=env, input=logmessage)
+ (out, err) = c.execute(stdout=PIPE, stderr=PIPE, env=env,
input=logmessage)
if c.exit_status:
if out is None or out.readline().strip() != 'nothing to commit':
- raise ChangesetApplicationFailure("%s returned status %d" %
- (str(c), c.exit_status))
+ if err is None or err.readline().strip() != 'Nothing to
commit':
+ raise ChangesetApplicationFailure("%s returned status %d" %
+ (str(c), c.exit_status))
else:
# empty changeset, which git-core doesn't support
pass
diff -rN -u old-tailor/vcpx/shwrap.py new-tailor/vcpx/shwrap.py
--- old-tailor/vcpx/shwrap.py 2005-12-06 19:36:17.000000000 -0500
+++ new-tailor/vcpx/shwrap.py 2005-12-07 16:52:35.000000000 -0500
@@ -136,22 +136,11 @@
self.exit_status = None
- self._last_command = [chunk % kwargs for chunk in self.command]
- if len(args) == 1 and type(args[0]) == type([]):
- self._last_command.extend(args[0])
- else:
- self._last_command.extend(args)
-
- self.log.info(self)
-
- if self.DRY_RUN:
- return
+ cmd_front = [chunk % kwargs for chunk in self.command]
if not kwargs.has_key('cwd') and self.cwd:
kwargs['cwd'] = self.cwd
- self.log.debug("Executing %r (%r)", self, kwargs.get('cwd', getcwd()))
-
if not kwargs.has_key('env'):
env = kwargs['env'] = {}
env.update(environ)
@@ -180,21 +169,6 @@
output = open(devnull, 'w')
if error is None:
error = open(devnull, 'w')
- try:
- process = Popen(self._last_command,
- stdin=input and PIPE or None,
- stdout=output,
- stderr=error,
- env=kwargs.get('env'),
- cwd=kwargs.get('cwd'),
- universal_newlines=True)
- except OSError, e:
- from errno import ENOENT
-
- if e.errno == ENOENT:
- raise OSError("'%s' does not exist!" % self._last_command[0])
- else:
- raise
if input and isinstance(input, unicode):
encoding = getpreferredencoding()
@@ -203,22 +177,53 @@
"pass an already encoded input")
input = input.encode(encoding, 'ignore')
- out, err = process.communicate(input=input)
- self.exit_status = process.returncode
- if not self.exit_status:
- self.log.info("[Ok]")
- else:
- self.log.warning("[Status %s]", self.exit_status)
-
- # For debug purposes, copy the output to our stderr when hidden above
- if self.DEBUG:
- if out and output == PIPE:
- stderr.write('Output stream:\n')
- stderr.write(out)
- if err and error == PIPE:
- stderr.write('Error stream:\n')
- stderr.write(err)
+ if len(args) == 1 and type(args[0]) == type([]):
+ args = args[0]
+
+ for i in range(0,len(args)+1,50):
+ self._last_command=cmd_front[0:]
+ self._last_command.extend(args[i:min(i+50,len(args)+1)])
+
+ self.log.info(self)
+
+ if self.DRY_RUN:
+ return
+
+ self.log.debug("Executing %r (%r)", self, kwargs.get('cwd',
getcwd()))
+
+ try:
+ process = Popen(self._last_command,
+ stdin=input and PIPE or None,
+ stdout=output,
+ stderr=error,
+ env=kwargs.get('env'),
+ cwd=kwargs.get('cwd'),
+ universal_newlines=True)
+ except OSError, e:
+ from errno import ENOENT
+
+ if e.errno == ENOENT:
+ raise OSError("'%s' does not exist!" %
self._last_command[0])
+ else:
+ raise
+
+ out, err = process.communicate(input=input)
+
+ self.exit_status = process.returncode
+ if not self.exit_status:
+ self.log.info("[Ok]")
+ else:
+ self.log.warning("[Status %s]", self.exit_status)
+
+ # For debug purposes, copy the output to our stderr when hidden
above
+ if self.DEBUG:
+ if out and output == PIPE:
+ stderr.write('Output stream:\n')
+ stderr.write(out)
+ if err and error == PIPE:
+ stderr.write('Error stream:\n')
+ stderr.write(err)
if out is not None:
out = StringIO(out)
diff -rN -u old-tailor/vcpx/svn.py new-tailor/vcpx/svn.py
--- old-tailor/vcpx/svn.py 2005-12-06 19:36:17.000000000 -0500
+++ new-tailor/vcpx/svn.py 2005-12-07 20:48:02.000000000 -0500
@@ -243,7 +243,7 @@
def _applyChangeset(self, changeset):
from time import sleep
- cmd = self.repository.command("update",
+ cmd = self.repository.command("update", "--ignore-externals",
"--revision", changeset.revision, ".")
svnup = ExternalCommand(cwd=self.basedir, command=cmd)
@@ -342,7 +342,7 @@
if not exists(join(self.basedir, '.svn')):
self.log.debug("Checking out a working copy")
- cmd = self.repository.command("co", "--quiet",
+ cmd = self.repository.command("co", "--quiet",
"--ignore-externals",
"--revision", revision)
svnco = ExternalCommand(command=cmd)
out, err = svnco.execute("%s%s" % (self.repository.repository,
@@ -581,7 +581,7 @@
if not self.repository.repository or exists(join(self.basedir,
'.svn')):
return
- cmd = self.repository.command("co", "--quiet")
+ cmd = self.repository.command("co", "--quiet", "--ignore-externals")
svnco = ExternalCommand(command=cmd)
svnco.execute("%s%s" % (self.repository.repository,
self.repository.module), self.basedir)
_______________________________________________
Tailor mailing list
[email protected]
http://lists.zooko.com/mailman/listinfo/tailor