Show More
@@ -550,12 +550,9 b' class ui(object):' | |||||
550 |
|
550 | |||
551 | def expandpath(self, loc, default=None): |
|
551 | def expandpath(self, loc, default=None): | |
552 | """Return repository location relative to cwd or from [paths]""" |
|
552 | """Return repository location relative to cwd or from [paths]""" | |
553 | if util.hasscheme(loc) or os.path.isdir(os.path.join(loc, '.hg')): |
|
|||
554 | return loc |
|
|||
555 |
|
||||
556 | p = self.paths.getpath(loc, default=default) |
|
553 | p = self.paths.getpath(loc, default=default) | |
557 | if p: |
|
554 | if p: | |
558 | return p.loc |
|
555 | return p.rawloc | |
559 | return loc |
|
556 | return loc | |
560 |
|
557 | |||
561 | @util.propertycache |
|
558 | @util.propertycache | |
@@ -1002,7 +999,10 b' class paths(dict):' | |||||
1002 | self[name] = path(name, rawloc=loc) |
|
999 | self[name] = path(name, rawloc=loc) | |
1003 |
|
1000 | |||
1004 | def getpath(self, name, default=None): |
|
1001 | def getpath(self, name, default=None): | |
1005 |
"""Return a ``path`` f |
|
1002 | """Return a ``path`` from a string, falling back to a default. | |
|
1003 | ||||
|
1004 | ``name`` can be a named path or locations. Locations are filesystem | |||
|
1005 | paths or URIs. | |||
1006 |
|
1006 | |||
1007 | Returns the first of ``name`` or ``default`` that is present, or None |
|
1007 | Returns the first of ``name`` or ``default`` that is present, or None | |
1008 | if neither is present. |
|
1008 | if neither is present. | |
@@ -1010,6 +1010,12 b' class paths(dict):' | |||||
1010 | try: |
|
1010 | try: | |
1011 | return self[name] |
|
1011 | return self[name] | |
1012 | except KeyError: |
|
1012 | except KeyError: | |
|
1013 | # Try to resolve as a local path or URI. | |||
|
1014 | try: | |||
|
1015 | return path(None, rawloc=name) | |||
|
1016 | except ValueError: | |||
|
1017 | pass | |||
|
1018 | ||||
1013 | if default is not None: |
|
1019 | if default is not None: | |
1014 | try: |
|
1020 | try: | |
1015 | return self[default] |
|
1021 | return self[default] | |
@@ -1026,10 +1032,34 b' class path(object):' | |||||
1026 |
|
1032 | |||
1027 | ``name`` is the symbolic name of the path. |
|
1033 | ``name`` is the symbolic name of the path. | |
1028 | ``rawloc`` is the raw location, as defined in the config. |
|
1034 | ``rawloc`` is the raw location, as defined in the config. | |
|
1035 | ||||
|
1036 | If ``name`` is not defined, we require that the location be a) a local | |||
|
1037 | filesystem path with a .hg directory or b) a URL. If not, | |||
|
1038 | ``ValueError`` is raised. | |||
1029 | """ |
|
1039 | """ | |
|
1040 | if not rawloc: | |||
|
1041 | raise ValueError('rawloc must be defined') | |||
|
1042 | ||||
|
1043 | # Locations may define branches via syntax <base>#<branch>. | |||
|
1044 | u = util.url(rawloc) | |||
|
1045 | branch = None | |||
|
1046 | if u.fragment: | |||
|
1047 | branch = u.fragment | |||
|
1048 | u.fragment = None | |||
|
1049 | ||||
|
1050 | self.url = u | |||
|
1051 | self.branch = branch | |||
|
1052 | ||||
1030 | self.name = name |
|
1053 | self.name = name | |
1031 | # We'll do more intelligent things with rawloc in the future. |
|
1054 | self.rawloc = rawloc | |
1032 |
self.loc = |
|
1055 | self.loc = str(u) | |
|
1056 | ||||
|
1057 | # When given a raw location but not a symbolic name, validate the | |||
|
1058 | # location is valid. | |||
|
1059 | if (not name and not u.scheme | |||
|
1060 | and not os.path.isdir(os.path.join(str(u), '.hg'))): | |||
|
1061 | raise ValueError('location is not a URL or path to a local ' | |||
|
1062 | 'repo: %s' % rawloc) | |||
1033 |
|
1063 | |||
1034 | # we instantiate one globally shared progress bar to avoid |
|
1064 | # we instantiate one globally shared progress bar to avoid | |
1035 | # competing progress bars when multiple UI objects get created |
|
1065 | # competing progress bars when multiple UI objects get created |
General Comments 0
You need to be logged in to leave comments.
Login now