Patchwork [13,of,23] configitems: register the 'web.description' config

login
register
mail settings
Submitter Boris Feld
Date Sept. 16, 2017, 6:28 p.m.
Message ID <a51b26e8d3406c73676f.1505586500@FB>
Download mbox | patch
Permalink /patch/23965/
State Accepted
Headers show

Comments

Boris Feld - Sept. 16, 2017, 6:28 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1498787143 -7200
#      ven. juin 30 03:45:43 2017 +0200
# Node ID a51b26e8d3406c73676f14127bb637cd7fde357d
# Parent  b62bd50736bf55e36d167ff2a00f24ac27c61fd5
# EXP-Topic config.register.web
configitems: register the 'web.description' config
Gregory Szorc - Sept. 16, 2017, 8:39 p.m.
On Sat, Sep 16, 2017 at 11:28 AM, Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1498787143 -7200
> #      ven. juin 30 03:45:43 2017 +0200
> # Node ID a51b26e8d3406c73676f14127bb637cd7fde357d
> # Parent  b62bd50736bf55e36d167ff2a00f24ac27c61fd5
> # EXP-Topic config.register.web
> configitems: register the 'web.description' config
>
> diff -r b62bd50736bf -r a51b26e8d340 hgext/zeroconf/__init__.py
> --- a/hgext/zeroconf/__init__.py        ven. juin 30 03:45:42 2017 +0200
> +++ b/hgext/zeroconf/__init__.py        ven. juin 30 03:45:43 2017 +0200
> @@ -127,7 +127,9 @@
>          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)
> +            desc = repo.ui.config("web", "description")
> +            if not desc:
> +                desc = name
>

I have a preference for: desc = repo.ui.config('web', 'description') or name

But I left this unchanged in flight.


>          publish(name, desc, path, port)
>      else:
>          # webdir
> @@ -137,7 +139,9 @@
>              u.readconfig(os.path.join(path, '.hg', 'hgrc'))
>              name = os.path.basename(repo)
>              path = (prefix + repo).strip('/')
> -            desc = u.config('web', 'description', name)
> +            desc = u.config('web', 'description')
> +            if not desc:
> +                desc = name
>              publish(name, desc, path, port)
>      return httpd
>
> diff -r b62bd50736bf -r a51b26e8d340 mercurial/configitems.py
> --- a/mercurial/configitems.py  ven. juin 30 03:45:42 2017 +0200
> +++ b/mercurial/configitems.py  ven. juin 30 03:45:43 2017 +0200
> @@ -615,6 +615,9 @@
>  coreconfigitem('web', 'descend',
>      default=True,
>  )
> +coreconfigitem('web', 'description',
> +    default="",
> +)
>  coreconfigitem('worker', 'backgroundclose',
>      default=dynamicdefault,
>  )
> diff -r b62bd50736bf -r a51b26e8d340 mercurial/hgweb/hgwebdir_mod.py
> --- a/mercurial/hgweb/hgwebdir_mod.py   ven. juin 30 03:45:42 2017 +0200
> +++ b/mercurial/hgweb/hgwebdir_mod.py   ven. juin 30 03:45:43 2017 +0200
> @@ -428,7 +428,7 @@
>                      continue
>
>                  contact = get_contact(get)
> -                description = get("web", "description", "")
> +                description = get("web", "description")
>                  seenrepos.add(name)
>                  name = get("web", "name", name)
>                  row = {'contact': contact or "unknown",
> diff -r b62bd50736bf -r a51b26e8d340 mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py    ven. juin 30 03:45:42 2017 +0200
> +++ b/mercurial/hgweb/webcommands.py    ven. juin 30 03:45:43 2017 +0200
> @@ -719,8 +719,11 @@
>      start = max(0, count - web.maxchanges)
>      end = min(count, start + web.maxchanges)
>
> +    desc = web.config("web", "description")
> +    if not desc:
> +        desc = 'unknown'
>      return tmpl("summary",
> -                desc=web.config("web", "description", "unknown"),
> +                desc=desc,
>                  owner=get_contact(web.config) or "unknown",
>                  lastchange=tip.date(),
>                  tags=tagentries,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff -r b62bd50736bf -r a51b26e8d340 hgext/zeroconf/__init__.py
--- a/hgext/zeroconf/__init__.py	ven. juin 30 03:45:42 2017 +0200
+++ b/hgext/zeroconf/__init__.py	ven. juin 30 03:45:43 2017 +0200
@@ -127,7 +127,9 @@ 
         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)
+            desc = repo.ui.config("web", "description")
+            if not desc:
+                desc = name
         publish(name, desc, path, port)
     else:
         # webdir
@@ -137,7 +139,9 @@ 
             u.readconfig(os.path.join(path, '.hg', 'hgrc'))
             name = os.path.basename(repo)
             path = (prefix + repo).strip('/')
-            desc = u.config('web', 'description', name)
+            desc = u.config('web', 'description')
+            if not desc:
+                desc = name
             publish(name, desc, path, port)
     return httpd
 
diff -r b62bd50736bf -r a51b26e8d340 mercurial/configitems.py
--- a/mercurial/configitems.py	ven. juin 30 03:45:42 2017 +0200
+++ b/mercurial/configitems.py	ven. juin 30 03:45:43 2017 +0200
@@ -615,6 +615,9 @@ 
 coreconfigitem('web', 'descend',
     default=True,
 )
+coreconfigitem('web', 'description',
+    default="",
+)
 coreconfigitem('worker', 'backgroundclose',
     default=dynamicdefault,
 )
diff -r b62bd50736bf -r a51b26e8d340 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	ven. juin 30 03:45:42 2017 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	ven. juin 30 03:45:43 2017 +0200
@@ -428,7 +428,7 @@ 
                     continue
 
                 contact = get_contact(get)
-                description = get("web", "description", "")
+                description = get("web", "description")
                 seenrepos.add(name)
                 name = get("web", "name", name)
                 row = {'contact': contact or "unknown",
diff -r b62bd50736bf -r a51b26e8d340 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	ven. juin 30 03:45:42 2017 +0200
+++ b/mercurial/hgweb/webcommands.py	ven. juin 30 03:45:43 2017 +0200
@@ -719,8 +719,11 @@ 
     start = max(0, count - web.maxchanges)
     end = min(count, start + web.maxchanges)
 
+    desc = web.config("web", "description")
+    if not desc:
+        desc = 'unknown'
     return tmpl("summary",
-                desc=web.config("web", "description", "unknown"),
+                desc=desc,
                 owner=get_contact(web.config) or "unknown",
                 lastchange=tip.date(),
                 tags=tagentries,