convert: add a config knob for not saving the bzr revision
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 05 Jul 2018 15:07:29 -0400
changeset 38572 85da230c316a
parent 38571 30a027c0e327
child 38573 050fbd9d103a
convert: add a config knob for not saving the bzr revision Now that the timestamp is fixed, the log of the Mercurial repo is still unstable with --debug, because the bzr commit ID keeps changing. Both hg and git implement `convert.*.saverev`, so do the same here.
hgext/convert/__init__.py
hgext/convert/bzr.py
mercurial/configitems.py
tests/test-convert-bzr-merges.t
tests/test-convert.t
--- a/hgext/convert/__init__.py	Thu Jul 05 15:07:29 2018 -0400
+++ b/hgext/convert/__init__.py	Thu Jul 05 15:07:29 2018 -0400
@@ -204,6 +204,14 @@
 
     :convert.hg.revs: revset specifying the source revisions to convert.
 
+    Bazaar Source
+    #############
+
+    The following options can be used with ``--config``:
+
+    :convert.bzr.saverev: whether to store the original Bazaar commit ID in
+        the metadata of the destination commit. The default is True.
+
     CVS Source
     ##########
 
--- a/hgext/convert/bzr.py	Thu Jul 05 15:07:29 2018 -0400
+++ b/hgext/convert/bzr.py	Thu Jul 05 15:07:29 2018 -0400
@@ -65,6 +65,7 @@
             raise common.NoRepo(_('%s does not look like a Bazaar repository')
                               % path)
         self._parentids = {}
+        self._saverev = ui.configbool('convert', 'bzr.saverev')
 
     def _checkrepotype(self, path):
         # Lightweight checkouts detection is informational but probably
@@ -175,7 +176,8 @@
                 author=self.recode(rev.committer),
                 desc=self.recode(rev.message),
                 branch=branch,
-                rev=version)
+                rev=version,
+                saverev=self._saverev)
 
     def gettags(self):
         bytetags = {}
--- a/mercurial/configitems.py	Thu Jul 05 15:07:29 2018 -0400
+++ b/mercurial/configitems.py	Thu Jul 05 15:07:29 2018 -0400
@@ -209,6 +209,9 @@
     default=None,
     generic=True,
 )
+coreconfigitem('convert', 'bzr.saverev',
+    default=True,
+)
 coreconfigitem('convert', 'cvsps.cache',
     default=True,
 )
--- a/tests/test-convert-bzr-merges.t	Thu Jul 05 15:07:29 2018 -0400
+++ b/tests/test-convert-bzr-merges.t	Thu Jul 05 15:07:29 2018 -0400
@@ -39,7 +39,7 @@
   $ bzr merge -q --force ../source-branch2
   $ bzr commit -q -m 'Merged branches' '--commit-time=2009-10-10 08:00:04 +0100'
   $ cd ..
-  $ hg convert --datesort source source-hg
+  $ hg convert --datesort --config convert.bzr.saverev=False source source-hg
   initializing destination source-hg repository
   scanning source...
   sorting...
--- a/tests/test-convert.t	Thu Jul 05 15:07:29 2018 -0400
+++ b/tests/test-convert.t	Thu Jul 05 15:07:29 2018 -0400
@@ -148,6 +148,15 @@
       convert.hg.revs
                     revset specifying the source revisions to convert.
   
+      Bazaar Source
+      #############
+  
+      The following options can be used with "--config":
+  
+      convert.bzr.saverev
+                    whether to store the original Bazaar commit ID in the
+                    metadata of the destination commit. The default is True.
+  
       CVS Source
       ##########