Running version-info fails when there is no work tree

Bug #2004542 reported by Björn Lindström
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Breezy
Fix Released
Low
Jelmer Vernooij

Bug Description

Have some legacy tooling that need to run Bazaar like this on a shared repo without a worktree. Caveat for if I don't get the terminology quite right.

----
$ bzr version-info --all /path/to/shared/repo/without/worktree/
Traceback (most recent call last):
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/commands.py", line 1017, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/commands.py", line 1206, in run_bzr
    ret = run(*run_argv)
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/commands.py", line 757, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/commands.py", line 782, in run
    return class_run(*args, **kwargs)
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/cmd_version_info.py", line 139, in run
    builder.generate(self.outf)
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/version_info_formats/format_rio.py", line 61, in generate
    self._extract_file_revisions()
  File "/opt/breezy/lib64/python3.6/site-packages/breezy/version_info_formats/__init__.py", line 96, in _extract_file_revisions
    basis_tree = self._working_tree.basis_tree()
AttributeError: 'NoneType' object has no attribute 'basis_tree'

brz 3.2.2 on python 3.6.8 (Linux-4.18.0-425.10.1.el8_7.x86_64-x86_64-with-
    redhat-8.7-Ootpa)
arguments: ['/bin/bzr', 'version-info', '--all', '/path/to/shared/repo/without/worktree/']
plugins: bash_completion[3.2.2], changelog_merge[3.2.2],
    commitfromnews[3.2.2], cvs[3.2.2], darcs[3.2.2], email[3.2.2],
    fastimport[3.2.2], flake8[unknown], fossil[3.2.2], github[3.2.2],
    gitlab[3.2.2], hg[3.2.2], launchpad[3.2.2], mtn[3.2.2],
    netrc_credential_store[3.2.2], news_merge[3.2.2], po_merge[3.2.2],
    propose[3.2.2], pypi[3.2.2], quilt[unknown], repodebug[3.2.2],
    rewrite[unknown], stats[3.2.2], svn[3.2.2], upload[3.2.2],
    weave_fmt[3.2.2], zsh_completion[3.2.2]
encoding: 'utf-8', fsenc: 'utf-8', lang: 'en_US.UTF-8'

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/brz/+filebug
    including this traceback and a description of the problem.
----

For now I'm using this patch, which seems to be working so far:

----
diff -Naru breezy-3.2.2.orig/breezy/version_info_formats/__init__.py breezy-3.2.2/breezy/version_info_formats/__init__.py
--- breezy-3.2.2.orig/breezy/version_info_formats/__init__.py 2021-12-07 02:24:26.000000000 +0000
+++ breezy-3.2.2/breezy/version_info_formats/__init__.py 2023-02-01 11:53:28.383389156 +0000
@@ -89,6 +89,9 @@
     def _extract_file_revisions(self):
         """Extract the working revisions for all files"""

+ if self._working_tree is None:
+ return None
+
         # Things seem clean if we never look :)
         self._clean = True

----

Submitting this here as a suggested change, as it seems to make sense that if there is no worktree, there is no need to inspect any files in it.

Related branches

Jelmer Vernooij (jelmer)
Changed in brz:
status: New → Fix Committed
importance: Undecided → Low
assignee: nobody → Jelmer Vernooij (jelmer)
milestone: none → 3.3.3
Revision history for this message
Björn Lindström (bkhl) wrote :

Jelmer, thanks for the quick response!

Jelmer Vernooij (jelmer)
Changed in brz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.