# HG changeset patch # User Steve Borho # Date 1238361306 18000 # Node ID a218ba5f60df891fbbb84f4e512fa233f482025f # Parent edf2d83a11aabf3d564fcc830e78bce4e3a6b938 allow clone into existing but empty directories diff -r edf2d83a11aa -r a218ba5f60df mercurial/hg.py --- a/mercurial/hg.py Sun Mar 29 19:56:53 2009 -0300 +++ b/mercurial/hg.py Sun Mar 29 16:15:06 2009 -0500 @@ -131,7 +131,10 @@ source = localpath(source) if os.path.exists(dest): - raise util.Abort(_("destination '%s' already exists") % dest) + if not os.path.isdir(dest): + raise util.Abort(_("destination '%s' already exists") % dest) + elif os.listdir(dest): + raise util.Abort(_("destination '%s' is not empty") % dest) class DirCleanup(object): def __init__(self, dir_): diff -r edf2d83a11aa -r a218ba5f60df tests/test-clone --- a/tests/test-clone Sun Mar 29 19:56:53 2009 -0300 +++ b/tests/test-clone Sun Mar 29 16:15:06 2009 -0500 @@ -60,4 +60,11 @@ hg clone --pull a g hg -R g verify +echo +echo % clone to '.' +mkdir h +cd h +hg clone ../a . +cd .. + exit 0 diff -r edf2d83a11aa -r a218ba5f60df tests/test-clone-failure --- a/tests/test-clone-failure Sun Mar 29 19:56:53 2009 -0300 +++ b/tests/test-clone-failure Sun Mar 29 16:15:06 2009 -0500 @@ -43,4 +43,10 @@ cd .. hg clone q +# destination directory not empty +mkdir a +echo stuff > a/a +hg clone q a +echo $? + true diff -r edf2d83a11aa -r a218ba5f60df tests/test-clone-failure.out --- a/tests/test-clone-failure.out Sun Mar 29 19:56:53 2009 -0300 +++ b/tests/test-clone-failure.out Sun Mar 29 16:15:06 2009 -0500 @@ -4,9 +4,11 @@ 255 abort: repository a not found! 255 -abort: destination '../a' already exists +abort: Permission denied: ../a 255 abort: repository a not found! 255 destination directory: q -abort: destination 'q' already exists +abort: destination 'q' is not empty +abort: destination 'a' is not empty +255 diff -r edf2d83a11aa -r a218ba5f60df tests/test-clone.out --- a/tests/test-clone.out Sun Mar 29 19:56:53 2009 -0300 +++ b/tests/test-clone.out Sun Mar 29 16:15:06 2009 -0500 @@ -50,3 +50,7 @@ crosschecking files in changesets and manifests checking files 2 files, 11 changesets, 11 total revisions + +% clone to . +updating working directory +2 files updated, 0 files merged, 0 files removed, 0 files unresolved