First draft for clone -u
Adrian Buehlmann
adrian at cadifra.com
Wed Oct 21 19:37:53 UTC 2009
I started trying to add option -u to the clone command.
Currently I have this first draft for a patch (feedback most welcome):
clone: add option -u/--updaterev
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -626,11 +626,14 @@ def clone(ui, source, dest=None, **opts)
this is not compatible with certain extensions that place their
metadata under the .hg directory, such as mq.
"""
+ if opts.get('noupdate') and opts.get('updaterev'):
+ raise util.Abort(_("cannot specify both --noupdate and --updaterev\n"))
+
hg.clone(cmdutil.remoteui(ui, opts), source, dest,
pull=opts.get('pull'),
stream=opts.get('uncompressed'),
rev=opts.get('rev'),
- update=not opts.get('noupdate'))
+ update=opts.get('updaterev') or not opts.get('noupdate'))
def commit(ui, repo, *pats, **opts):
"""commit the specified files or all outstanding changes
@@ -3347,6 +3350,8 @@ table = {
(clone,
[('U', 'noupdate', None,
_('the clone will only contain a repository (no working copy)')),
+ ('u', 'updaterev', '',
+ _('revision, tag or branch to check out')),
('r', 'rev', [],
_('a changeset you would like to have after cloning')),
('', 'pull', None, _('use pull protocol to copy metadata')),
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -309,6 +309,8 @@ def clone(ui, source, dest=None, pull=Fa
if update:
if update is not True:
checkout = update
+ if src_repo.local():
+ checkout = src_repo.lookup(update)
for test in (checkout, 'default', 'tip'):
if test is None:
continue
Example working uses:
$ hg clone -u stable http://bitbucket.org/tortoisehg/stable/ thgs
requesting all changes
adding changesets
adding manifests
adding file changes
added 4713 changesets with 6986 changes to 621 files
updating to branch stable
313 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg clone -u . thgs thgs2
updating to branch stable
313 files updated, 0 files merged, 0 files removed, 0 files unresolved
More information about the Mercurial-devel
mailing list