summaryrefslogtreecommitdiff
path: root/hgsubversion/svnmeta.py
diff options
context:
space:
mode:
Diffstat (limited to 'hgsubversion/svnmeta.py')
-rw-r--r--hgsubversion/svnmeta.py97
1 files changed, 70 insertions, 27 deletions
diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py
index a7d652c..7f5a79a 100644
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -26,8 +26,7 @@ class SVNMeta(object):
# simple and public variables
self.ui = repo.ui
self.repo = repo
- self.path = os.path.normpath(repo.join('..'))
- self.firstpulled = 0
+ self.path = os.path.normpath(repo.vfs.join('..'))
self.lastdate = '1970-01-01 00:00:00 -0000'
self.addedtags = {}
self.deletedtags = {}
@@ -52,9 +51,9 @@ class SVNMeta(object):
self.subdir = subdir
# generated properties that have a persistent file stored on disk
- self._gen_cachedconfig('lastpulled', 0, configname=False)
self._gen_cachedconfig('defaultauthors', True)
self._gen_cachedconfig('caseignoreauthors', False)
+ self._gen_cachedconfig('mapauthorscmd', None)
self._gen_cachedconfig('defaulthost', self.uuid)
self._gen_cachedconfig('usebranchnames', True)
self._gen_cachedconfig('defaultmessage', '')
@@ -69,7 +68,7 @@ class SVNMeta(object):
"""Return a cached value for a config option. If the cache is uninitialized
then try to read its value from disk. Option can be overridden by the
commandline.
- name: property name, e.g. 'lastpulled'
+ name: property name, e.g. 'defaultauthors'
filename: name of file in .hg/svn
configname: commandline option name
default: default value
@@ -94,6 +93,8 @@ class SVNMeta(object):
c = self.ui.configint('hgsubversion', configname, default)
elif isinstance(default, list):
c = self.ui.configlist('hgsubversion', configname, default)
+ elif isinstance(default, dict):
+ c = dict(self.ui.configitems(configname))
else:
c = self.ui.config('hgsubversion', configname, default)
@@ -136,14 +137,14 @@ class SVNMeta(object):
filename = name
if configname is None:
configname = name
- prop = property(lambda x: self._get_cachedconfig(name,
- filename,
- configname,
- default,
- pre=pre),
- lambda x, y: self._set_cachedconfig(y,
- name,
- filename))
+ prop = property(lambda x: x._get_cachedconfig(name,
+ filename,
+ configname,
+ default,
+ pre=pre),
+ lambda x, y: x._set_cachedconfig(y,
+ name,
+ filename))
setattr(SVNMeta, name, prop)
def layout_from_subversion(self, svn, revision=None):
@@ -218,7 +219,7 @@ class SVNMeta(object):
@property
def editor(self):
- if not hasattr(self, '_editor'):
+ if not hgutil.safehasattr(self, '_editor'):
self._editor = editor.HgEditor(self)
return self._editor
@@ -284,13 +285,15 @@ class SVNMeta(object):
return os.path.join(self.metapath, 'branch_info')
@property
- def authors_file(self):
+ def authormap_file(self):
return os.path.join(self.metapath, 'authors')
@property
def authors(self):
if self._authors is None:
- self._authors = maps.AuthorMap(self)
+ self._authors = maps.AuthorMap(
+ self.ui, self.authormap_file, self.defaulthost,
+ self.caseignoreauthors, self.mapauthorscmd, self.defaultauthors)
return self._authors
@property
@@ -300,7 +303,7 @@ class SVNMeta(object):
@property
def filemap(self):
if self._filemap is None:
- self._filemap = maps.FileMap(self)
+ self._filemap = maps.FileMap(self.ui, self.filemap_file)
return self._filemap
@property
@@ -310,7 +313,7 @@ class SVNMeta(object):
@property
def branchmap(self):
if self._branchmap is None:
- self._branchmap = maps.BranchMap(self)
+ self._branchmap = maps.BranchMap(self.ui, self.branchmap_file)
return self._branchmap
@property
@@ -321,7 +324,7 @@ class SVNMeta(object):
@property
def tags(self):
if self._tags is None:
- self._tags = maps.Tags(self)
+ self._tags = maps.Tags(self.ui, self.tagfile)
return self._tags
@property
@@ -332,7 +335,7 @@ class SVNMeta(object):
@property
def tagmap(self):
if self._tagmap is None:
- self._tagmap = maps.TagMap(self)
+ self._tagmap = maps.TagMap(self.ui, self.tagmap_file)
return self._tagmap
@property
@@ -342,9 +345,34 @@ class SVNMeta(object):
@property
def revmap(self):
if self._revmap is None:
- self._revmap = maps.RevMap(self)
+ lastpulled_path = os.path.join(self.metapath, 'lastpulled')
+ opts = {}
+ if self.revmapclass is maps.SqliteRevMap:
+ # sqlite revmap takes an optional option: sqlitepragmas
+ opts['sqlitepragmas'] = self.ui.configlist(
+ 'hgsubversion', 'sqlitepragmas')
+ self._revmap = self.revmapclass(
+ self.revmap_file, lastpulled_path, **opts)
return self._revmap
+ @property
+ def revmapexists(self):
+ return os.path.exists(self.revmap_file)
+
+ _defaultrevmapclass = maps.RevMap
+
+ @property
+ def revmapclass(self):
+ impl = self.ui.config('hgsubversion', 'revmapimpl')
+ if impl == 'plain':
+ return maps.RevMap
+ elif impl == 'sqlite':
+ return maps.SqliteRevMap
+ elif impl is None:
+ return self._defaultrevmapclass
+ else:
+ raise hgutil.Abort('unknown revmapimpl: %s' % impl)
+
def fixdate(self, date):
if date is not None:
date = date.replace('T', ' ').replace('Z', '').split('.')[0]
@@ -388,6 +416,19 @@ class SVNMeta(object):
}
return extra
+ def skipbranch(self, name):
+ '''Returns whether or not we're skipping a branch.'''
+ # sometimes it's easier to pass the path instead of just the branch
+ # name, so we test for that here
+ if name:
+ bname = self.split_branch_path(name)
+ if bname != (None, None, None):
+ name = bname[1]
+
+ # if the mapped branch == '' and the original branch name == '' then we
+ # won't commit this branch
+ return name and not self.branchmap.get(name, True)
+
def mapbranch(self, extra, close=False):
if close:
extra['close'] = 1
@@ -440,6 +481,13 @@ class SVNMeta(object):
path = self.normalize(path)
return self.layoutobj.get_path_tag(path, self.layoutobj.taglocations)
+ def get_tag_path(self, name):
+ """Return a path corresponding to the given tag name"""
+ try:
+ return self.layoutobj.taglocations[0] + '/' + name
+ except IndexError:
+ return None
+
def split_branch_path(self, path, existing=True):
"""Figure out which branch inside our repo this path represents, and
also figure out which path inside that branch it is.
@@ -531,12 +579,7 @@ class SVNMeta(object):
"""
if (number, branch) in self.revmap:
return number, branch
- real_num = 0
- for num, br in self.revmap.iterkeys():
- if br != branch:
- continue
- if num <= number and num > real_num:
- real_num = num
+ real_num = self.revmap.branchmaxrevnum(branch, number)
if branch in self.branches:
parent_branch = self.branches[branch][0]
parent_branch_rev = self.branches[branch][1]
@@ -576,7 +619,7 @@ class SVNMeta(object):
return node.hex(self.revmap[tagged])
tag = fromtag
# Reference an existing tag
- limitedtags = maps.Tags(self, endrev=number - 1)
+ limitedtags = maps.Tags(self.ui, self.tagfile, endrev=number - 1)
if tag in limitedtags:
return limitedtags[tag]
r, br = self.get_parent_svn_branch_and_rev(number - 1, branch, exact)