[cig-commits] commit: `hg ffetch` becomes available if you have the fetch extension

Mercurial hg at geodynamics.org
Mon Nov 24 11:27:13 PST 2008


changeset:   71:73f97f3eef54
user:        Simon Law <simon at akoha.org>
date:        Mon Aug 27 13:53:22 2007 -0400
files:       forest.py
description:
`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
@@ -799,6 +799,48 @@ def clone(ui, source, dest=None, **opts)
         except util.Abort, err:
             ui.warn(_("skipped: %s\n") % err)
         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):
@@ -1270,4 +1312,17 @@ def uisetup(ui):
              _('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"



More information about the CIG-COMMITS mailing list