changeset 71:73f97f3eef54

`hg ffetch` becomes available if you have the fetch extension This is to help you automatically pull and merge and the same time.
author Simon Law <simon@akoha.org>
date Mon, 27 Aug 2007 13:53:22 -0400
parents 148376451559
children 1c916e260ece
files forest.py
diffstat 1 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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"