Skip to content

Commit aebf562

Browse files
committed
Add caching support for Mercurial
1 parent b28fc12 commit aebf562

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mbed/mbed.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,23 @@ def init(path=None):
365365
popen([hg_cmd, 'init'] + ([path] if path else []) + (['-v'] if verbose else ['-q']))
366366

367367
def clone(url, name=None, depth=None, protocol=None, cache=None):
368-
popen([hg_cmd, 'clone', formaturl(url, protocol), name] + (['-v'] if verbose else ['-q']))
368+
main = True
369+
370+
if cache and not os.path.isdir(name):
371+
if not os.path.isdir(os.path.split(name)[0]):
372+
os.makedirs(os.path.split(name)[0])
373+
shutil.copytree(cache, name)
374+
375+
try:
376+
with cd(name):
377+
Hg.update()
378+
main = False
379+
except ProcessException:
380+
if os.path.exists(name):
381+
rmtree_readonly(name)
382+
383+
if main:
384+
popen([hg_cmd, 'clone', formaturl(url, protocol), name] + (['-v'] if verbose else ['-q']))
369385

370386
def add(dest):
371387
log("Adding reference \"%s\"" % dest)

0 commit comments

Comments
 (0)