changeset 1860:97f07d311a50

Merged tah and crew
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 08 Mar 2006 06:20:32 +0100
parents 39c46510ed25 (diff) b8bd84ad9b67 (current diff)
children 65949d1c9bf7 7a09785d3237
files
diffstat 1 files changed, 25 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Mar 08 05:31:20 2006 +0100
+++ b/mercurial/commands.py	Wed Mar 08 06:20:32 2006 +0100
@@ -1058,13 +1058,8 @@
         error = _(".hg/dirstate inconsistent with current parent's manifest")
         raise util.Abort(error)
 
-def debugconfig(ui):
+def debugconfig(ui, repo):
     """show combined config settings from all hgrc files"""
-    try:
-        repo = hg.repository(ui)
-        ui = repo.ui
-    except hg.RepoError:
-        pass
     for section, name, value in ui.walkconfig():
         ui.write('%s.%s=%s\n' % (section, name, value))
 
@@ -1763,7 +1758,7 @@
         if n != nullid:
             show_changeset(ui, repo, changenode=n, brinfo=br)
 
-def paths(ui, search=None):
+def paths(ui, repo, search=None):
     """show definition of symbolic path names
 
     Show definition of symbolic path name NAME. If no name is given, show
@@ -1772,12 +1767,6 @@
     Path names are defined in the [paths] section of /etc/mercurial/hgrc
     and $HOME/.hgrc.  If run inside a repository, .hg/hgrc is used, too.
     """
-    try:
-        repo = hg.repository(ui)
-        ui = repo.ui
-    except hg.RepoError:
-        pass
-
     if search:
         for name, path in ui.configitems("paths"):
             if name == search:
@@ -2668,8 +2657,9 @@
     ('h', 'help', None, _('display help and exit')),
 ]
 
-norepo = ("clone init version help debugancestor debugconfig debugdata"
-          " debugindex debugindexdot paths")
+norepo = ("clone init version help debugancestor debugdata"
+          " debugindex debugindexdot")
+optionalrepo = ("paths debugconfig")
 
 def find(cmd):
     """Return (aliases, command table entry) for command string."""
@@ -2844,6 +2834,16 @@
 
     try:
         try:
+            if options['cwd']:
+                try:
+                    os.chdir(options['cwd'])
+                except OSError, inst:
+                    raise util.Abort('%s: %s' %
+                                     (options['cwd'], inst.strerror))
+
+            path = options["repository"] or ""
+            repo = path and hg.repository(u, path=path) or None
+
             if options['help']:
                 help_(u, cmd, options['version'])
                 sys.exit(0)
@@ -2854,20 +2854,17 @@
                 help_(u, 'shortlist')
                 sys.exit(0)
 
-            if options['cwd']:
+            if cmd not in norepo.split():
                 try:
-                    os.chdir(options['cwd'])
-                except OSError, inst:
-                    raise util.Abort('%s: %s' %
-                                     (options['cwd'], inst.strerror))
-
-            if cmd not in norepo.split():
-                path = options["repository"] or ""
-                repo = hg.repository(u, path=path)
-                u = repo.ui
-                for x in external:
-                    if hasattr(x, 'reposetup'):
-                        x.reposetup(u, repo)
+                    if not repo:
+                        repo = hg.repository(u, path=path)
+                    u = repo.ui
+                    for x in external:
+                        if hasattr(x, 'reposetup'):
+                            x.reposetup(u, repo)
+                except hg.RepoError:
+                    if cmd not in optionalrepo.split():
+                        raise
                 d = lambda: func(u, repo, *args, **cmdoptions)
             else:
                 d = lambda: func(u, *args, **cmdoptions)