Mercurial > hg-stable
changeset 6539:7814d7bb77bc
convert: rename get_entry_from_path() into an svn_source method
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 14 Apr 2008 22:31:33 +0200 |
parents | 05dff77bfbd9 |
children | 55bd855fc0af |
files | hgext/convert/subversion.py |
diffstat | 1 files changed, 29 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Mon Apr 14 22:31:33 2008 +0200 +++ b/hgext/convert/subversion.py Mon Apr 14 22:31:33 2008 +0200 @@ -537,24 +537,6 @@ svn.ra.reparent(self.ra, svn_url.encode(self.encoding)) def expandpaths(self, rev, paths, parents): - def get_entry_from_path(path, module=self.module): - # Given the repository url of this wc, say - # "http://server/plone/CMFPlone/branches/Plone-2_0-branch" - # extract the "entry" portion (a relative path) from what - # svn log --xml says, ie - # "/CMFPlone/branches/Plone-2_0-branch/tests/PloneTestCase.py" - # that is to say "tests/PloneTestCase.py" - if path.startswith(module): - relative = path.rstrip('/')[len(module):] - if relative.startswith('/'): - return relative[1:] - elif relative == '': - return relative - - # The path is outside our tracked tree... - self.ui.debug('%r is not under %r, ignoring\n' % (path, module)) - return None - entries = [] copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions. copies = {} @@ -565,13 +547,13 @@ self.reparent(self.module) for path, ent in paths: - entrypath = get_entry_from_path(path, module=self.module) + entrypath = self.getrelpath(path) entry = entrypath.decode(self.encoding) kind = svn.ra.check_path(self.ra, entrypath, revnum) if kind == svn.core.svn_node_file: if ent.copyfrom_path: - copyfrom_path = get_entry_from_path(ent.copyfrom_path) + copyfrom_path = self.getrelpath(ent.copyfrom_path) if copyfrom_path: self.ui.debug("Copied to %s from %s@%s\n" % (entrypath, copyfrom_path, @@ -592,8 +574,8 @@ # a root revision. uuid, old_module, fromrev = self.revsplit(parents[0]) - basepath = old_module + "/" + get_entry_from_path(path, module=self.module) - entrypath = old_module + "/" + get_entry_from_path(path, module=self.module) + basepath = old_module + "/" + self.getrelpath(path) + entrypath = basepath def lookup_parts(p): rc = None @@ -649,7 +631,7 @@ # parent in the same commit? (probably can). Could # cause problems if instead of revnum -1, # we have to look in (copyfrom_path, revnum - 1) - entrypath = get_entry_from_path("/" + child, module=old_module) + entrypath = self.getrelpath("/" + child, module=old_module) if entrypath: entry = self.recode(entrypath.decode(self.encoding)) if entry in copies: @@ -682,7 +664,7 @@ # parent in the same commit? (probably can). Could # cause problems if instead of revnum -1, # we have to look in (copyfrom_path, revnum - 1) - entrypath = get_entry_from_path("/" + child, module=self.module) + entrypath = self.getrelpath("/" + child) # print child, self.module, entrypath if entrypath: # Need to filter out directories here... @@ -693,20 +675,9 @@ # Copies here (must copy all from source) # Probably not a real problem for us if # source does not exist - - # Can do this with the copy command "hg copy" - # if ent.copyfrom_path: - # copyfrom_entry = get_entry_from_path(ent.copyfrom_path.decode(self.encoding), - # module=self.module) - # copyto_entry = entrypath - # - # print "copy directory", copyfrom_entry, 'to', copyto_entry - # - # copies.append((copyfrom_entry, copyto_entry)) - if ent.copyfrom_path: copyfrom_path = ent.copyfrom_path.decode(self.encoding) - copyfrom_entry = get_entry_from_path(copyfrom_path, module=self.module) + copyfrom_entry = self.getrelpath(copyfrom_path) if copyfrom_entry: copyfrom[path] = ent self.ui.debug("mark %s came from %s\n" % (path, copyfrom[path])) @@ -717,12 +688,12 @@ children = self._find_children(self.recode(copyfrom_path), ent.copyfrom_rev) children.sort() for child in children: - entrypath = get_entry_from_path("/" + child, module=self.module) + entrypath = self.getrelpath("/" + child) if entrypath: entry = entrypath.decode(self.encoding) # print "COPY COPY From", copyfrom_entry, entry copyto_path = path + entry[len(copyfrom_entry):] - copyto_entry = get_entry_from_path(copyto_path, module=self.module) + copyto_entry = self.getrelpath(copyto_path) # print "COPY", entry, "COPY To", copyto_entry copies[self.recode(copyto_entry)] = self.recode(entry) # copy from quux splort/quuxfile @@ -887,6 +858,26 @@ rpath = '/'.join([self.base, path]).strip('/') return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()] + def getrelpath(self, path, module=None): + if module is None: + module = self.module + # Given the repository url of this wc, say + # "http://server/plone/CMFPlone/branches/Plone-2_0-branch" + # extract the "entry" portion (a relative path) from what + # svn log --xml says, ie + # "/CMFPlone/branches/Plone-2_0-branch/tests/PloneTestCase.py" + # that is to say "tests/PloneTestCase.py" + if path.startswith(module): + relative = path.rstrip('/')[len(module):] + if relative.startswith('/'): + return relative[1:] + elif relative == '': + return relative + + # The path is outside our tracked tree... + self.ui.debug('%r is not under %r, ignoring\n' % (path, module)) + return None + pre_revprop_change = '''#!/bin/sh REPOS="$1"