Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 37262:54435fd09f1d
clone: rename "rev" to "revs" since there can be many
It was a little tricky in hg.clone(), since there was a local "revs"
variable defined there, but "rev" was never used after "revs", so I
just overwrote it.
Note that clonewithshare() should also have its "rev" argument renamed
to "revs", but I'll leave that to someone else.
Differential Revision: https://phab.mercurial-scm.org/D3016
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 02 Apr 2018 08:46:07 -0700 |
parents | 3809eafedf2c |
children | 70c52800940b |
comparison
equal
deleted
inserted
replaced
37261:3809eafedf2c | 37262:54435fd09f1d |
---|---|
446 ui.status(_('(sharing from new pooled repository %s)\n') % basename) | 446 ui.status(_('(sharing from new pooled repository %s)\n') % basename) |
447 # Always use pull mode because hardlinks in share mode don't work | 447 # Always use pull mode because hardlinks in share mode don't work |
448 # well. Never update because working copies aren't necessary in | 448 # well. Never update because working copies aren't necessary in |
449 # share mode. | 449 # share mode. |
450 clone(ui, peeropts, source, dest=sharepath, pull=True, | 450 clone(ui, peeropts, source, dest=sharepath, pull=True, |
451 rev=rev, update=False, stream=stream) | 451 revs=rev, update=False, stream=stream) |
452 | 452 |
453 # Resolve the value to put in [paths] section for the source. | 453 # Resolve the value to put in [paths] section for the source. |
454 if islocal(source): | 454 if islocal(source): |
455 defaultpath = os.path.abspath(util.urllocalpath(source)) | 455 defaultpath = os.path.abspath(util.urllocalpath(source)) |
456 else: | 456 else: |
481 if os.path.exists(srcbranchcache): | 481 if os.path.exists(srcbranchcache): |
482 if not os.path.exists(dstcachedir): | 482 if not os.path.exists(dstcachedir): |
483 os.mkdir(dstcachedir) | 483 os.mkdir(dstcachedir) |
484 util.copyfile(srcbranchcache, dstbranchcache) | 484 util.copyfile(srcbranchcache, dstbranchcache) |
485 | 485 |
486 def clone(ui, peeropts, source, dest=None, pull=False, rev=None, | 486 def clone(ui, peeropts, source, dest=None, pull=False, revs=None, |
487 update=True, stream=False, branch=None, shareopts=None): | 487 update=True, stream=False, branch=None, shareopts=None): |
488 """Make a copy of an existing repository. | 488 """Make a copy of an existing repository. |
489 | 489 |
490 Create a copy of an existing repository in a new directory. The | 490 Create a copy of an existing repository in a new directory. The |
491 source and destination are URLs, as passed to the repository | 491 source and destination are URLs, as passed to the repository |
510 server prefers streaming | 510 server prefers streaming |
511 | 511 |
512 stream: stream raw data uncompressed from repository (fast over | 512 stream: stream raw data uncompressed from repository (fast over |
513 LAN, slow over WAN) | 513 LAN, slow over WAN) |
514 | 514 |
515 rev: revision to clone up to (implies pull=True) | 515 revs: revision to clone up to (implies pull=True) |
516 | 516 |
517 update: update working directory after clone completes, if | 517 update: update working directory after clone completes, if |
518 destination is local repository (True means update to default rev, | 518 destination is local repository (True means update to default rev, |
519 anything else is treated as a revision) | 519 anything else is treated as a revision) |
520 | 520 |
534 srcpeer = peer(ui, peeropts, source) | 534 srcpeer = peer(ui, peeropts, source) |
535 else: | 535 else: |
536 srcpeer = source.peer() # in case we were called with a localrepo | 536 srcpeer = source.peer() # in case we were called with a localrepo |
537 branches = (None, branch or []) | 537 branches = (None, branch or []) |
538 origsource = source = srcpeer.url() | 538 origsource = source = srcpeer.url() |
539 rev, checkout = addbranchrevs(srcpeer, srcpeer, branches, rev) | 539 revs, checkout = addbranchrevs(srcpeer, srcpeer, branches, revs) |
540 | 540 |
541 if dest is None: | 541 if dest is None: |
542 dest = defaultdest(source) | 542 dest = defaultdest(source) |
543 if dest: | 543 if dest: |
544 ui.status(_("destination directory: %s\n") % dest) | 544 ui.status(_("destination directory: %s\n") % dest) |
585 raise error.Abort(_('unknown share naming mode: %s') % | 585 raise error.Abort(_('unknown share naming mode: %s') % |
586 sharenamemode) | 586 sharenamemode) |
587 | 587 |
588 if sharepath: | 588 if sharepath: |
589 return clonewithshare(ui, peeropts, sharepath, source, srcpeer, | 589 return clonewithshare(ui, peeropts, sharepath, source, srcpeer, |
590 dest, pull=pull, rev=rev, update=update, | 590 dest, pull=pull, rev=revs, update=update, |
591 stream=stream) | 591 stream=stream) |
592 | 592 |
593 srclock = destlock = cleandir = None | 593 srclock = destlock = cleandir = None |
594 srcrepo = srcpeer.local() | 594 srcrepo = srcpeer.local() |
595 try: | 595 try: |
601 cleandir = dest | 601 cleandir = dest |
602 | 602 |
603 copy = False | 603 copy = False |
604 if (srcrepo and srcrepo.cancopy() and islocal(dest) | 604 if (srcrepo and srcrepo.cancopy() and islocal(dest) |
605 and not phases.hassecret(srcrepo)): | 605 and not phases.hassecret(srcrepo)): |
606 copy = not pull and not rev | 606 copy = not pull and not revs |
607 | 607 |
608 if copy: | 608 if copy: |
609 try: | 609 try: |
610 # we use a lock here because if we race with commit, we | 610 # we use a lock here because if we race with commit, we |
611 # can end up with extra data in the cloned revlogs that's | 611 # can end up with extra data in the cloned revlogs that's |
658 cleandir = None | 658 cleandir = None |
659 raise error.Abort(_("destination '%s' already exists") | 659 raise error.Abort(_("destination '%s' already exists") |
660 % dest) | 660 % dest) |
661 raise | 661 raise |
662 | 662 |
663 revs = None | 663 if revs: |
664 if rev: | |
665 if not srcpeer.capable('lookup'): | 664 if not srcpeer.capable('lookup'): |
666 raise error.Abort(_("src repository does not support " | 665 raise error.Abort(_("src repository does not support " |
667 "revision lookup and so doesn't " | 666 "revision lookup and so doesn't " |
668 "support clone by revision")) | 667 "support clone by revision")) |
669 revs = [srcpeer.lookup(r) for r in rev] | 668 revs = [srcpeer.lookup(r) for r in revs] |
670 checkout = revs[0] | 669 checkout = revs[0] |
670 else: | |
671 revs = None | |
671 local = destpeer.local() | 672 local = destpeer.local() |
672 if local: | 673 if local: |
673 u = util.url(abspath) | 674 u = util.url(abspath) |
674 defaulturl = bytes(u) | 675 defaulturl = bytes(u) |
675 local.ui.setconfig('paths', 'default', defaulturl, 'clone') | 676 local.ui.setconfig('paths', 'default', defaulturl, 'clone') |