changeset 6:1a5bb173170b

Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
author Augie Fackler <durin42@gmail.com>
date Thu, 02 Oct 2008 09:13:08 -0500
parents 0548662e2f34
children 79b0e059319d
files fetch_command.py hg_delta_editor.py push_cmd.py svncommand.py svnwrap/svn_swig_wrapper.py
diffstat 5 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_command.py
+++ b/fetch_command.py
@@ -3,13 +3,13 @@ import re
 import operator
 import os
 import shutil
-import stat
 import tempfile
 
 from mercurial import patch
 from mercurial import node
 from mercurial import context
 from mercurial import revlog
+from mercurial import util as merc_util
 from svn import core
 from svn import delta
 
@@ -40,7 +40,7 @@ def fetch_revisions(ui, svn_url, hg_repo
                   ' of SWIG.')
         have_replay = False
     initializing_repo = False
-    svn = svnwrap.SubversionRepo(svn_url)
+    svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
     author_host = "@%s" % svn.uuid
     tag_locations = tag_locations.split(',')
     hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -8,6 +8,7 @@ import traceback
 from mercurial import context
 from mercurial import hg
 from mercurial import ui
+from mercurial import util
 from mercurial import revlog
 from mercurial import node
 from svn import delta
@@ -27,7 +28,7 @@ def pickle_atomic(data, file_path, dir=N
     except:
         raise
     else:
-        os.rename(path, file_path)
+        util.rename(path, file_path)
 
 def stash_exception_on_self(fn):
     """Stash any exception raised in the method on self.
--- a/push_cmd.py
+++ b/push_cmd.py
@@ -94,7 +94,7 @@ def commit_from_rev(ui, repo, rev_ctx, h
         file_data[file] = base_data, new_data, action
 
     # TODO check for directory deletes here
-    svn = svnwrap.SubversionRepo(svn_url)
+    svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
     parent_branch = rev_ctx.parents()[0].branch()
     branch_path = 'trunk'
     if parent_branch and parent_branch != 'default':
--- a/svncommand.py
+++ b/svncommand.py
@@ -4,6 +4,7 @@ import stat
 
 from mercurial import hg
 from mercurial import node
+from mercurial import util as merc_util
 
 import svnwrap
 import hg_delta_editor
@@ -101,7 +102,7 @@ def verify_revision(ui, args, repo, forc
     rev = int(args[0])
     wc_path = os.path.dirname(repo.path)
     svn_url = open(os.path.join(repo.path, 'svn', 'url')).read()
-    svn = svnwrap.SubversionRepo(svn_url)
+    svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
     util.wipe_all_files(wc_path)
     if update(ui, args, repo, clean=True) == 0:
         util.wipe_all_files(wc_path)
--- a/svnwrap/svn_swig_wrapper.py
+++ b/svnwrap/svn_swig_wrapper.py
@@ -1,7 +1,6 @@
 import cStringIO
 import getpass
 import os
-import pwd
 import shutil
 import sys
 import tempfile
@@ -69,8 +68,9 @@ class SubversionRepo(object):
     This uses the SWIG Python bindings, and will only work on svn >= 1.4.
     It takes a required param, the URL.
     """
-    def __init__(self, url=''):
+    def __init__(self, url='', username=''):
         self.svn_url = url
+        self.uname = username
         self.auth_baton_pool = core.Pool()
         self.auth_baton = _create_auth_baton(self.auth_baton_pool)
 
@@ -89,7 +89,6 @@ class SubversionRepo(object):
         # while we're in here we'll recreate our pool
         self.pool = core.Pool()
         self.client_context = client.create_context()
-        self.uname = str(pwd.getpwuid(os.getuid())[0])
         core.svn_auth_set_parameter(self.auth_baton,
                                     core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
                                     self.uname)