Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 24803:e89f909edffa stable 3.4-rc
merge default into stable for 3.4 freeze
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 16 Apr 2015 20:57:51 -0500 |
parents | 28d76bc069db |
children | 2f88821856eb |
comparison
equal
deleted
inserted
replaced
24753:612ed41ae359 | 24803:e89f909edffa |
---|---|
156 raise | 156 raise |
157 self.warn(_("ignored: %s\n") % str(inst)) | 157 self.warn(_("ignored: %s\n") % str(inst)) |
158 | 158 |
159 if self.plain(): | 159 if self.plain(): |
160 for k in ('debug', 'fallbackencoding', 'quiet', 'slash', | 160 for k in ('debug', 'fallbackencoding', 'quiet', 'slash', |
161 'logtemplate', 'style', | 161 'logtemplate', 'statuscopies', 'style', |
162 'traceback', 'verbose'): | 162 'traceback', 'verbose'): |
163 if k in cfg['ui']: | 163 if k in cfg['ui']: |
164 del cfg['ui'][k] | 164 del cfg['ui'][k] |
165 for k, v in cfg.items('defaults'): | 165 for k, v in cfg.items('defaults'): |
166 del cfg['defaults'][k] | 166 del cfg['defaults'][k] |
529 def expandpath(self, loc, default=None): | 529 def expandpath(self, loc, default=None): |
530 """Return repository location relative to cwd or from [paths]""" | 530 """Return repository location relative to cwd or from [paths]""" |
531 if util.hasscheme(loc) or os.path.isdir(os.path.join(loc, '.hg')): | 531 if util.hasscheme(loc) or os.path.isdir(os.path.join(loc, '.hg')): |
532 return loc | 532 return loc |
533 | 533 |
534 path = self.config('paths', loc) | 534 p = self.paths.getpath(loc, default=default) |
535 if not path and default is not None: | 535 if p: |
536 path = self.config('paths', default) | 536 return p.loc |
537 return path or loc | 537 return loc |
538 | |
539 @util.propertycache | |
540 def paths(self): | |
541 return paths(self) | |
538 | 542 |
539 def pushbuffer(self, error=False): | 543 def pushbuffer(self, error=False): |
540 """install a buffer to capture standard output of the ui object | 544 """install a buffer to capture standard output of the ui object |
541 | 545 |
542 If error is True, the error output will be captured too.""" | 546 If error is True, the error output will be captured too.""" |
803 f.close() | 807 f.close() |
804 | 808 |
805 environ = {'HGUSER': user} | 809 environ = {'HGUSER': user} |
806 if 'transplant_source' in extra: | 810 if 'transplant_source' in extra: |
807 environ.update({'HGREVISION': hex(extra['transplant_source'])}) | 811 environ.update({'HGREVISION': hex(extra['transplant_source'])}) |
808 for label in ('source', 'rebase_source'): | 812 for label in ('intermediate-source', 'source', 'rebase_source'): |
809 if label in extra: | 813 if label in extra: |
810 environ.update({'HGREVISION': extra[label]}) | 814 environ.update({'HGREVISION': extra[label]}) |
811 break | 815 break |
812 if editform: | 816 if editform: |
813 environ.update({'HGEDITFORM': editform}) | 817 environ.update({'HGEDITFORM': editform}) |
921 | 925 |
922 ui.write(s, 'label') is equivalent to | 926 ui.write(s, 'label') is equivalent to |
923 ui.write(ui.label(s, 'label')). | 927 ui.write(ui.label(s, 'label')). |
924 ''' | 928 ''' |
925 return msg | 929 return msg |
930 | |
931 class paths(dict): | |
932 """Represents a collection of paths and their configs. | |
933 | |
934 Data is initially derived from ui instances and the config files they have | |
935 loaded. | |
936 """ | |
937 def __init__(self, ui): | |
938 dict.__init__(self) | |
939 | |
940 for name, loc in ui.configitems('paths'): | |
941 # No location is the same as not existing. | |
942 if not loc: | |
943 continue | |
944 self[name] = path(name, rawloc=loc) | |
945 | |
946 def getpath(self, name, default=None): | |
947 """Return a ``path`` for the specified name, falling back to a default. | |
948 | |
949 Returns the first of ``name`` or ``default`` that is present, or None | |
950 if neither is present. | |
951 """ | |
952 try: | |
953 return self[name] | |
954 except KeyError: | |
955 if default is not None: | |
956 try: | |
957 return self[default] | |
958 except KeyError: | |
959 pass | |
960 | |
961 return None | |
962 | |
963 class path(object): | |
964 """Represents an individual path and its configuration.""" | |
965 | |
966 def __init__(self, name, rawloc=None): | |
967 """Construct a path from its config options. | |
968 | |
969 ``name`` is the symbolic name of the path. | |
970 ``rawloc`` is the raw location, as defined in the config. | |
971 """ | |
972 self.name = name | |
973 # We'll do more intelligent things with rawloc in the future. | |
974 self.loc = rawloc |