diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -82,9 +82,8 @@ cat [revision]:: clone [-U] [dest]:: Create a copy of an existing repository in a new directory. - If the destination directory is specified but doesn't exist, it is - created. If no destination directory is specified, it defaults to the - current directory. + If no destination directory name is specified, it defaults to the + basename of the source. The source is added to the new repository's .hg/hgrc file to be used in future pulls. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -272,10 +272,12 @@ def clone(ui, source, dest = None, **opt success = created = False if dest is None: - dest = os.getcwd() - elif not os.path.exists(dest): - os.mkdir(dest) - created = True + dest = os.path.basename(source) + if dest == source: + ui.warn('abort: source and destination are the same\n') + sys.exit(1) + + os.mkdir(dest) try: dest = os.path.realpath(dest)