summaryrefslogtreecommitdiff
path: root/hgsubversion/svnwrap/subvertpy_wrapper.py
diff options
context:
space:
mode:
Diffstat (limited to 'hgsubversion/svnwrap/subvertpy_wrapper.py')
-rw-r--r--hgsubversion/svnwrap/subvertpy_wrapper.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/hgsubversion/svnwrap/subvertpy_wrapper.py b/hgsubversion/svnwrap/subvertpy_wrapper.py
index 03a167e..35dc450 100644
--- a/hgsubversion/svnwrap/subvertpy_wrapper.py
+++ b/hgsubversion/svnwrap/subvertpy_wrapper.py
@@ -22,6 +22,7 @@ try:
from subvertpy import delta
from subvertpy import properties
from subvertpy import ra
+ from subvertpy import repos
import subvertpy
except ImportError:
raise ImportError('Subvertpy %d.%d.%d or later required, but not found'
@@ -51,6 +52,18 @@ def version():
svnvers += '-' + subversion_version[3]
return (svnvers, 'Subvertpy ' + _versionstr(subvertpy.__version__))
+def create_and_load(repopath, dumpfd):
+ ''' create a new repository at repopath and load the given dump into it '''
+ repo = repos.create(repopath)
+
+ nullfd = open(os.devnull, 'w')
+
+ try:
+ repo.load_fs(dumpfd, nullfd, repos.LOAD_UUID_FORCE)
+ finally:
+ dumpfd.close()
+ nullfd.close()
+
# exported values
ERR_FS_ALREADY_EXISTS = subvertpy.ERR_FS_ALREADY_EXISTS
ERR_FS_CONFLICT = subvertpy.ERR_FS_CONFLICT
@@ -186,7 +199,8 @@ class SubversionRepo(object):
Note that password stores do not work, the parameter is only here
to ensure that the API is the same as for the SWIG wrapper.
"""
- def __init__(self, url='', username='', password='', head=None, password_stores=None):
+ def __init__(self, url='', username='', password='', head=None,
+ password_stores=None):
parsed = common.parse_url(url, username, password)
# --username and --password override URL credentials
self.username = parsed[0]
@@ -450,11 +464,17 @@ class SubversionRepo(object):
else:
# visiting a directory
- if path in addeddirs:
- direditor = editor.add_directory(path)
- elif path in deleteddirs:
+ if path in deleteddirs:
direditor = editor.delete_entry(path, base_revision)
- continue
+
+ if path not in addeddirs:
+ continue
+
+ if path in addeddirs:
+ frompath, fromrev = copies.get(path, (None, -1))
+ if frompath:
+ frompath = self.path2url(frompath)
+ direditor = editor.add_directory(path, frompath, fromrev)
else:
direditor = editor.open_directory(path)