Commits

Martin Vejnár  committed f048354

Added new option 'nohgrc' to disable the creation of hgrc in new repos.

  • Participants
  • Parent commits 8a1a057

Comments (0)

Files changed (2)

File hgdirmanager/hgdirmanager.py

 
     def _new_repo(self, req):
         req.perm.require('REPO_CREATE')
+        nohgrc = self.config.getbool('hgdir', 'nohgrc')
         if req.method == 'POST':
             reponame = req.args.get('field_name')
             if reponame == '':
                     except Exception, e:
                         add_warning(req, _('Failed to create repository: ') + str(e))
                     else:
-                        description = req.args.get('field_description')
-                        contact = req.args.get('field_contact')
-                        url_prefix = self.config.get('hgdir', 'url_prefix')
-                        hgrcpath = os.path.join(repodir,  '.hg', 'hgrc')
-                        with open(hgrcpath, 'w') as f:
-                            f.write('[web]\n')
-                            f.write('contact = %s\n' % contact)
-                            f.write('description = %s\n' % description)
-                            f.write('baseurl = %s\n' % url_prefix)
-                        
+                        if not nohgrc:
+                            description = req.args.get('field_description')
+                            contact = req.args.get('field_contact')
+                            url_prefix = self.config.get('hgdir', 'url_prefix')
+                            hgrcpath = os.path.join(repodir,  '.hg', 'hgrc')
+                            with open(hgrcpath, 'w') as f:
+                                f.write('[web]\n')
+                                f.write('contact = %s\n' % contact)
+                                f.write('description = %s\n' % description)
+                                f.write('baseurl = %s\n' % url_prefix)
+
                         RepositoryManager(self.env).reload_repositories()
                         req.redirect(req.href.browser(reponame))
 
-        return 'newhgrepo.html', {}, None
+        return 'newhgrepo.html', { 'nohgrc': nohgrc }, None
 
     def _delete_repo(self, req, reponame):
         req.perm.require('REPO_DELETE')

File hgdirmanager/templates/newhgrepo.html

                     <input type="text" id="field-name" name="field_name" size="70" />
                   </td>
                 </tr>
-                <tr>
+                <tr py:if="not nohgrc">
                   <th><label for="field-description">Description:</label></th>
                   <td class="fullrow" colspan="3">
                     <input type="text" id="field-description" name="field_description" size="70" />
                   </td>
                 </tr>
-                <tr>
+                <tr py:if="not nohgrc">
                   <th><label for="field-contact">Contact:</label></th>
                   <td class="fullrow" colspan="3">
                     <input type="text" id="field-contact" name="field_contact" size="70" />