Merge lp:~gz/brz/relocate_brz_log into lp:brz

Proposed by Martin Packman
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~gz/brz/relocate_brz_log
Merge into: lp:brz
Diff against target: 469 lines (+62/-78)
12 files modified
breezy/bedding.py (+3/-1)
breezy/gpg.py (+1/-1)
breezy/help_topics/__init__.py (+3/-3)
breezy/help_topics/en/missing-extensions.txt (+1/-1)
breezy/tests/__init__.py (+4/-4)
breezy/tests/blackbox/test_version.py (+9/-9)
breezy/trace.py (+12/-17)
breezy/transport/log.py (+2/-2)
doc/developers/apport.txt (+2/-2)
doc/developers/authentication-ring.txt (+1/-1)
doc/developers/integration.txt (+23/-36)
doc/developers/profiling.txt (+1/-1)
To merge this branch: bzr merge lp:~gz/brz/relocate_brz_log
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+368886@code.launchpad.net

Commit message

Relocate the bzr log file out of $HOME.

Description of the change

Relocate the bzr log file out of $HOME

Now under $XDG_CACHE_HOME on nix and %LOCALAPPDATA% on windows.

Setting $BRZ_HOME will override the cache location, to simplify test
isolation, and $BRZ_LOG is still the final word.

Drive-by fix various docs around bzr/brz spelling.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bedding.py'
2--- breezy/bedding.py 2019-06-16 01:03:51 +0000
3+++ breezy/bedding.py 2019-06-16 20:07:06 +0000
4@@ -169,8 +169,10 @@
5
6 def cache_dir():
7 """Return the cache directory to use."""
8+ base = osutils.path_from_environ('BRZ_HOME')
9 if sys.platform in "win32":
10- base = win32utils.get_local_appdata_location()
11+ if base is None:
12+ base = win32utils.get_local_appdata_location()
13 if base is None:
14 base = win32utils.get_home_location()
15 else:
16
17=== modified file 'breezy/gpg.py'
18--- breezy/gpg.py 2018-01-24 07:51:44 +0000
19+++ breezy/gpg.py 2019-06-16 20:07:06 +0000
20@@ -177,7 +177,7 @@
21 else:
22 # This is not quite worthy of a warning, because some people
23 # don't need GPG_TTY to be set. But it is worthy of a big mark
24- # in ~/.brz.log, so that people can debug it if it happens to them
25+ # in brz.log, so that people can debug it if it happens to them
26 trace.mutter('** Env var TTY empty, cannot set GPG_TTY.'
27 ' Is TTY exported?')
28
29
30=== modified file 'breezy/help_topics/__init__.py'
31--- breezy/help_topics/__init__.py 2018-11-20 23:50:57 +0000
32+++ breezy/help_topics/__init__.py 2019-06-16 20:07:06 +0000
33@@ -601,8 +601,8 @@
34 ("BRZ_HOME (Win32)", "Directory holding breezy config dir. Overrides APPDATA and HOME."),
35 ("BZR_REMOTE_PATH", "Full name of remote 'brz' command (for brz+ssh:// URLs)."),
36 ("BRZ_SSH", "Path to SSH client, or one of paramiko, openssh, sshcorp, plink or lsh."),
37- ("BRZ_LOG", "Location of .brz.log (use '/dev/null' to suppress log)."),
38- ("BRZ_LOG (Win32)", "Location of .brz.log (use 'NUL' to suppress log)."),
39+ ("BRZ_LOG", "Location of brz.log (use '/dev/null' to suppress log)."),
40+ ("BRZ_LOG (Win32)", "Location of brz.log (use 'NUL' to suppress log)."),
41 ("BRZ_COLUMNS", "Override implicit terminal width."),
42 ("BRZ_CONCURRENCY", "Number of processes that can be run concurrently (selftest)"),
43 ("BRZ_PROGRESS_BAR", "Override the progress display. Values are 'none' or 'text'."),
44@@ -634,7 +634,7 @@
45 r"""Files
46
47 :On Unix: ~/.config/breezy/breezy.conf
48-:On Windows: C:\\Documents and Settings\\username\\Application Data\\Breezy\\2.0\\breezy.conf
49+:On Windows: %APPDATA%\\breezy\\breezy.conf
50
51 Contains the user's default configuration. The section ``[DEFAULT]`` is
52 used to define general configuration that will be applied everywhere.
53
54=== modified file 'breezy/help_topics/en/missing-extensions.txt'
55--- breezy/help_topics/en/missing-extensions.txt 2017-07-30 16:59:50 +0000
56+++ breezy/help_topics/en/missing-extensions.txt 2019-06-16 20:07:06 +0000
57@@ -23,4 +23,4 @@
58
59 Breezy will work normally but some operations may be slower.
60
61-The specific modules that failed, and why, are listed in .brz.log.
62+The specific modules that failed, and why, are listed in brz.log.
63
64=== modified file 'breezy/tests/__init__.py'
65--- breezy/tests/__init__.py 2019-06-16 01:03:51 +0000
66+++ breezy/tests/__init__.py 2019-06-16 20:07:06 +0000
67@@ -155,9 +155,9 @@
68 'BZREMAIL': None, # may still be present in the environment
69 'EMAIL': 'jrandom@example.com', # set EMAIL as brz does not guess
70 'BRZ_PROGRESS_BAR': None,
71- # This should trap leaks to ~/.brz.log. This occurs when tests use TestCase
72- # as a base class instead of TestCaseInTempDir. Tests inheriting from
73- # TestCase should not use disk resources, BRZ_LOG is one.
74+ # Trap leaks to $XDG_CACHE_HOME/breezy/brz.log. This occurs when tests use
75+ # TestCase as a base class instead of TestCaseInTempDir. Tests inheriting
76+ # from TestCase should not use disk resources, BRZ_LOG is one.
77 'BRZ_LOG': '/you-should-use-TestCaseInTempDir-if-you-need-a-log-file',
78 'BRZ_PLUGIN_PATH': '-site',
79 'BRZ_DISABLE_PLUGINS': None,
80@@ -2684,7 +2684,7 @@
81 """
82 root = TestCaseWithMemoryTransport.TEST_ROOT
83 try:
84- # Make sure we get a readable and accessible home for .brz.log
85+ # Make sure we get a readable and accessible home for brz.log
86 # and/or config files, and not fallback to weird defaults (see
87 # http://pad.lv/825027).
88 self.assertIs(None, os.environ.get('BRZ_HOME', None))
89
90=== modified file 'breezy/tests/blackbox/test_version.py'
91--- breezy/tests/blackbox/test_version.py 2018-11-11 04:08:32 +0000
92+++ breezy/tests/blackbox/test_version.py 2019-06-16 20:07:06 +0000
93@@ -56,7 +56,7 @@
94 self.assertContainsRe(out, r"(?m)^ Python standard library:")
95 self.assertContainsRe(out, r"(?m)^ breezy:")
96 self.assertContainsRe(out, r"(?m)^ Breezy configuration:")
97- self.assertContainsRe(out, r'(?m)^ Breezy log file:.*\.brz\.log')
98+ self.assertContainsRe(out, r'(?m)^ Breezy log file:.*[\\/]breezy[\\/]brz\.log')
99
100 def test_version_short(self):
101 self.permit_source_tree_branch_repo()
102@@ -71,7 +71,7 @@
103 # Even though trace._brz_log_filename variable
104 # is used only to keep actual log filename
105 # and changing this variable in selftest
106- # don't change main .brz.log location,
107+ # don't change main brz.log location,
108 # and therefore pretty safe,
109 # but we run these tests in separate temp dir
110 # with relative unicoded path
111@@ -108,17 +108,19 @@
112
113 class TestVersionBzrLogLocation(TestCaseInTempDir):
114
115+ def default_log(self):
116+ return os.path.join(os.environ['BRZ_HOME'], 'breezy', 'brz.log')
117+
118 def test_simple(self):
119 brz_log = 'my.brz.log'
120 self.overrideEnv('BRZ_LOG', brz_log)
121- default_log = os.path.join(os.environ['BRZ_HOME'], '.brz.log')
122- self.assertPathDoesNotExist([default_log, brz_log])
123+ self.assertPathDoesNotExist([self.default_log(), brz_log])
124 out = self.run_bzr_subprocess('version')[0]
125 self.assertTrue(len(out) > 0)
126 self.assertContainsRe(
127 out, br"(?m)^ Breezy log file: " + brz_log.encode('ascii'))
128- self.assertPathDoesNotExist(default_log)
129 self.assertPathExists(brz_log)
130+ self.assertPathDoesNotExist(self.default_log())
131
132 def test_dev_null(self):
133 # This test uses a subprocess to cause the log opening logic to
134@@ -128,13 +130,12 @@
135 else:
136 brz_log = '/dev/null'
137 self.overrideEnv('BRZ_LOG', brz_log)
138- default_log = os.path.join(os.environ['BRZ_HOME'], '.brz.log')
139- self.assertPathDoesNotExist(default_log)
140+ self.assertPathDoesNotExist(self.default_log())
141 out = self.run_bzr_subprocess('version')[0]
142 self.assertTrue(len(out) > 0)
143 self.assertContainsRe(
144 out, br"(?m)^ Breezy log file: " + brz_log.encode('ascii'))
145- self.assertPathDoesNotExist(default_log)
146+ self.assertPathDoesNotExist(self.default_log())
147
148 def test_unicode_brz_log(self):
149 uni_val = u"\xa7"
150@@ -145,7 +146,6 @@
151 self.skipTest(
152 "Test string %r unrepresentable in user encoding %s" % (
153 uni_val, enc))
154- self.overrideEnv('BRZ_HOME', self.test_base_dir)
155 brz_log = os.path.join(self.test_base_dir, uni_val)
156 if PY3:
157 self.overrideEnv("BRZ_LOG", brz_log)
158
159=== modified file 'breezy/trace.py'
160--- breezy/trace.py 2018-11-12 01:41:38 +0000
161+++ breezy/trace.py 2019-06-16 20:07:06 +0000
162@@ -23,11 +23,11 @@
163 Messages are classified by severity levels: critical, error, warning, info,
164 and debug.
165
166-They can be sent to two places: to stderr, and to ~/.brz.log. For purposes
167-such as running the test suite, they can also be redirected away from both of
168-those two places to another location.
169+They can be sent to two places: stderr, and `$XDG_CACHE_HOME/breezy/brz.log`.
170+For purposes such as running the test suite, they can also be redirected away
171+from both of those two places to another location.
172
173-~/.brz.log gets all messages, and full tracebacks for uncaught exceptions.
174+`brz.log` gets all messages, and full tracebacks for uncaught exceptions.
175 This trace file is always in UTF-8, regardless of the user's default encoding,
176 so that we can always rely on writing any message.
177
178@@ -72,6 +72,7 @@
179
180 lazy_import(globals(), """
181 from breezy import (
182+ bedding,
183 debug,
184 errors,
185 osutils,
186@@ -96,7 +97,7 @@
187 # than push/pop_log_file.
188 _trace_file = None
189
190-# Absolute path for ~/.brz.log. Not changed even if the log/trace output is
191+# Absolute path for brz.log. Not changed even if the log/trace output is
192 # redirected elsewhere. Used to show the location in --version.
193 _brz_log_filename = None
194
195@@ -206,20 +207,14 @@
196 brz_log = osutils.path_from_environ('BRZ_LOG')
197 if brz_log:
198 return brz_log
199- home = osutils.path_from_environ('BRZ_HOME')
200- if home is None:
201- # GZ 2012-02-01: Logging to the home dir is bad, but XDG is unclear
202- # over what would be better. On windows, bug 240550
203- # suggests LOCALAPPDATA be used instead.
204- home = osutils._get_home_dir()
205- return os.path.join(home, '.brz.log')
206+ return os.path.join(bedding.cache_dir(), 'brz.log')
207
208
209 def _open_brz_log():
210- """Open the .brz.log trace file.
211+ """Open the brz.log trace file.
212
213 If the log is more than a particular length, the old file is renamed to
214- .brz.log.old and a new file is started. Otherwise, we append to the
215+ brz.log.old and a new file is started. Otherwise, we append to the
216 existing file.
217
218 This sets the global _brz_log_filename.
219@@ -280,7 +275,7 @@
220
221
222 def enable_default_logging():
223- """Configure default logging: messages to stderr and debug to .brz.log
224+ """Configure default logging: messages to stderr and debug to brz.log
225
226 This should only be called once per process.
227
228@@ -490,13 +485,13 @@
229
230
231 def report_exception(exc_info, err_file):
232- """Report an exception to err_file (typically stderr) and to .brz.log.
233+ """Report an exception to err_file (typically stderr) and to brz.log.
234
235 This will show either a full traceback or a short message as appropriate.
236
237 :return: The appropriate exit code for this error.
238 """
239- # Log the full traceback to ~/.brz.log
240+ # Log the full traceback to brz.log
241 log_exception_quietly()
242 if 'error' in debug.debug_flags:
243 print_exception(exc_info, err_file)
244
245=== modified file 'breezy/transport/log.py'
246--- breezy/transport/log.py 2018-11-18 19:48:57 +0000
247+++ breezy/transport/log.py 2019-06-16 20:07:06 +0000
248@@ -14,7 +14,7 @@
249 # along with this program; if not, write to the Free Software
250 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
251
252-"""Transport decorator that logs transport operations to .brz.log."""
253+"""Transport decorator that logs transport operations to brz.log."""
254
255 from __future__ import absolute_import
256
257@@ -29,7 +29,7 @@
258
259
260 class TransportLogDecorator(decorator.TransportDecorator):
261- """Decorator for Transports that logs interesting operations to .brz.log.
262+ """Decorator for Transports that logs interesting operations to brz.log.
263
264 In general we want to log things that usually take a network round trip
265 and may be slow.
266
267=== modified file 'doc/developers/apport.txt'
268--- doc/developers/apport.txt 2019-02-15 17:41:17 +0000
269+++ doc/developers/apport.txt 2019-06-16 20:07:06 +0000
270@@ -59,7 +59,7 @@
271 because sometimes they are in fact bugs. Then the user can attach the
272 apport report later if they decide to file a bug. There may be quite a
273 lot of them so we might need to limit the number that are stored, or do
274- this when a debug flag is set. At the moment they go into .bzr.log and
275+ this when a debug flag is set. At the moment they go into bzr.log and
276 that's probably ok to start with.
277
278 * Raising an error from the breakin debugger should cause this to fire.
279@@ -69,7 +69,7 @@
280 longwinded than our current output and might make the traceback scroll
281 off the screen.
282
283-* Automatically trace messages (ie from .bzr.log) in the report. We could
284+* Automatically trace messages (ie from bzr.log) in the report. We could
285 just include the whole file, but it may be long, and including the whole
286 thing has a greater risk of including sensitive data.
287
288
289=== modified file 'doc/developers/authentication-ring.txt'
290--- doc/developers/authentication-ring.txt 2017-07-30 16:59:50 +0000
291+++ doc/developers/authentication-ring.txt 2019-06-16 20:07:06 +0000
292@@ -365,7 +365,7 @@
293 * As this specification proposes a matching between some credentials
294 definitions and real URLs, the implementation provides an optional UI
295 feedback about which credential definition is used. Using ``-Dauth`` will
296- output some traces in the ``.bzr.log`` file metionning the sections
297+ output some traces in the ``brz.log`` file metionning the sections
298 used. This allows the user to validate his definitions.
299
300 Questions and Answers
301
302=== modified file 'doc/developers/integration.txt'
303--- doc/developers/integration.txt 2017-11-11 12:51:45 +0000
304+++ doc/developers/integration.txt 2019-06-16 20:07:06 +0000
305@@ -5,7 +5,7 @@
306 This document provides some general observations on integrating with
307 Breezy and some recipes for typical tasks. It is intended to be useful to
308 someone developing either a plugin or some other piece of software that
309-integrates with bzr. If you want to know about a topic that's not covered
310+integrates with brz. If you want to know about a topic that's not covered
311 here, just ask us.
312
313
314@@ -14,50 +14,37 @@
315 Starting with breezy
316 ====================
317
318-Within bzr
319+Within brz
320 ----------
321
322-When using breezy within the ``bzr`` program (for instance as a bzr
323+When using breezy within the ``brz`` program (for instance as a brz
324 plugin), breezy's global state is already available for use.
325
326-From outside bzr
327+From outside brz
328 ----------------
329
330-To use breezy outside of ``bzr`` some global state needs to be setup.
331+To use breezy outside of ``brz`` some global state needs to be setup.
332 breezy needs ways to handle user input, passwords, a place to emit
333 progress bars, logging setup appropriately for your program. The easiest
334-way to set all this up in the same fashion ``bzr`` does is to call
335-``breezy.initialize``.
336+way to set all this up in the same fashion ``brz`` does is to call
337+``breezy.initialize``.
338
339 This returns a context manager within which breezy functions will work
340-correctly. See the pydoc for ``breezy.initialize`` for more information.
341+correctly. See the pydoc for ``breezy.initialize`` for more information.
342 (You can get away without entering the context manager, because the setup
343 work happens directly from ``initialize``.)
344
345-In Python 2.4 the ``with`` keyword is not supported and
346-so you need to use the context manager manually::
347-
348- # This sets up your ~/.bzr.log, ui factory and so on and so forth. It is
349- # not safe to use as a doctest.
350- library_state = breezy.initialize()
351- library_state.__enter__()
352- try:
353- pass
354- # do stuff here
355- finally:
356- library_state.__exit__(None, None, None)
357-
358-
359-Running bzr commands
360+
361+Running brz commands
362 ====================
363
364 To run command-line commands in-process::
365
366 from breezy.commands import get_command
367-
368+
369 cmd = get_command('version')
370 cmd.run([])
371-
372+
373 This will send output through the current UIFactory; you can redirect this
374 elsewhere through the parameters to `breezy.initialize`.
375
376@@ -69,7 +56,7 @@
377 is loaded from the workingtree.py file, eg::
378
379 from breezy import workingtree
380- wt = workingtree.WorkingTree.open('/home/jebw/bzrtest')
381+ wt = workingtree.WorkingTree.open('/home/jebw/brztest')
382
383
384 This gives us a WorkingTree object, which has various methods spread over
385@@ -114,17 +101,17 @@
386 Adding Files
387 ------------
388
389-If you want to add files the same way ``bzr add`` does, you can use
390+If you want to add files the same way ``brz add`` does, you can use
391 MutableTree.smart_add. By default, this is recursive. Paths can either be
392 absolute or relative to the workingtree::
393
394 wt.smart_add(['dir1/filea.txt', 'fileb.txt',
395- '/home/jebw/bzrtesttree/filec.txt'])
396+ '/home/jebw/brztesttree/filec.txt'])
397
398
399 For more precise control over which files to add, use MutableTree.add::
400
401- wt.add(['dir1/filea.txt', 'fileb.txt', '/home/jebw/bzrtesttree/filec.txt'])
402+ wt.add(['dir1/filea.txt', 'fileb.txt', '/home/jebw/brztesttree/filec.txt'])
403
404
405 Removing Files
406@@ -241,7 +228,7 @@
407
408 from breezy import branch
409
410- b = branch.Branch.open('/home/jebw/bzrtest')
411+ b = branch.Branch.open('/home/jebw/brztest')
412
413
414 Branching from an existing branch
415@@ -249,14 +236,14 @@
416
417 To branch you create a branch object representing the branch you are
418 branching from, and supply a path/url to the new branch location.
419-The following code clones the bzr.dev branch (the latest copy of the Breezy
420+The following code clones the brz trunk branch (the latest copy of the Breezy
421 source code) - be warned it has to download 60meg so takes a while to run
422 with no feedback::
423
424 from breezy import branch
425
426- b = branch.Branch.open('http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev')
427- nb = b.controldir.sprout('/tmp/newBzrBranch').open_branch()
428+ b = branch.Branch.open('bzr+ssh://bazaar.launchpad.net/+branch/brz/')
429+ nb = b.controldir.sprout('/tmp/newBrzBzranch').open_branch()
430
431
432 This provides no feedback, since Breezy automatically uses the 'silent' UI.
433@@ -271,7 +258,7 @@
434 from breezy import branch
435
436 b1 = branch.Branch.open('file:///home/user/mybranch')
437- b2 = branch.Branch.open('http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev')
438+ b2 = branch.Branch.open('bzr+ssh://bazaar.launchpad.net/+branch/brz/')
439 b1.push(b2)
440
441
442@@ -295,12 +282,12 @@
443 from breezy import bzrdir
444
445 accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch('http:URL')
446- source.create_checkout('/tmp/newBzrCheckout', None, True, accelerator_tree)
447+ source.create_checkout('/tmp/newBrzCheckout', None, True, accelerator_tree)
448
449
450 To make a heavyweight checkout, change the last line to::
451
452- source.create_checkout('/tmp/newBzrCheckout', None, False, accelerator_tree
453+ source.create_checkout('/tmp/newBrzCheckout', None, False, accelerator_tree
454
455
456 History Operations
457
458=== modified file 'doc/developers/profiling.txt'
459--- doc/developers/profiling.txt 2017-11-11 12:51:45 +0000
460+++ doc/developers/profiling.txt 2019-06-16 20:07:06 +0000
461@@ -49,7 +49,7 @@
462 identifying unnecessary lock traffic. This is activated by the ``-Dlock``
463 global option.
464
465-This writes messages into ``~/.brz.log``.
466+This writes messages into ``$XDG_CACHE_HOME/breeezy/brz.log``.
467 At present this only logs actions relating to the on-disk lockdir. It
468 doesn't describe actions on in-memory lock counters, or OS locks (which
469 are used for dirstate.)

Subscribers

People subscribed via source and target branches