Mercurial > hg
comparison mercurial/hg.py @ 20800:8253e55930a3
clone: abort if default destination has no meaningful name (BC)
If source URL has no path, default destination is resolved as '.'. It is
surprising than useful, and perhaps an unexpected behavior.
This change does not solve issue3880, but can avoid to clone into current
directory by accident.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Mar 2014 00:46:12 +0900 |
parents | 069bf1b821c8 |
children | 9a09a625bc93 |
comparison
equal
deleted
inserted
replaced
20799:069bf1b821c8 | 20800:8253e55930a3 |
---|---|
130 >>> defaultdest('/foo/bar') | 130 >>> defaultdest('/foo/bar') |
131 'bar' | 131 'bar' |
132 >>> defaultdest('/') | 132 >>> defaultdest('/') |
133 '' | 133 '' |
134 >>> defaultdest('') | 134 >>> defaultdest('') |
135 '.' | 135 '' |
136 >>> defaultdest('http://example.org/') | 136 >>> defaultdest('http://example.org/') |
137 '.' | 137 '' |
138 >>> defaultdest('http://example.org/foo/') | 138 >>> defaultdest('http://example.org/foo/') |
139 'foo' | 139 'foo' |
140 ''' | 140 ''' |
141 return os.path.basename(os.path.normpath(util.url(source).path or '')) | 141 path = util.url(source).path |
142 if not path: | |
143 return '' | |
144 return os.path.basename(os.path.normpath(path)) | |
142 | 145 |
143 def share(ui, source, dest=None, update=True): | 146 def share(ui, source, dest=None, update=True): |
144 '''create a shared repository''' | 147 '''create a shared repository''' |
145 | 148 |
146 if not islocal(source): | 149 if not islocal(source): |
288 origsource = source = srcpeer.url() | 291 origsource = source = srcpeer.url() |
289 rev, checkout = addbranchrevs(srcpeer, srcpeer, branch, rev) | 292 rev, checkout = addbranchrevs(srcpeer, srcpeer, branch, rev) |
290 | 293 |
291 if dest is None: | 294 if dest is None: |
292 dest = defaultdest(source) | 295 dest = defaultdest(source) |
293 ui.status(_("destination directory: %s\n") % dest) | 296 if dest: |
297 ui.status(_("destination directory: %s\n") % dest) | |
294 else: | 298 else: |
295 dest = ui.expandpath(dest) | 299 dest = ui.expandpath(dest) |
296 | 300 |
297 dest = util.urllocalpath(dest) | 301 dest = util.urllocalpath(dest) |
298 source = util.urllocalpath(source) | 302 source = util.urllocalpath(source) |