Mercurial > hg
diff hgext/convert/subversion.py @ 16466:c53a49c345e1 stable
convert/svn: do not try converting empty head revisions (issue3347)
Subversion conversion works by picking trunk and branches heads, computing a
revision graph from them and converting the selected commits. By design we fail
to convert empty revisions so we have to be careful when discovering the
revision graph. In this particular issue, the source svn repository was a
partial mirror made by svnsync. The funny part is svnsync preserves all
revisions including empty ones. Also, we trusted ra.stat(path,
stop).created_rev to give us the latest revision with changes in path history
up to stop. This assumption broke at least when path is '', that is the
repository root, which always returned 'stop' revision despited being empty.
The workaround is to first trust ra.stat() but if the returned revision appear
empty, search the whole path history from stop to r1 until some changes are
found.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Wed, 18 Apr 2012 14:04:58 +0200 |
parents | ad38b96c88f9 |
children | ecd2fbe68b25 |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Wed Apr 18 14:04:58 2012 +0200 +++ b/hgext/convert/subversion.py Wed Apr 18 14:04:58 2012 +0200 @@ -563,11 +563,15 @@ reported. Return None if computed module does not belong to rootmodule subtree. """ - def findchanges(path, start, stop): - stream = self._getlog([path], start, stop) + def findchanges(path, start, stop=None): + stream = self._getlog([path], start, stop or 1) try: for entry in stream: paths, revnum, author, date, message = entry + if stop is None and paths: + # We do not know the latest changed revision, + # keep the first one with changed paths. + break if revnum <= stop: break @@ -580,6 +584,8 @@ (path, newpath, revnum)) path = newpath break + if not paths: + revnum = None return revnum, path finally: stream.close() @@ -605,6 +611,19 @@ # development, but it might be in *another module*. Fetch the # log and detect renames down to the latest revision. revnum, realpath = findchanges(path, stop, dirent.created_rev) + if revnum is None: + # Tools like svnsync can create empty revision, when + # synchronizing only a subtree for instance. These empty + # revisions created_rev still have their original values + # despite all changes having disappeared and can be + # returned by ra.stat(), at least when stating the root + # module. In that case, do not trust created_rev and scan + # the whole history. + revnum, realpath = findchanges(path, stop) + if revnum is None: + self.ui.debug('ignoring empty branch %r\n' % realpath) + return None + if not realpath.startswith(self.rootmodule): self.ui.debug('ignoring foreign branch %r\n' % realpath) return None