Patchwork D8217: hgit: make sure repository has store attribute before checking for type

login
register
mail settings
Submitter phabricator
Date March 4, 2020, 4:47 p.m.
Message ID <differential-rev-PHID-DREV-26a4dpcodanitqy672yw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45465/
State Superseded
Headers show

Comments

phabricator - March 4, 2020, 4:47 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  httppeer (and maybe others too) does not have a store attribute. This was
  causing `hg pull` being broken on a hg repository when the extension is enabled.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/git/__init__.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - March 4, 2020, 5:30 p.m.
mharbison72 added inline comments.

INLINE COMMENTS

> __init__.py:226
>  def reposetup(ui, repo):
> -    if isinstance(repo.store, gitstore):
> +    if util.safehasattr(repo, 'store') and isinstance(repo.store, gitstore):
>          orig = repo.__class__

It seems like the usual `reposetup()` check to handle peers is

  if not repo.local():
      return

IDK if it matters though.  It looks like `localpeer.local()` returns a non-None value.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8217/new/

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

To: pulkit, #hg-reviewers
Cc: mharbison72, mercurial-devel
phabricator - March 4, 2020, 6:47 p.m.
This revision now requires changes to proceed.
durin42 added a comment.
durin42 requested changes to this revision.


  Could you rebase this on the new version of 6734?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8217/new/

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

To: pulkit, #hg-reviewers, durin42
Cc: durin42, mharbison72, mercurial-devel

Patch

diff --git a/hgext/git/__init__.py b/hgext/git/__init__.py
--- a/hgext/git/__init__.py
+++ b/hgext/git/__init__.py
@@ -19,6 +19,7 @@ 
     localrepo,
     pycompat,
     store,
+    util,
 )
 
 from . import (
@@ -222,7 +223,7 @@ 
 
 
 def reposetup(ui, repo):
-    if isinstance(repo.store, gitstore):
+    if util.safehasattr(repo, 'store') and isinstance(repo.store, gitstore):
         orig = repo.__class__
         repo.store._progress_factory = repo.ui.makeprogress