From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toshio Kuratomi Newsgroups: gmane.comp.version-control.bazaar-ng.general,gmane.emacs.devel Subject: Re: Emacs Bazaar repository Date: Sun, 16 Mar 2008 16:47:37 -0500 Message-ID: <47DD9579.2050008@gmail.com> References: <87skyvse7k.fsf@xmission.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFC842E9A2B908F144BDD5ED9" X-Trace: ger.gmane.org 1205704084 8230 80.91.229.12 (16 Mar 2008 21:48:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Mar 2008 21:48:04 +0000 (UTC) Cc: bazaar@lists.canonical.com, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: bazaar-bounces@lists.canonical.com Sun Mar 16 22:48:31 2008 Return-path: Envelope-to: gcvbg-bazaar-ng@m.gmane.org Original-Received: from chlorine.canonical.com ([91.189.94.204]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jb0iP-0008Jm-3a for gcvbg-bazaar-ng@m.gmane.org; Sun, 16 Mar 2008 22:48:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1Jb0hn-0000gu-4K; Sun, 16 Mar 2008 21:47:47 +0000 Original-Received: from py-out-1112.google.com ([64.233.166.181]) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1Jb0hk-0000dc-2w for bazaar@lists.canonical.com; Sun, 16 Mar 2008 21:47:44 +0000 Original-Received: by py-out-1112.google.com with SMTP id a29so5957574pyi.0 for ; Sun, 16 Mar 2008 14:47:43 -0700 (PDT) Original-Received: by 10.65.234.2 with SMTP id l2mr29814626qbr.37.1205704061626; Sun, 16 Mar 2008 14:47:41 -0700 (PDT) Original-Received: from ?10.20.14.208? ( [63.250.241.10]) by mx.google.com with ESMTPS id q18sm18411027qbq.22.2008.03.16.14.47.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 16 Mar 2008 14:47:40 -0700 (PDT) User-Agent: Thunderbird 2.0.0.12 (X11/20080226) In-Reply-To: X-Enigmail-Version: 0.95.6 X-BeenThere: bazaar@lists.canonical.com X-Mailman-Version: 2.1.8 Precedence: list List-Id: bazaar discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bazaar-bounces@lists.canonical.com Errors-To: bazaar-bounces@lists.canonical.com Xref: news.gmane.org gmane.comp.version-control.bazaar-ng.general:38742 gmane.emacs.devel:92779 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFC842E9A2B908F144BDD5ED9 Content-Type: multipart/mixed; boundary="------------090204070401030503090007" This is a multi-part message in MIME format. --------------090204070401030503090007 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Stefan Monnier wrote: >> After a few false starts I have been successful (at least as far as I >> can tell) in importing the Emacs CVS repository into Bazaar. If anyon= e >> is interested in playing with the results you can check out the HEAD o= f >> the CVS repository with: >=20 > Another piece of information that I find missing is all the tags. > It seems they are present in the form of > http://bzr.notengoamigos.org/emacs/tags pseudo branches, but they're no= t > present in the form of actual Bzr tags. =20 I wrote a patch about six months to a year ago to deal with this. https://bugs.launchpad.net/bzr-cvsps-import/+bug/128326 I'm attaching the patch -- but it might need to be updated. -Toshio --------------090204070401030503090007 Content-Type: text/x-patch; name="bzr-cvsps-tags.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="bzr-cvsps-tags.patch" =3D=3D=3D modified file '__init__.py' --- __init__.py 2007-01-19 17:03:04 +0000 +++ __init__.py 2007-07-25 16:36:34 +0000 @@ -64,10 +64,14 @@ help=3D'Use cvs to extract texts.'), option.Option('use-rcs', help=3D'Use rcs to extract texts. (de= fault)'), + option.Option('use-dirstate-tags', + help=3D'Use bzr metadata tags rather = than' + ' a branch per tag'), ] =20 def run(self, cvsroot=3DNone, module=3DNone, output=3DNone, cvsps_du= mp=3DNone, - encoding=3DNone, verify=3DTrue, use_cvs=3DFalse, use_rcs=3DF= alse): + encoding=3DNone, verify=3DTrue, use_cvs=3DFalse, use_rcs=3DF= alse, + use_dirstate_tags=3DFalse): from cvsps import importer =20 if cvsroot.startswith(':pserver:') or cvsroot.startswith(':ext:'= ): @@ -78,11 +82,18 @@ if not use_cvs and not use_rcs: # Default is to use rcs, since it is slightly faster. use_cvs =3D False + + if use_dirstate_tags: + tag_style =3D 'dirstate' + else: + tag_style =3D 'branch' + importer =3D importer.Importer(cvsroot, module, output, cvsps_dump=3Dcvsps_dump, encoding=3Dencoding, verify=3Dverify, - use_cvs_for_text=3Duse_cvs) + use_cvs_for_text=3Duse_cvs, + tag_style=3Dtag_style) importer.process() =20 =20 =3D=3D=3D modified file 'cvsps/importer.py' --- cvsps/importer.py 2007-02-12 18:03:03 +0000 +++ cvsps/importer.py 2007-07-25 18:14:22 +0000 @@ -597,11 +597,12 @@ """ =20 def __init__(self, bzr_repo, cvs_root, cvs_module, map_file, - verify=3DTrue, use_cvs_for_text=3DTrue): + verify=3DTrue, use_cvs_for_text=3DTrue, tag_style=3DNon= e): self._bzr_repo =3D bzr_repo self._map_file =3D map_file self._cvs_root =3D cvs_root self._cvs_module =3D cvs_module + self._tag_style =3D tag_style or 'branch' =20 self._working_path =3D osutils.pathjoin( self._bzr_repo.bzrdir.root_transport.local_abspath('.'), @@ -623,7 +624,7 @@ self._n_existing_patches =3D 0 self._n_tags =3D 0 =20 - def handle_patchset(self, patchset): + def handle_patchset(self, patchset, pb): """Handle one of the patchsets from cvs to bzr""" =20 revision_id =3D self._map_file.get(patchset.num) @@ -653,7 +654,11 @@ self._n_patches +=3D 1 =20 if patchset.tag is not None: - self._handle_tag(patchset, revision_id) + if self._tag_style =3D=3D 'dirstate': + self._handle_tag_dirstate(patchset, revision_id, pb) + else: + self._handle_tag_branch(patchset, revision_id) + action +=3D '+tag' =20 return revision_id, action @@ -830,8 +835,13 @@ os.makedirs(branch_path) =20 # Create a new one + format =3D bzrdir.BzrDirFormat.get_default_format() + if self._tag_style =3D=3D 'dirstate' and not format.get_branch_f= ormat().supports_tags(): + format =3D bzrdir.format_registry.get('dirstate-tags')() + target_branch =3D bzrdir.BzrDir.create_branch_convenience(branch= _path, - force_new_tree=3D= False) + force_new_tree=3D= False, + format=3Dformat= ) self._set_repo(target_branch) target_branch.lock_write() self._cache_branch(patchset.branch, target_branch) @@ -875,7 +885,23 @@ =20 return revision_id =20 - def _handle_tag(self, patchset, revision_id): + def _handle_tag_dirstate(self, patchset, revision_id, pb): + """Create a tag with the given revision id.""" + # TODO: toshio 20070725 We probably want to check that the branc= h + # format supports tags and convert it if it doesn't. However, t= he + # repository is locked at this point so it's not as simple as th= e + # below code. + # + # Currently, I'm making sure that the branches support tags when= + # we create them. + #if not self._cur_bzr_branch.supports_tags(): + # newFormat =3D bzrdir.format_registry.get('dirstate-tags')()= + # converter =3D self._cur_bzr_branch.bzrdir._format.get_conve= rter(newFormat) + # self._cur_bzr_branch =3D converter.convert(self._cur_bzr_br= anch.bzrdir, pb) + self._cur_bzr_branch.tags.set_tag(patchset.tag, revision_id) + self._n_tags +=3D 1 + + def _handle_tag_branch(self, patchset, revision_id): """Create a tag with the given revision id.""" tag_branch_path =3D self._get_tag_branch_path(patchset.tag) try: @@ -969,10 +995,12 @@ """Import a CVS project into bzr.""" =20 def __init__(self, cvsroot, cvs_module, output_base, cvsps_dump=3DNo= ne, - encoding=3DNone, verify=3DTrue, use_cvs_for_text=3DTrue= ): + encoding=3DNone, verify=3DTrue, use_cvs_for_text=3DTrue= , + tag_style=3DNone): self._cvs_root =3D osutils.abspath(cvsroot) self._cvs_module =3D cvs_module self._use_cvs_for_text =3D use_cvs_for_text + self._tag_style =3D tag_style or 'branch' self._verify =3D verify =20 self.output_base =3D output_base @@ -1016,7 +1044,7 @@ os.makedirs(path) self._paths_created =3D True =20 - def open_or_create_bzr_repo(self): + def open_or_create_bzr_repo(self, pb): """Open the bzr repository, creating it if needed.""" self.setup_directories() bzr_repo_transport =3D transport.get_transport(self._repo_path) @@ -1024,6 +1052,11 @@ a_bzrdir =3D bzrdir.BzrDir.open_from_transport(bzr_repo_tran= sport) except errors.NotBranchError: return self._create_bzr_repo(bzr_repo_transport) + if self._tag_style =3D=3D 'dirstate' and ( + not a_bzrdir.find_branch_format().supports_tags()): + newFormat =3D bzrdir.format_registry.get('dirstate-tags')() + converter =3D a_bzrdir._format.get_converter(newFormat) + a_bzrdir =3D converter.convert(a_bzrdir, pb) return a_bzrdir.open_repository() =20 def _create_bzr_repo(self, a_transport): @@ -1033,6 +1066,10 @@ except errors.FileExists: pass fmt =3D bzrdir.BzrDirFormat.get_default_format() + if self._tag_style =3D=3D 'dirstate' and not ( + fmt.get_branch_format().supports_tags()): + fmt =3D bzrdir.format_registry.get('dirstate-tags')() + control =3D fmt.initialize_on_transport(a_transport) repo =3D control.create_repository(shared=3DTrue) repo.set_make_working_trees(False) @@ -1065,7 +1102,7 @@ n_patchsets =3D len(patchsets) for i, patchset in enumerate(patchsets): try: - rev_id, action =3D cvs_to_bzr.handle_patchset(patchset) + rev_id, action =3D cvs_to_bzr.handle_patchset(patchset, = pb) except KeyboardInterrupt: if pb is not None: pb.clear() @@ -1101,7 +1138,11 @@ =20 def process(self): """Start converting the repository.""" - repo =3D self.open_or_create_bzr_repo() + pb =3D ui.ui_factory.nested_progress_bar() + try: + repo =3D self.open_or_create_bzr_repo(pb=3Dpb) + finally: + pb.finished() # Maintain a repository wide lock for the whole transaction # that should help cache stuff. # TODO: jam 20061121 This may actually cache *too* much. Conside= r @@ -1115,7 +1156,8 @@ try: cvs_to_bzr =3D CVSToBzr(repo, self._cvs_root, self._cvs_= module, map_file, verify=3Dself._verify, - use_cvs_for_text=3Dself._use_cvs_f= or_text) + use_cvs_for_text=3Dself._use_cvs_f= or_text, + tag_style=3Dself._tag_style) start_time =3D time.time() pb =3D ui.ui_factory.nested_progress_bar() try: --------------090204070401030503090007-- --------------enigFC842E9A2B908F144BDD5ED9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH3ZV5X6yAic2E7kgRAk2RAJ0fDsAZm08hxpR3N4goODGVtzQc6wCdFVBu m/Va70dEJ1W6QHM1b20letc= =AVr7 -----END PGP SIGNATURE----- --------------enigFC842E9A2B908F144BDD5ED9--