[MERGE] BZR_LOG env variable controls location of .bzr.log.

Alexander Belchenko bialix at ukr.net
Fri Feb 8 08:11:51 GMT 2008


John Arbash Meinel пишет:
> Alexander Belchenko wrote:
> | John Arbash Meinel ?8H5B:
> | | You don't actually assert that 'my.bzr.log' actually contains the 
> logged
> | | info, just that 'bzr --version' reports it.
> | |
> | | I would like to see that ~/.bzr.log is empty/nonexistant and that
> | | my.bzr.log does contain data. I don't think we need to test that "NUL"
> | | doesn't. :)
> |
> | I don't understand how I can test that ~/.bzr.log is "empty/nonexistant"
> | if it
> | always exists by default. You suggest my test will kill this file?
> | Testing existence of my.bzr.log is no problem.
> 
> Every test gets a new $HOME directory, and thus a new .bzr.log. I don't
> know if it already exists by the time your test points it somewhere
> else. If it does, you could just test that its size stays the same.
> 
> I would just like some sort of proof that we aren't actually writing to
> that file.

The problem is on Windows we don't using ~/.bzr.log for default log location,
and using My Documents folder instead. So I switch default trace filename
location to use BZR_HOME if defined, and then I can properly testing BZR_LOG
regardless of platform. Also I think this change complete the role of
$BZR_HOME as overriden $HOME not only for .bazaar config dir, but and for trace
log too.

Here is changes over previous patch:

=== modified file 'NEWS'
--- NEWS 06.02.2008 12:07:17
+++ NEWS 07.02.2008 10:47:27
@@ -16,6 +16,10 @@
        friendly. Full path of plugins locations will be shown only with
        ``--verbose`` command-line option. (Alexander Belchenko)

+    * If BZR_HOME environment variable is defined then default location
+      for .bzr.log trace file is ``$BZR_HOME/.bzr.log``.
+      (Alexander Belchenko)
+
      * ``merge`` now prefers to use the submit branch, but will fall back to
        parent branch.  For many users, this has no effect.  But some users who
        pull and merge on the same branch will notice a change.  This change

=== modified file 'bzrlib/tests/blackbox/test_version.py'
--- bzrlib/tests/blackbox/test_version.py 06.02.2008 12:01:56
+++ bzrlib/tests/blackbox/test_version.py 07.02.2008 10:47:27
@@ -16,6 +16,7 @@

  """Black-box tests for bzr version."""

+import os
  import sys

  import bzrlib
@@ -83,9 +84,13 @@
      def test_simple(self):
          bzr_log = 'my.bzr.log'
          osutils.set_or_unset_env('BZR_LOG', bzr_log)
+        default_log = os.path.join(os.environ['BZR_HOME'], '.bzr.log')
+        self.failIfExists([default_log, bzr_log])
          out = self.run_bzr_subprocess('version')[0]
          self.assertTrue(len(out) > 0)
          self.assertContainsRe(out, r"(?m)^  Bazaar log file: " + bzr_log)
+        self.failIfExists(default_log)
+        self.failUnlessExists(bzr_log)

      def test_dev_null(self):
          if sys.platform == 'win32':
@@ -93,6 +98,9 @@
          else:
              bzr_log = '/dev/null'
          osutils.set_or_unset_env('BZR_LOG', bzr_log)
+        default_log = os.path.join(os.environ['BZR_HOME'], '.bzr.log')
+        self.failIfExists(default_log)
          out = self.run_bzr_subprocess('version')[0]
          self.assertTrue(len(out) > 0)
          self.assertContainsRe(out, r"(?m)^  Bazaar log file: " + bzr_log)
+        self.failIfExists(default_log)

=== modified file 'bzrlib/trace.py'
--- bzrlib/trace.py 06.02.2008 12:01:56
+++ bzrlib/trace.py 07.02.2008 10:47:27
@@ -170,11 +170,13 @@
      import codecs

      if tracefilename is None:
-        if sys.platform == 'win32':
-            from bzrlib import win32utils
-            home = win32utils.get_home_location()
-        else:
-            home = os.path.expanduser('~')
+        home = os.environ.get('BZR_HOME')
+        if home is None:
+            if sys.platform == 'win32':
+                from bzrlib import win32utils
+                home = win32utils.get_home_location()
+            else:
+                home = os.path.expanduser('~')
          _bzr_log_filename = os.path.join(home, '.bzr.log')
      else:
          _bzr_log_filename = tracefilename


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: disable.bzr.log.v4.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20080208/f8390618/attachment.diff 


More information about the bazaar mailing list