Use unicode_output=False in some Darcs._u_invoke_client() calls.
authorW. Trevor King <wking@drexel.edu>
Tue, 17 Nov 2009 14:47:44 +0000 (09:47 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 17 Nov 2009 14:47:44 +0000 (09:47 -0500)
This avoids the following error:
  ======================================================================
  ERROR: Should get file contents as committed to specified revision.
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File ".../libbe/vcs.py", line 860, in test_revision_file_contents_as_committed
      full_path, revision)
    File ".../libbe/vcs.py", line 339, in get_file_contents
      contents = self._vcs_get_file_contents(relpath,revision,binary=binary)
    File ".../libbe/darcs.py", line 122, in _vcs_get_file_contents
      status,output,error = self._u_invoke(args, stdin=major_patch)
    File ".../libbe/vcs.py", line 488, in _u_invoke
      raise CommandError(args, status, stdout, stderr)
  CommandError: Command failed (2):
    patch: **** Only garbage was found in the patch input.

  while executing
    ['patch', '--reverse', 'a/text']

After adding the unicode_output=False lines, I adjusted the
VCS._u_invoke_client() definition to pass all it's kwargs
automatically through to VCS._u_invoke().  To make this simpler and
more consistent, I renamed the "directory" option to "cwd", and
adjusted *._u_invoke() calls appropriately in several VCS backends.

libbe/arch.py
libbe/bzr.py
libbe/darcs.py
libbe/git.py
libbe/hg.py
libbe/vcs.py

