# HG changeset patch # User Simon Law # Date 1188237202 14400 # Node ID 73f97f3eef541f4d9d867a341e1c2e6444ab2f1c # Parent 148376451559550c0905ea5121e796bc009656c7 `hg ffetch` becomes available if you have the fetch extension This is to help you automatically pull and merge and the same time. diff -r 148376451559 -r 73f97f3eef54 forest.py --- a/forest.py Mon Aug 27 13:51:50 2007 -0400 +++ b/forest.py Mon Aug 27 13:53:22 2007 -0400 @@ -801,6 +801,48 @@ ui.status("\n") +def fetch(ui, top, source="default", **opts): + """pull changes from a remote forest, merge new changes if needed. + + This finds all changes from the forest at the specified path or + URL and adds them to the local forest. + + Look at the help text for the fetch command for more information. + """ + + snapfile = opts['snapfile'] + forest = Forest(top=top, snapfile=snapfile, + walkhg=walkhgenabled(ui, opts['walkhg'])) + source = [source] + try: + import hgext.fetch as fetch + except ImportError: + raise util.Abort(_("could not import fetch module\n")) + + def function(tree, srcpath, opts): + if not srcpath: + srcpath = forest.top().getpath(source) + if srcpath: + rpath = util.pconvert(relpath(forest.top().root, tree.root)) + srcpath = '/'.join((srcpath, rpath)) + else: + ui.warn(_("skipped: %s\n") % + _("repository %s not found") % source[0]) + return + try: + fetch.fetch(ui, tree.getrepo(ui), srcpath, **opts) + except Exception, err: + ui.warn(_("skipped: %s\n") % err) + tree.repo.transaction().__del__() + + @Forest.Tree.skip + def check_mq(tree): + tree.die_on_mq(top.root) + + forest.apply(ui, function, source, opts, + prehooks=[lambda tree: check_mq(tree)]) + + def incoming(ui, top, source="default", **opts): """show new changesets found in source forest @@ -1270,4 +1312,17 @@ _('hg fupdate [OPTION]...')) } + try: + import hgext.fetch + except ImportError: + return + try: + cmdtable.update({"ffetch": (fetch, + [walkhgopts, snapfileopts] + + cmd_options(ui, 'fetch', + remove=('bundle',)), + _('hg ffetch [OPTION]... [SOURCE]'))}) + except cmdutil.UnknownCommand: + return + commands.norepo += " fclone fseed"