comparison hgext/fetch.py @ 4549:0c61124ad877

dispatch: move dispatching code to cmdutil
author Matt Mackall <mpm@selenic.com>
date Mon, 11 Jun 2007 21:09:24 -0500
parents 6b4127c7d52a
children eadfaa9ec487
comparison
equal deleted inserted replaced
4548:c9fcebbfc422 4549:0c61124ad877
5 # This software may be used and distributed according to the terms 5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 from mercurial.i18n import _ 8 from mercurial.i18n import _
9 from mercurial.node import * 9 from mercurial.node import *
10 from mercurial import commands, hg, node, util 10 from mercurial import commands, cmdutil, hg, node, util
11 11
12 def fetch(ui, repo, source='default', **opts): 12 def fetch(ui, repo, source='default', **opts):
13 '''Pull changes from a remote repository, merge new changes if needed. 13 '''Pull changes from a remote repository, merge new changes if needed.
14 14
15 This finds all changes from the repository at the specified path 15 This finds all changes from the repository at the specified path
40 ui.status(_('not merging with %d other new heads ' 40 ui.status(_('not merging with %d other new heads '
41 '(use "hg heads" and "hg merge" to merge them)') % 41 '(use "hg heads" and "hg merge" to merge them)') %
42 (len(newheads) - 1)) 42 (len(newheads) - 1))
43 if not err: 43 if not err:
44 mod, add, rem = repo.status(wlock=wlock)[:3] 44 mod, add, rem = repo.status(wlock=wlock)[:3]
45 message = (commands.logmessage(opts) or 45 message = (cmdutil.logmessage(opts) or
46 (_('Automated merge with %s') % other.url())) 46 (_('Automated merge with %s') % other.url()))
47 n = repo.commit(mod + add + rem, message, 47 n = repo.commit(mod + add + rem, message,
48 opts['user'], opts['date'], lock=lock, wlock=wlock, 48 opts['user'], opts['date'], lock=lock, wlock=wlock,
49 force_editor=opts.get('force_editor')) 49 force_editor=opts.get('force_editor'))
50 ui.status(_('new changeset %d:%s merges remote changes ' 50 ui.status(_('new changeset %d:%s merges remote changes '
51 'with local\n') % (repo.changelog.rev(n), 51 'with local\n') % (repo.changelog.rev(n),
52 short(n))) 52 short(n)))
53 def pull(): 53 def pull():
54 commands.setremoteconfig(ui, opts) 54 cmdutil.setremoteconfig(ui, opts)
55 55
56 other = hg.repository(ui, ui.expandpath(source)) 56 other = hg.repository(ui, ui.expandpath(source))
57 ui.status(_('pulling from %s\n') % ui.expandpath(source)) 57 ui.status(_('pulling from %s\n') % ui.expandpath(source))
58 revs = None 58 revs = None
59 if opts['rev'] and not other.local(): 59 if opts['rev'] and not other.local():