Mercurial > hgsubversion
changeset 517:ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Enforce that returned tags are non-empty.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 16 Jan 2010 17:25:09 +0100 |
parents | f089f46729ee |
children | e37738d95b27 |
files | hgsubversion/editor.py hgsubversion/replay.py hgsubversion/stupid.py hgsubversion/svnmeta.py |
diffstat | 4 files changed, 37 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -193,7 +193,7 @@ class HgEditor(delta.Editor): if not fpath: return if (branch not in self.meta.branches and - not self.meta.is_path_tag(self.meta.remotename(branch))): + not self.meta.get_path_tag(self.meta.remotename(branch))): # we know this branch will exist now, because it has at least one file. Rock. self.meta.branches[branch] = None, 0, self.current.rev.revnum self.current.file = path @@ -235,12 +235,12 @@ class HgEditor(delta.Editor): if br_path is None or not copyfrom_path: return path if copyfrom_path: - tag = self.meta.is_path_tag(copyfrom_path) + tag = self.meta.get_path_tag(copyfrom_path) if tag not in self.meta.tags: tag = None - if not self.meta.is_path_valid(copyfrom_path) and not tag: - self.current.missing.add('%s/' % path) - return path + if not self.meta.is_path_valid(copyfrom_path): + self.current.missing.add('%s/' % path) + return path if tag: ci = self.meta.repo[self.meta.tags[tag]].extra()['convert_revision'] source_rev, source_branch, = self.meta.parse_converted_revision(ci)
--- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -128,12 +128,14 @@ def convert_rev(ui, meta, svn, r, tbdelt continue extra = meta.genextra(rev.revnum, branch) - tag = False + tag = None if branch is not None: - tag = meta.is_path_tag(meta.remotename(branch)) - if (not (tag and tag in meta.tags) and - (branch not in meta.branches - and branch not in meta.repo.branchtags())): + # New regular tag without modifications, it will be committed by + # svnmeta.committag(), we can skip the whole branch for now + tag = meta.get_path_tag(meta.remotename(branch)) + if (tag and tag not in meta.tags and + branch not in meta.branches + and branch not in meta.repo.branchtags()): continue parentctx = meta.repo.changectx(parents[0])
--- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -469,7 +469,7 @@ def branches_in_paths(meta, tbdelta, pat relpath, branch, branchpath = meta.split_branch_path(p) if relpath is not None: branches[branch] = branchpath - elif paths[p].action == 'D' and not meta.is_path_tag(p): + elif paths[p].action == 'D' and not meta.get_path_tag(p): ln = meta.localname(p) # must check in branches_to_delete as well, because this runs after we # already updated the branch map @@ -552,7 +552,7 @@ def convert_rev(ui, meta, svn, r, tbdelt deleted_branches = {} for p in r.paths: - if meta.is_path_tag(p): + if meta.get_path_tag(p): continue branch = meta.localname(p) if not (r.paths[p].action == 'R' and branch in meta.branches): @@ -618,9 +618,7 @@ def convert_rev(ui, meta, svn, r, tbdelt extra = meta.genextra(r.revnum, b) - tag = False - tag = meta.is_path_tag(meta.remotename(b)) - + tag = meta.get_path_tag(meta.remotename(b)) if tag: if parentctx.node() == node.nullid: continue @@ -642,7 +640,7 @@ def convert_rev(ui, meta, svn, r, tbdelt branch = extra.get('branch', None) if not tag: if (not branch in meta.branches - and not meta.is_path_tag(meta.remotename(branch))): + and not meta.get_path_tag(meta.remotename(branch))): meta.branches[branch] = None, 0, r.revnum meta.revmap[r.revnum, b] = ha else:
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -229,23 +229,21 @@ class SVNMeta(object): path = path[1:] return path - def is_path_tag(self, path): - """If path could represent the path to a tag, returns the potential tag - name. Otherwise, returns False. + def get_path_tag(self, path): + """If path could represent the path to a tag, returns the + potential (non-empty) tag name. Otherwise, returns None Note that it's only a tag if it was copied from the path '' in a branch (or tag) we have, for our purposes. """ - if self.layout == 'single': - return False - path = self.normalize(path) - for tagspath in self.tag_locations: - onpath = path.startswith(tagspath) - longer = len(path) > len('%s/' % tagspath) - if path and onpath and longer: - tag, subpath = path[len(tagspath) + 1:], '' - return tag - return False + if self.layout != 'single': + path = self.normalize(path) + for tagspath in self.tag_locations: + if path.startswith(tagspath + '/'): + tag = path[len(tagspath) + 1:] + if tag: + return tag + return None def split_branch_path(self, path, existing=True): """Figure out which branch inside our repo this path represents, and @@ -260,8 +258,8 @@ class SVNMeta(object): path = self.normalize(path) if self.layout == 'single': return (path, None, '') - if self.is_path_tag(path): - tag = self.is_path_tag(path) + tag = self.get_path_tag(path) + if tag: matched = [t for t in self.tags.iterkeys() if tag.startswith(t+'/')] if not matched: return None, None, None @@ -299,10 +297,10 @@ class SVNMeta(object): def _determine_parent_branch(self, p, src_path, src_rev, revnum): if src_path is not None: src_file, src_branch = self.split_branch_path(src_path)[:2] - src_tag = self.is_path_tag(src_path) - if src_tag != False or src_file == '': # case 2 + src_tag = self.get_path_tag(src_path) + if src_tag or src_file == '': ln = self.localname(p) - if src_tag != False and src_tag in self.tags: + if src_tag and src_tag in self.tags: ci = self.repo[self.tags[src_tag]].extra()['convert_revision'] src_rev, src_branch, = self.parse_converted_revision(ci) return {ln: (src_branch, src_rev, revnum)} @@ -350,7 +348,7 @@ class SVNMeta(object): def get_parent_revision(self, number, branch): '''Get the parent revision hash for a commit on a specific branch. ''' - tag = self.is_path_tag(self.remotename(branch)) + tag = self.get_path_tag(self.remotename(branch)) limitedtags = maps.TagMap(self.repo, endrev=number-1) if tag and tag in limitedtags: ha = limitedtags[tag] @@ -384,8 +382,8 @@ class SVNMeta(object): self.closebranches = set() tags_to_delete = set() for p in sorted(paths): - t_name = self.is_path_tag(p) - if t_name != False: + t_name = self.get_path_tag(p) + if t_name: src_p, src_rev = paths[p].copyfrom_path, paths[p].copyfrom_rev # if you commit to a tag, I'm calling you stupid and ignoring # you. @@ -393,7 +391,7 @@ class SVNMeta(object): file, branch = self.split_branch_path(src_p)[:2] if file is None: # some crazy people make tags from other tags - from_tag = self.is_path_tag(src_p) + from_tag = self.get_path_tag(src_p) if not from_tag: continue if from_tag in self.tags: @@ -527,7 +525,7 @@ class SVNMeta(object): branches.setdefault(branch, []).append(('rm', tag, None)) for b, tags in branches.iteritems(): - fromtag = self.is_path_tag(self.remotename(b)) + fromtag = self.get_path_tag(self.remotename(b)) # modify parent's .hgtags source parent = self.repo[self.get_parent_revision(rev.revnum, b)] if '.hgtags' not in parent: