Mercurial > hg > openjdk > trees
changeset 22:4ce70223c2b4
clone: skip cloning a repo if the destination exists
This eliminates the need for the --skiproot option, which is still accepted
but ignored.
author | jcoomes |
---|---|
date | Thu, 06 Mar 2014 05:28:47 -0800 |
parents | 760782dd3c80 |
children | 6db1e65386fb |
files | tests/test-trees-local.t tests/test-trees-remote-x.t trees.py |
diffstat | 3 files changed, 21 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-trees-local.t Sun Mar 02 09:55:27 2014 -0800 +++ b/tests/test-trees-local.t Thu Mar 06 05:28:47 2014 -0800 @@ -20,7 +20,7 @@ $ hg tclone -q r1 r2 $ hg tclone -q r1 r3 s1 file:$TESTTMP/r2 s2 -Clone r4 in two steps using skiproot. +Clone r4 in two steps. $ hg tclone r1 r4 s1 cloning r1 @@ -48,8 +48,8 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved created $TESTTMP/r4/s1/s1.3 with spaces - $ hg tclone --skiproot r3 r4 s2 - skipping root r3 + $ hg tclone r3 r4 s2 + skipping r3 (destination exists) cloning $TESTTMP/r3/s2 updating (to branch default|working directory) (re) @@ -71,7 +71,7 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved created $TESTTMP/r4/s2/s2.2/s2.2.1 -Clone using skiproot without explicitly listing subtrees. +Clone without explicitly listing subtrees. $ hg tclone r1/s1 rx cloning r1/s1 @@ -94,8 +94,8 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved created $TESTTMP/rx/s1.3 with spaces - $ hg tclone --skiproot rflat rx - skipping root rflat + $ hg tclone rflat rx + skipping rflat (destination exists) cloning $TESTTMP/rflat/s1 updating (to branch default|working directory) (re)
--- a/tests/test-trees-remote-x.t Sun Mar 02 09:55:27 2014 -0800 +++ b/tests/test-trees-remote-x.t Thu Mar 06 05:28:47 2014 -0800 @@ -47,7 +47,6 @@ $ hg tclone -U "$TREES_REMOTE_URL/tree-1" cloning */tree-1 (glob) - destination directory: tree-1 requesting all changes adding changesets adding manifests
--- a/trees.py Sun Mar 02 09:55:27 2014 -0800 +++ b/trees.py Thu Mar 06 05:28:47 2014 -0800 @@ -378,12 +378,19 @@ subtrees.append(subtree) return subtrees -def _clone(ui, source, dest, opts): - ui.status('cloning %s\n' % source) - src, dst = _clonerepo(ui, source, dest, opts) - ui.status(_('created %s\n') % dst.root) +def _clone(ui, source, dest, opts, skiproot = False): + if not skiproot and not os.path.exists(os.path.join(dest, '.hg')): + ui.status('cloning %s\n' % source) + src, dst = _clonerepo(ui, source, dest, opts) + ui.status(_('created %s\n') % dst.root) + else: + msg = 'skipping %s (destination exists)\n' + if skiproot: + msg = 'skipping root %s\n' + ui.status(msg % source) + src, dst = _skiprepo(ui, source, dest) subtrees = _clonesubtrees(ui, src, dst, opts) - _writeconfig(dst, _ns(ui, opts), subtrees) + addconfig(ui, dst, subtrees, opts, True) # Need to indirect through hg_clone for compatibility w/various hg versions. hg_clone = None @@ -397,13 +404,9 @@ s = __builtin__.list(subtreeargs) s.extend(opts.get('subtrees')) # Note: extend does not return a value opts['subtrees'] = s - if not opts.get('skiproot'): - _clone(ui, source, dest, opts) - else: - ui.status('skipping root %s\n' % source) - src, dst = _skiprepo(ui, source, dest) - subtrees = _clonesubtrees(ui, src, dst, opts) - _writeconfig(dst, _ns(ui, opts), subtrees, True) + if dest is None: + dest = hg.defaultdest(source) + _clone(ui, source, dest, opts, opts.get('skiproot')) return 0 def _command(ui, repo, argv, stop, opts):