Mercurial > hg-stable
comparison mercurial/commands.py @ 625:978011cf5279
Cleanups for repo.pull
Use repo.pull in pull and clone commands
Teach clone about ssh:// (temporarily)
Fix up shutil issue on failed pull
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 05 Jul 2005 18:12:57 -0800 |
parents | 876333a295ff |
children | b6c42714d900 |
comparison
equal
deleted
inserted
replaced
624:876333a295ff | 625:978011cf5279 |
---|---|
329 ui.warn("abort: destination '%s' already exists\n" % dest) | 329 ui.warn("abort: destination '%s' already exists\n" % dest) |
330 return 1 | 330 return 1 |
331 | 331 |
332 class dircleanup: | 332 class dircleanup: |
333 def __init__(self, dir): | 333 def __init__(self, dir): |
334 import shutil | |
335 self.rmtree = shutil.rmtree | |
334 self.dir = dir | 336 self.dir = dir |
335 os.mkdir(dir) | 337 os.mkdir(dir) |
336 def close(self): | 338 def close(self): |
337 self.dir = None | 339 self.dir = None |
338 def __del__(self): | 340 def __del__(self): |
339 if self.dir: | 341 if self.dir: |
340 import shutil | 342 self.rmtree(self.dir, True) |
341 shutil.rmtree(self.dir, True) | |
342 | 343 |
343 d = dircleanup(dest) | 344 d = dircleanup(dest) |
344 | 345 |
345 link = 0 | 346 link = 0 |
346 abspath = source | 347 abspath = source |
347 if not (source.startswith("http://") or | 348 if not (source.startswith("http://") or |
348 source.startswith("hg://") or | 349 source.startswith("hg://") or |
350 source.startswith("ssh://") or | |
349 source.startswith("old-http://")): | 351 source.startswith("old-http://")): |
350 abspath = os.path.abspath(source) | 352 abspath = os.path.abspath(source) |
351 d1 = os.stat(dest).st_dev | 353 d1 = os.stat(dest).st_dev |
352 d2 = os.stat(source).st_dev | 354 d2 = os.stat(source).st_dev |
353 if d1 == d2: link = 1 | 355 if d1 == d2: link = 1 |
362 repo = hg.repository(ui, dest) | 364 repo = hg.repository(ui, dest) |
363 | 365 |
364 else: | 366 else: |
365 repo = hg.repository(ui, dest, create=1) | 367 repo = hg.repository(ui, dest, create=1) |
366 other = hg.repository(ui, source) | 368 other = hg.repository(ui, source) |
367 fetch = repo.findincoming(other) | 369 repo.pull(other) |
368 if fetch: | |
369 cg = other.changegroup(fetch) | |
370 repo.addchangegroup(cg) | |
371 | 370 |
372 f = repo.opener("hgrc", "w") | 371 f = repo.opener("hgrc", "w") |
373 f.write("[paths]\n") | 372 f.write("[paths]\n") |
374 f.write("default = %s\n" % abspath) | 373 f.write("default = %s\n" % abspath) |
375 | 374 |
692 show_changeset(ui, repo, changenode=n) | 691 show_changeset(ui, repo, changenode=n) |
693 | 692 |
694 def pull(ui, repo, source="default", **opts): | 693 def pull(ui, repo, source="default", **opts): |
695 """pull changes from the specified source""" | 694 """pull changes from the specified source""" |
696 source = ui.expandpath(source) | 695 source = ui.expandpath(source) |
697 | |
698 ui.status('pulling from %s\n' % (source)) | 696 ui.status('pulling from %s\n' % (source)) |
699 | 697 |
700 other = hg.repository(ui, source) | 698 other = hg.repository(ui, source) |
701 fetch = repo.findincoming(other) | 699 r = repo.pull(other) |
702 if not fetch: | 700 if not r: |
703 ui.status("no changes found\n") | |
704 return | |
705 | |
706 cg = other.changegroup(fetch) | |
707 r = repo.addchangegroup(cg) | |
708 if cg and not r: | |
709 if opts['update']: | 701 if opts['update']: |
710 return update(ui, repo) | 702 return update(ui, repo) |
711 else: | 703 else: |
712 ui.status("(run 'hg update' to get a working copy)\n") | 704 ui.status("(run 'hg update' to get a working copy)\n") |
713 | 705 |