equal
deleted
inserted
replaced
64 # shared features |
64 # shared features |
65 sharedbookmarks = b'bookmarks' |
65 sharedbookmarks = b'bookmarks' |
66 |
66 |
67 |
67 |
68 def addbranchrevs(lrepo, other, branches, revs, remotehidden=False): |
68 def addbranchrevs(lrepo, other, branches, revs, remotehidden=False): |
69 if util.safehasattr(other, 'peer'): |
69 if hasattr(other, 'peer'): |
70 # a courtesy to callers using a localrepo for other |
70 # a courtesy to callers using a localrepo for other |
71 peer = other.peer(remotehidden=remotehidden) |
71 peer = other.peer(remotehidden=remotehidden) |
72 else: |
72 else: |
73 peer = other |
73 peer = other |
74 hashbranch, branches = branches |
74 hashbranch, branches = branches |
172 elif scheme in repo_schemes: |
172 elif scheme in repo_schemes: |
173 cls = repo_schemes[scheme] |
173 cls = repo_schemes[scheme] |
174 cls.instance # make sure we load the module |
174 cls.instance # make sure we load the module |
175 else: |
175 else: |
176 cls = LocalFactory |
176 cls = LocalFactory |
177 if util.safehasattr(cls, 'islocal'): |
177 if hasattr(cls, 'islocal'): |
178 return cls.islocal(repo) # pytype: disable=module-attr |
178 return cls.islocal(repo) # pytype: disable=module-attr |
179 return False |
179 return False |
180 repo.ui.deprecwarn(b"use obj.local() instead of islocal(obj)", b"6.4") |
180 repo.ui.deprecwarn(b"use obj.local() instead of islocal(obj)", b"6.4") |
181 return repo.local() |
181 return repo.local() |
182 |
182 |
252 remotehidden=False, |
252 remotehidden=False, |
253 ): |
253 ): |
254 '''return a repository peer for the specified path''' |
254 '''return a repository peer for the specified path''' |
255 ui = getattr(uiorrepo, 'ui', uiorrepo) |
255 ui = getattr(uiorrepo, 'ui', uiorrepo) |
256 rui = remoteui(uiorrepo, opts) |
256 rui = remoteui(uiorrepo, opts) |
257 if util.safehasattr(path, 'url'): |
257 if hasattr(path, 'url'): |
258 # this is already a urlutil.path object |
258 # this is already a urlutil.path object |
259 peer_path = path |
259 peer_path = path |
260 else: |
260 else: |
261 peer_path = urlutil.path(ui, None, rawloc=path, validate_path=False) |
261 peer_path = urlutil.path(ui, None, rawloc=path, validate_path=False) |
262 scheme = peer_path.url.scheme # pytype: disable=attribute-error |
262 scheme = peer_path.url.scheme # pytype: disable=attribute-error |
315 If repo is not a shared repository, returns None. |
315 If repo is not a shared repository, returns None. |
316 """ |
316 """ |
317 if repo.sharedpath == repo.path: |
317 if repo.sharedpath == repo.path: |
318 return None |
318 return None |
319 |
319 |
320 if util.safehasattr(repo, 'srcrepo') and repo.srcrepo: |
320 if hasattr(repo, 'srcrepo') and repo.srcrepo: |
321 return repo.srcrepo |
321 return repo.srcrepo |
322 |
322 |
323 # the sharedpath always ends in the .hg; we want the path to the repo |
323 # the sharedpath always ends in the .hg; we want the path to the repo |
324 source = repo.vfs.split(repo.sharedpath)[0] |
324 source = repo.vfs.split(repo.sharedpath)[0] |
325 srcurl, branches = urlutil.parseurl(source) |
325 srcurl, branches = urlutil.parseurl(source) |
338 relative=False, |
338 relative=False, |
339 ): |
339 ): |
340 '''create a shared repository''' |
340 '''create a shared repository''' |
341 |
341 |
342 not_local_msg = _(b'can only share local repositories') |
342 not_local_msg = _(b'can only share local repositories') |
343 if util.safehasattr(source, 'local'): |
343 if hasattr(source, 'local'): |
344 if source.local() is None: |
344 if source.local() is None: |
345 raise error.Abort(not_local_msg) |
345 raise error.Abort(not_local_msg) |
346 elif not islocal(source): |
346 elif not islocal(source): |
347 # XXX why are we getting bytes here ? |
347 # XXX why are we getting bytes here ? |
348 raise error.Abort(not_local_msg) |
348 raise error.Abort(not_local_msg) |
727 srcpeer = peer(ui, peeropts, src_path) |
727 srcpeer = peer(ui, peeropts, src_path) |
728 origsource = src_path.rawloc |
728 origsource = src_path.rawloc |
729 branches = (src_path.branch, branch or []) |
729 branches = (src_path.branch, branch or []) |
730 source = src_path.loc |
730 source = src_path.loc |
731 else: |
731 else: |
732 if util.safehasattr(source, 'peer'): |
732 if hasattr(source, 'peer'): |
733 srcpeer = source.peer() # in case we were called with a localrepo |
733 srcpeer = source.peer() # in case we were called with a localrepo |
734 else: |
734 else: |
735 srcpeer = source |
735 srcpeer = source |
736 branches = (None, branch or []) |
736 branches = (None, branch or []) |
737 # XXX path: simply use the peer `path` object when this become available |
737 # XXX path: simply use the peer `path` object when this become available |
1565 return ret |
1565 return ret |
1566 |
1566 |
1567 |
1567 |
1568 def remoteui(src, opts): |
1568 def remoteui(src, opts): |
1569 """build a remote ui from ui or repo and opts""" |
1569 """build a remote ui from ui or repo and opts""" |
1570 if util.safehasattr(src, 'baseui'): # looks like a repository |
1570 if hasattr(src, 'baseui'): # looks like a repository |
1571 dst = src.baseui.copy() # drop repo-specific config |
1571 dst = src.baseui.copy() # drop repo-specific config |
1572 src = src.ui # copy target options from repo |
1572 src = src.ui # copy target options from repo |
1573 else: # assume it's a global ui object |
1573 else: # assume it's a global ui object |
1574 dst = src.copy() # keep all global options |
1574 dst = src.copy() # keep all global options |
1575 |
1575 |