Patchwork D768: blackbox: do not prevent 'chg init' from working

login
register
mail settings
Submitter phabricator
Date Sept. 22, 2017, 12:50 p.m.
Message ID <a93cfce846215e70b8b04a46a457ae2f@localhost.localdomain>
Download mbox | patch
Permalink /patch/24114/
State Not Applicable
Headers show

Comments

phabricator - Sept. 22, 2017, 12:50 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb1d4ac068961: blackbox: do not prevent &#039;chg init&#039; from working (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D768?vs=1975&id=2009

REVISION DETAIL
  https://phab.mercurial-scm.org/D768

AFFECTED FILES
  hgext/blackbox.py
  tests/test-blackbox.t

CHANGE DETAILS




To: quark, #hg-reviewers, akushner
Cc: akushner, mercurial-devel

Patch

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -293,6 +293,13 @@ 
 
   $ cd ..
 
+With chg, blackbox should not create the log file if the repo is gone
+
+  $ hg init repo1
+  $ hg --config extensions.a=! -R repo1 log
+  $ rm -rf $TESTTMP/repo1
+  $ hg --config extensions.a=! init repo1
+
 #endif
 
 blackbox should work if repo.ui.log is not called (issue5518)
diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -77,9 +77,13 @@ 
     class blackboxui(ui.__class__):
         @property
         def _bbvfs(self):
+            vfs = None
             repo = getattr(self, '_bbrepo', None)
             if repo:
-                return repo.vfs
+                vfs = repo.vfs
+                if not vfs.isdir('.'):
+                    vfs = None
+            return vfs
 
         @util.propertycache
         def track(self):
@@ -136,6 +140,10 @@ 
 
             if not ui:
                 return
+            vfs = ui._bbvfs
+            if not vfs:
+                return
+
             repo = getattr(ui, '_bbrepo', None)
             if not lastui or repo:
                 lastui = ui