Mercurial > hgsubversion
diff hgsubversion/svnmeta.py @ 952:9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Reverting a branch with a remove followed by a copy results in a branch
replacement. By default, branch replacements are handled by closing the
replaced branch and committing the new branch on top of it. But we do
not really want that when reverting a branch, we only want a linear
history with a changeset capturing the revert.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Tue, 16 Oct 2012 21:17:55 +0200 |
parents | a80b01ceb1fc |
children | 8b2480175bae |
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -544,7 +544,9 @@ class SVNMeta(object): # 1. Is the file located inside any currently known # branch? If yes, then we're done with it, this isn't # interesting. - # 2. Does the file have copyfrom information? If yes, then + # 2. Does the file have copyfrom information? If yes, and + # the branch is being replaced by what would be an + # ancestor, treat it as a regular revert. Otherwise, # we're done: this is a new branch, and we record the # copyfrom in added_branches if it comes from the root # of another branch, or create it from scratch. @@ -565,6 +567,18 @@ class SVNMeta(object): if paths[p].action == 'D': self.closebranches.add(br) # case 4 elif paths[p].action == 'R': + # Check the replacing source is not an ancestor + # branch of the branch being replaced, this + # would just be a revert. + cfi, cbr = self.split_branch_path( + paths[p].copyfrom_path, paths[p].copyfrom_rev)[:2] + if cfi == '': + cctx = self.repo[self.get_parent_revision( + paths[p].copyfrom_rev + 1, cbr)] + ctx = self.repo[self.get_parent_revision( + revision.revnum, br)] + if cctx and util.isancestor(ctx, cctx): + continue parent = self._determine_parent_branch( p, paths[p].copyfrom_path, paths[p].copyfrom_rev, revision.revnum)