Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 1858:9fab6e903bae
Make hg paths and hg debugconfig work with -R/--repository option.
Commands that can use a repo, but don't need one, should be added
to the "optionalrepo" string, similar to the "norepo" string.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Wed, 08 Mar 2006 01:30:43 +0100 |
parents | 848152a2e67f |
children | 39c46510ed25 |
comparison
equal
deleted
inserted
replaced
1857:848152a2e67f | 1858:9fab6e903bae |
---|---|
1056 errors += 1 | 1056 errors += 1 |
1057 if errors: | 1057 if errors: |
1058 error = _(".hg/dirstate inconsistent with current parent's manifest") | 1058 error = _(".hg/dirstate inconsistent with current parent's manifest") |
1059 raise util.Abort(error) | 1059 raise util.Abort(error) |
1060 | 1060 |
1061 def debugconfig(ui): | 1061 def debugconfig(ui, repo): |
1062 """show combined config settings from all hgrc files""" | 1062 """show combined config settings from all hgrc files""" |
1063 try: | |
1064 repo = hg.repository(ui) | |
1065 ui = repo.ui | |
1066 except hg.RepoError: | |
1067 pass | |
1068 for section, name, value in ui.walkconfig(): | 1063 for section, name, value in ui.walkconfig(): |
1069 ui.write('%s.%s=%s\n' % (section, name, value)) | 1064 ui.write('%s.%s=%s\n' % (section, name, value)) |
1070 | 1065 |
1071 def debugsetparents(ui, repo, rev1, rev2=None): | 1066 def debugsetparents(ui, repo, rev1, rev2=None): |
1072 """manually set the parents of the current working directory | 1067 """manually set the parents of the current working directory |
1761 br = repo.branchlookup(p) | 1756 br = repo.branchlookup(p) |
1762 for n in p: | 1757 for n in p: |
1763 if n != nullid: | 1758 if n != nullid: |
1764 show_changeset(ui, repo, changenode=n, brinfo=br) | 1759 show_changeset(ui, repo, changenode=n, brinfo=br) |
1765 | 1760 |
1766 def paths(ui, search=None): | 1761 def paths(ui, repo, search=None): |
1767 """show definition of symbolic path names | 1762 """show definition of symbolic path names |
1768 | 1763 |
1769 Show definition of symbolic path name NAME. If no name is given, show | 1764 Show definition of symbolic path name NAME. If no name is given, show |
1770 definition of available names. | 1765 definition of available names. |
1771 | 1766 |
1772 Path names are defined in the [paths] section of /etc/mercurial/hgrc | 1767 Path names are defined in the [paths] section of /etc/mercurial/hgrc |
1773 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. | 1768 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. |
1774 """ | 1769 """ |
1775 try: | |
1776 repo = hg.repository(ui) | |
1777 ui = repo.ui | |
1778 except hg.RepoError: | |
1779 pass | |
1780 | |
1781 if search: | 1770 if search: |
1782 for name, path in ui.configitems("paths"): | 1771 for name, path in ui.configitems("paths"): |
1783 if name == search: | 1772 if name == search: |
1784 ui.write("%s\n" % path) | 1773 ui.write("%s\n" % path) |
1785 return | 1774 return |
2666 ('', 'profile', None, _('print command execution profile')), | 2655 ('', 'profile', None, _('print command execution profile')), |
2667 ('', 'version', None, _('output version information and exit')), | 2656 ('', 'version', None, _('output version information and exit')), |
2668 ('h', 'help', None, _('display help and exit')), | 2657 ('h', 'help', None, _('display help and exit')), |
2669 ] | 2658 ] |
2670 | 2659 |
2671 norepo = ("clone init version help debugancestor debugconfig debugdata" | 2660 norepo = ("clone init version help debugancestor debugdata" |
2672 " debugindex debugindexdot paths") | 2661 " debugindex debugindexdot") |
2662 optionalrepo = ("paths debugconfig") | |
2673 | 2663 |
2674 def find(cmd): | 2664 def find(cmd): |
2675 """Return (aliases, command table entry) for command string.""" | 2665 """Return (aliases, command table entry) for command string.""" |
2676 choice = [] | 2666 choice = [] |
2677 debugchoice = [] | 2667 debugchoice = [] |
2867 except OSError, inst: | 2857 except OSError, inst: |
2868 raise util.Abort('%s: %s' % | 2858 raise util.Abort('%s: %s' % |
2869 (options['cwd'], inst.strerror)) | 2859 (options['cwd'], inst.strerror)) |
2870 | 2860 |
2871 if cmd not in norepo.split(): | 2861 if cmd not in norepo.split(): |
2872 if not repo: | 2862 try: |
2873 repo = hg.repository(u, path=path) | 2863 if not repo: |
2874 u = repo.ui | 2864 repo = hg.repository(u, path=path) |
2875 for x in external: | 2865 u = repo.ui |
2876 if hasattr(x, 'reposetup'): | 2866 for x in external: |
2877 x.reposetup(u, repo) | 2867 if hasattr(x, 'reposetup'): |
2868 x.reposetup(u, repo) | |
2869 except hg.RepoError: | |
2870 if cmd not in optionalrepo.split(): | |
2871 raise | |
2878 d = lambda: func(u, repo, *args, **cmdoptions) | 2872 d = lambda: func(u, repo, *args, **cmdoptions) |
2879 else: | 2873 else: |
2880 d = lambda: func(u, *args, **cmdoptions) | 2874 d = lambda: func(u, *args, **cmdoptions) |
2881 | 2875 |
2882 try: | 2876 try: |