index daa8ac6114773997abfa4ed14ecc3705cbc833ab..98c4eddeb05b763bb6dcba3e8d8d7bae19b01e7c 100644 (file)
@@ -83,7 +83,7 @@ class Arch(vcs.VCS):
         self._archive_dir = "/tmp/%s" % trailer
         self._tmp_archive = True
         self._u_invoke_client("make-archive", self._archive_name,
-                              self._archive_dir, directory=path)
+                              self._archive_dir, cwd=path)
     def _invoke_client(self, *args, **kwargs):
         """
         Invoke the client on our archive.
@@ -121,7 +121,7 @@ class Arch(vcs.VCS):
         version = "0.1"
         self._project_name = "%s--%s--%s" % (category, branch, version)
         self._invoke_client("archive-setup", self._project_name,
-                            directory=path)
+                            cwd=path)
         self._tmp_project = True
     def _remove_project(self):
         assert self._tmp_project == True
@@ -164,10 +164,10 @@ class Arch(vcs.VCS):
         # http://regexps.srparish.net/tutorial-tla/new-source.html
         # http://regexps.srparish.net/tutorial-tla/importing-first.html
         self._invoke_client("init-tree", self._project_name,
-                              directory=path)
+                            cwd=path)
         self._adjust_naming_conventions(path)
         self._invoke_client("import", "--summary", "Began versioning",
-                            directory=path)
+                            cwd=path)
     def _vcs_cleanup(self):
         if self._tmp_project == True:
             self._remove_project()
@@ -198,7 +198,7 @@ class Arch(vcs.VCS):
         assert self._archive_name != None
     def _get_archive_project_name(self, root):
         # get project names
-        status,output,error = self._u_invoke_client("tree-version", directory=root)
+        status,output,error = self._u_invoke_client("tree-version", cwd=root)
         # e.g output
         # jdoe@example.com--bugs-everywhere-auto-2008.22.24.52/be--mainline--0.1
         archive_name,project_name = output.rstrip('\n').split('/')
@@ -266,7 +266,7 @@ class Arch(vcs.VCS):
             vcs.VCS._vcs_duplicate_repo(self, directory, revision)
         else:
             status,output,error = \
-                self._u_invoke_client("get", revision,directory)
+                self._u_invoke_client("get", revision, directory)
     def _vcs_commit(self, commitfile, allow_empty=False):
         if allow_empty == False:
             # arch applies empty commits without complaining, so check first
index ed9e03297b10d4b0641f94c282b128242ddbc91b..8e91d0c5d4a91eff8def008bc0462e01e1a0e9a2 100644 (file)
@@ -49,7 +49,7 @@ class Bzr(vcs.VCS):
         status,output,error = self._u_invoke_client("root", path)
         return output.rstrip('\n')
     def _vcs_init(self, path):
-        self._u_invoke_client("init", directory=path)
+        self._u_invoke_client("init", cwd=path)
     def _vcs_get_user_id(self):
         status,output,error = self._u_invoke_client("whoami")
         return output.rstrip('\n')
index 91158860f14e0a32d48673ee5a5968ded1806b74..6bf011989096fec7d5db7b8e6422b276811399cb 100644 (file)
@@ -60,7 +60,7 @@ class Darcs(vcs.VCS):
             return None
         return os.path.dirname(darcs_dir)
     def _vcs_init(self, path):
-        self._u_invoke_client("init", directory=path)
+        self._u_invoke_client("init", cwd=path)
     def _vcs_get_user_id(self):
         # following http://darcs.net/manual/node4.html#SECTION00410030000000000000
         # as of June 29th, 2009
@@ -107,10 +107,12 @@ class Darcs(vcs.VCS):
                 # Darcs versions < 2.0.0pre2 lack the "show contents" command
 
                 status,output,error = self._u_invoke_client( \
-                    "diff", "--unified", "--from-patch", revision, path)
+                    "diff", "--unified", "--from-patch", revision, path,
+                    unicode_output=False)
                 major_patch = output
                 status,output,error = self._u_invoke_client( \
-                    "diff", "--unified", "--patch", revision, path)
+                    "diff", "--unified", "--patch", revision, path,
+                    unicode_output=False)
                 target_patch = output
                 
                 # "--output -" to be supported in GNU patch > 2.5.9
index 628f9b9697f4273e75e59663a84f6722ceb8df48..781a2780da51f1dd655f9e5e419fa4308098da49 100644 (file)
@@ -50,12 +50,12 @@ class Git(vcs.VCS):
         if os.path.isdir(path) != True:
             path = os.path.dirname(path)
         status,output,error = self._u_invoke_client("rev-parse", "--git-dir",
-                                                    directory=path)
+                                                    cwd=path)
         gitdir = os.path.join(path, output.rstrip('\n'))
         dirname = os.path.abspath(os.path.dirname(gitdir))
         return dirname
     def _vcs_init(self, path):
-        self._u_invoke_client("init", directory=path)
+        self._u_invoke_client("init", cwd=path)
     def _vcs_get_user_id(self):
         status,output,error = \
             self._u_invoke_client("config", "user.name", expect=(0,1))
@@ -102,9 +102,8 @@ class Git(vcs.VCS):
         if revision==None:
             vcs.VCS._vcs_duplicate_repo(self, directory, revision)
         else:
-            #self._u_invoke_client("archive", revision, directory) # makes tarball
-            self._u_invoke_client("clone", "--no-checkout",".",directory)
-            self._u_invoke_client("checkout", revision, directory=directory)
+            self._u_invoke_client("clone", "--no-checkout", ".", directory)
+            self._u_invoke_client("checkout", revision, cwd=directory)
     def _vcs_commit(self, commitfile, allow_empty=False):
         args = ['commit', '--all', '--file', commitfile]
         if allow_empty == True:
index 7cd4c2fa60146110c4fb372df5dd888c7401d25b..40739b61d85183487e9a623d8c7fb6a08294952c 100644 (file)
@@ -45,10 +45,10 @@ class Hg(vcs.VCS):
             return True
         return False
     def _vcs_root(self, path):
-        status,output,error = self._u_invoke_client("root", directory=path)
+        status,output,error = self._u_invoke_client("root", cwd=path)
         return output.rstrip('\n')
     def _vcs_init(self, path):
-        self._u_invoke_client("init", directory=path)
+        self._u_invoke_client("init", cwd=path)
     def _vcs_get_user_id(self):
         status,output,error = self._u_invoke_client("showconfig","ui.username")
         return output.rstrip('\n')
index 59dcaf80937877831c4dc360bcce6ae96f23f1cd..ba238584465278c2851275723c82251ff576491a 100644 (file)
@@ -488,12 +488,9 @@ class VCS(object):
             raise CommandError(args, status, stdout, stderr)
         return status, stdout, stderr
     def _u_invoke_client(self, *args, **kwargs):
-        directory = kwargs.get('directory',None)
-        expect = kwargs.get('expect', (0,))
-        stdin = kwargs.get('stdin', None)
         cl_args = [self.client]
         cl_args.extend(args)
-        return self._u_invoke(cl_args, stdin=stdin,expect=expect,cwd=directory)
+        return self._u_invoke(cl_args, **kwargs)
     def _u_search_parent_directories(self, path, filename):
         """
         Find the file (or directory) named filename in path or in any