# HG changeset patch # User Augie Fackler # Date 1241817068 18000 # Node ID b6c6d32c8ef1e83c2c4cdcb144da5b477a4e3332 # Parent 1ba8ed29148ef89a89cfcd4164eef3278db8e894 Add an option to clone without branch names. diff --git a/__init__.py b/__init__.py --- a/__init__.py +++ b/__init__.py @@ -68,6 +68,7 @@ def uisetup(ui): ('', 'svn-authors', '', 'username mapping filename'), ('', 'svn-filemap', '', 'remap file to exclude paths or include only certain paths'), + ('', 'svn-no-branchnames', False, "don't record branch names in hg"), ]) try: diff --git a/hg_delta_editor.py b/hg_delta_editor.py --- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -633,6 +633,9 @@ class HgChangeReceiver(delta.Editor): def del_all_files(*args): raise IOError files = parentctx.manifest().keys() + extra = {} + if not self.opts.get('svn_no_branchnames', False): + extra['branch'] = 'closed-branches' current_ctx = context.memctx(self.repo, parents, rev.message or ' ', @@ -640,7 +643,7 @@ class HgChangeReceiver(delta.Editor): del_all_files, self.authors[rev.author], date, - {'branch': 'closed-branches'}) + extra) new_hash = self.repo.commitctx(current_ctx) self.ui.status('Marked branch %s as closed.\n' % (branch or 'default')) @@ -686,6 +689,8 @@ class HgChangeReceiver(delta.Editor): data=data, islink=is_link, isexec=is_exec, copied=copied) + if self.opts.get('svn_no_branchnames', False): + extra.pop('branch', None) current_ctx = context.memctx(self.repo, parents, rev.message or '...', @@ -713,6 +718,8 @@ class HgChangeReceiver(delta.Editor): extra = util.build_extra(rev.revnum, branch, open(self.uuid_file).read(), self.subdir) + if self.opts.get('svn_no_branchnames', False): + extra.pop('branch', None) current_ctx = context.memctx(self.repo, (ha, node.nullid), rev.message or ' ', diff --git a/stupid.py b/stupid.py --- a/stupid.py +++ b/stupid.py @@ -526,8 +526,10 @@ def svn_server_pull_rev(ui, svn, hg_edit hg_editor.authors[r.author], date, extra) - ha = hg_editor.repo.commitctx(current_ctx) branch = extra.get('branch', None) + if hg_editor.opts.get('svn_no_branchnames', False): + extra.pop('branch', None) + ha = hg_editor.repo.commitctx(current_ctx) if not branch in hg_editor.branches: hg_editor.branches[branch] = None, 0, r.revnum hg_editor.add_to_revmap(r.revnum, b, ha) @@ -558,6 +560,9 @@ def svn_server_pull_rev(ui, svn, hg_edit if 'closed-branches' in hg_editor.repo.branchtags(): closed = hg_editor.repo['closed-branches'].node() parents = (parent, closed) + extra = {} + if not hg_editor.opts.get('svn_no_branchnames', False): + extra['branch'] = 'closed-branches' current_ctx = context.memctx(hg_editor.repo, parents, r.message or util.default_commit_msg, @@ -565,7 +570,7 @@ def svn_server_pull_rev(ui, svn, hg_edit filectxfn, hg_editor.authors[r.author], date, - {'branch': 'closed-branches'}) + extra) ha = hg_editor.repo.commitctx(current_ctx) ui.status('Marked branch %s as closed.\n' % (b or 'default')) hg_editor._save_metadata() diff --git a/wrappers.py b/wrappers.py --- a/wrappers.py +++ b/wrappers.py @@ -283,6 +283,7 @@ def pull(orig, ui, repo, source="default tag_locations=tag_locations, authors=authors, filemap=filemap) + hg_editor.opts = opts if os.path.exists(hg_editor.uuid_file): uuid = open(hg_editor.uuid_file).read() assert uuid == svn.uuid