Patchwork [STABLE] zeroconf: access repo on hgweb_mod properly (issue5036)

login
register
mail settings
Submitter Gregory Szorc
Date Jan. 18, 2016, 4:37 a.m.
Message ID <d2c5ad3deccb5a504e25.1453091867@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/12826/
State Accepted
Headers show

Comments

Gregory Szorc - Jan. 18, 2016, 4:37 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1453091849 28800
#      Sun Jan 17 20:37:29 2016 -0800
# Branch stable
# Node ID d2c5ad3deccb5a504e2553652b66a4110db68afb
# Parent  3203dfe341f962e33256d6475fc3585563db78ad
zeroconf: access repo on hgweb_mod properly (issue5036)

hgweb_mod.hgweb.repo disappeared in ae33fff17c1e (hg: establish
a cache for localrepository instances) and the code for accessing repo
instances from hgweb was later refactored to go through a cache-aware
context manager.

Adapt zeroconf to access the repo instance via the new API.
Matt Mackall - Jan. 18, 2016, 3:44 p.m.
On Sun, 2016-01-17 at 20:37 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1453091849 28800
> #      Sun Jan 17 20:37:29 2016 -0800
> # Branch stable
> # Node ID d2c5ad3deccb5a504e2553652b66a4110db68afb
> # Parent  3203dfe341f962e33256d6475fc3585563db78ad
> zeroconf: access repo on hgweb_mod properly (issue5036)

Queued for stable, thanks.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/hgext/zeroconf/__init__.py b/hgext/zeroconf/__init__.py
--- a/hgext/zeroconf/__init__.py
+++ b/hgext/zeroconf/__init__.py
@@ -108,19 +108,20 @@  def publish(name, desc, path, port):
 def zc_create_server(create_server, ui, app):
     httpd = create_server(ui, app)
     port = httpd.port
 
     try:
         repos = app.repos
     except AttributeError:
         # single repo
-        name = app.reponame or os.path.basename(app.repo.root)
-        path = app.repo.ui.config("web", "prefix", "").strip('/')
-        desc = app.repo.ui.config("web", "description", name)
+        with app._obtainrepo() as repo:
+            name = app.reponame or os.path.basename(repo.root)
+            path = repo.ui.config("web", "prefix", "").strip('/')
+            desc = repo.ui.config("web", "description", name)
         publish(name, desc, path, port)
     else:
         # webdir
         prefix = app.ui.config("web", "prefix", "").strip('/') + '/'
         for repo, path in repos:
             u = app.ui.copy()
             u.readconfig(os.path.join(path, '.hg', 'hgrc'))
             name = os.path.basename(repo)