[PATCH 3 of 3] Added new remoteopts 'contact' and 'description' for httprepo creation

Martin Vejnar avakar at ratatanek.cz
Fri Sep 25 09:01:19 CDT 2009


# HG changeset patch
# User Martin Vejnar <avakar at ratatanek.cz>
# Date 1253887070 -7200
# Node ID c0b9aee6c679e68d28c36995e475fe87be354f99
# Parent  58ac824d65d43e7fd060425d4a86b7cd67c02277
Added new remoteopts 'contact' and 'description' for httprepo creation.
If either of the options is specified, a hgrc file for the remote repo is created
and the items are stored to the [web] section.

diff -r 58ac824d65d4 -r c0b9aee6c679 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Sep 25 15:57:36 2009 +0200
+++ b/mercurial/cmdutil.py	Fri Sep 25 15:57:50 2009 +0200
@@ -111,6 +111,11 @@
         v = opts.get(o) or src.config('ui', o)
         if v:
             dst.setconfig("ui", o, v)
+    # copy http-specific options
+    for o in 'contact', 'description':
+        v = opts.get(o) or src.config('web', o)
+        if v:
+            dst.setconfig('web', o, v)
     # copy bundle-specific options
     r = src.config('bundle', 'mainreporoot')
     if r:
diff -r 58ac824d65d4 -r c0b9aee6c679 mercurial/commands.py
--- a/mercurial/commands.py	Fri Sep 25 15:57:36 2009 +0200
+++ b/mercurial/commands.py	Fri Sep 25 15:57:50 2009 +0200
@@ -3118,6 +3118,8 @@
 remoteopts = [
     ('e', 'ssh', '', _('specify ssh command to use')),
     ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
+    ('', 'contact', '', _('specify the contact shown on the web')),
+    ('', 'description', '', _('specify the description shown on the web')),
 ]
 
 walkopts = [
diff -r 58ac824d65d4 -r c0b9aee6c679 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Fri Sep 25 15:57:36 2009 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Fri Sep 25 15:57:50 2009 +0200
@@ -184,9 +184,22 @@
                         return [_('2\ncannot create a repository with this name\n')]
 
                     try:
-                        hg.repository(self.ui, real, create=True)
+                        repo = hg.repository(self.ui, real, create=True)
                     except error.RepoError, e:
                         return ['1\n']
+                    
+                    hgrc_web = {}
+                    for o in 'contact', 'description':
+                        if o in req.form:
+                            hgrc_web[o] = req.form[o][0]
+                    if hgrc_web:
+                        fp = repo.opener("hgrc", "w", text=True)
+                        try:
+                            fp.write("[web]\n")
+                            for kv in hgrc_web.iteritems():
+                                fp.write("%s = %s\n" % kv)
+                        finally:
+                            fp.close()
 
                     self.refresh(force=True)
                     return ['0\n']
diff -r 58ac824d65d4 -r c0b9aee6c679 mercurial/httprepo.py
--- a/mercurial/httprepo.py	Fri Sep 25 15:57:36 2009 +0200
+++ b/mercurial/httprepo.py	Fri Sep 25 15:57:50 2009 +0200
@@ -40,7 +40,12 @@
         self.urlopener = url.opener(ui, authinfo)
 
         if create:
-            resp = self.do_read('init', data='')
+            initdata = {}
+            for o in 'contact', 'description':
+                v = ui.config('web', o)
+                if v:
+                    initdata[o] = v
+            resp = self.do_read('init', data=urllib.urlencode(initdata))
             resp_code, output = resp.split('\n', 1)
             try:
                 ret = int(resp_code)


More information about the Mercurial-devel mailing list