[PATCH 1 of 1 hglib] imported patch workingdir.patch

Jeff Laughlin jmlaughlin at integrated-informatics.com
Mon Nov 28 10:16:56 CST 2011


# HG changeset patch
# User Jeff Laughlin <jmlaughlin at integrated-informatics.com>
# Date 1322496809 18000
# Node ID ce8d832fa332918d3f7b97ccbc777530a78fc97a
# Parent  97fef60581eded25e88596306c175d04ba3a89c2
imported patch workingdir.patch

diff -r 97fef60581ed -r ce8d832fa332 hglib/client.py
--- a/hglib/client.py	Mon Nov 28 11:12:58 2011 -0500
+++ b/hglib/client.py	Mon Nov 28 11:13:29 2011 -0500
@@ -16,6 +16,7 @@
         args = [hglib.HGPATH, 'serve', '--cmdserver', 'pipe',
                 '--config', 'ui.interactive=True']
         if path:
+            path = os.path.abspath(path)
             args += ['-R', path]
         if configs:
             args += ['--config'] + configs
@@ -23,7 +24,7 @@
         if encoding:
             env['HGENCODING'] = encoding
 
-        self.server = util.popen(args, env)
+        self.server = util.popen(args, env, path)
         self._readhello()
         self._version = None
 
diff -r 97fef60581ed -r ce8d832fa332 hglib/util.py
--- a/hglib/util.py	Mon Nov 28 11:12:58 2011 -0500
+++ b/hglib/util.py	Mon Nov 28 11:13:29 2011 -0500
@@ -165,12 +165,13 @@
     startupinfo = subprocess.STARTUPINFO()
     startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
 
-def popen(args, env={}):
+def popen(args, env={}, cwd=None):
     environ = None
     if env:
         environ = dict(os.environ)
         environ.update(env)
 
+    cwd = os.path.abspath(cwd)
     return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, close_fds=close_fds,
-                            startupinfo=startupinfo, env=environ)
+                            startupinfo=startupinfo, env=environ, cwd=cwd)
diff -r 97fef60581ed -r ce8d832fa332 tests/__init__.py
--- a/tests/__init__.py	Mon Nov 28 11:12:58 2011 -0500
+++ b/tests/__init__.py	Mon Nov 28 11:13:29 2011 -0500
@@ -1,6 +1,11 @@
 import os, tempfile, sys, shutil
 
+
+olddir = None
+
 def setUp():
+    global olddir
+    olddir = os.getcwd()
     os.environ['LANG'] = os.environ['LC_ALL'] = os.environ['LANGUAGE'] = 'C'
     os.environ['TZ'] = 'GMT'
     os.environ["EMAIL"] = "Foo Bar <foo.bar at example.com>"
@@ -19,5 +24,5 @@
     os.environ["HGRCPATH"] = os.pathsep
 
 def tearDown(self):
-    os.chdir('..')
+    os.chdir(olddir)
     shutil.rmtree(os.environ["HGTMP"])
diff -r 97fef60581ed -r ce8d832fa332 tests/test-archive.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-archive.py	Mon Nov 28 11:13:29 2011 -0500
@@ -0,0 +1,31 @@
+import os
+import shutil
+import tempfile
+import unittest
+import hglib
+
+class test_archive(unittest.TestCase):
+    def test_basic(self):
+        olddir = os.getcwd()
+        testdir = None
+        client = None
+        try:
+            testdir = tempfile.mkdtemp('libhgtest')
+            client = hglib.init(os.path.join(testdir, 'repo'))
+            f = open(os.path.join(testdir,'repo','afile'), 'w')
+            f.write('Hello, world.')
+            f.close()
+            client.commit('first', addremove=True)
+            client.archive(os.path.join(testdir, 'arch'), include=['afile'])
+            self.assertTrue(os.path.exists(os.path.join(testdir, 'arch', 'afile')))
+        finally:
+            os.chdir(olddir)
+            try:
+                client.close()
+            except Exception:
+                pass
+            try:
+                shutil.rmtree(testdir, ignore_errors=True)
+            except Exception, e:
+                print e
+


More information about the Mercurial-devel mailing list