[cig-commits] commit: `hg fpush` now behaves much like `hg push`

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


changeset:   64:a45213137945
user:        Simon Law <simon at akoha.org>
date:        Mon Aug 27 13:43:43 2007 -0400
files:       forest.py test-forest test-forest.out
description:
`hg fpush` now behaves much like `hg push`


diff -r 95a1f9aab6ab -r a45213137945 forest.py
--- a/forest.py	Mon Aug 27 13:43:06 2007 -0400
+++ b/forest.py	Mon Aug 27 13:43:43 2007 -0400
@@ -946,28 +946,45 @@ def pull(ui, top, source="default", path
     forest.apply(ui, function, source, opts,
                  prehooks=[lambda tree: check_mq(tree)])
 
-def push(ui, toprepo, snapfile, pathalias, **opts):
-    """Push changes in a local forest to remote destinations.
-
-    Iterate over the entries in the snapshot file and, for each entry
-    matching an actual tree in the forest and with a location
-    associated with 'pathalias', push changes from this tree to the
-    location.
-
-    Skip entries that do not match or trees for which there is no entry.
-    """
-
-    opts['force'] = None
-    opts['rev'] = []
-
-    def doit(repo, root, path, rev, mq_applied):
-        if mq_applied:
-            ui.write(_("skipped, mq patches applied\n"))
+def push(ui, top, dest=None, pathalias=None, **opts):
+    """push changes to the specified forest.
+
+    Push changes from the local forest to the given destination.
+
+    You may specify a snapshot file, which is generated by the fsnap
+    command.  For each tree in this file, push the specified revision
+    to the specified destination path.
+
+    Look at the help text for the push command for more information.
+    """
+
+    if pathalias:
+        # Compatibility with old 'hg fpush SNAPFILE PATH-ALIAS' syntax
+        snapfile = dest
+        dest = [pathalias]
+        opts['rev'] = ['tip']           # Force a push from tip
+    else:
+        snapfile = opts['snapfile']
+        if dest:
+            dest = [dest]
         else:
-            commands.push(repo.ui, repo, path, **opts)
-
-    snapshot = ForestSnapshot(snapfile)
-    snapshot(ui, toprepo, doit, pathalias)
+            dest = ["default-push", "default"]
+    forest = Forest(top=top, snapfile=snapfile,
+                    walkhg=walkhgenabled(ui, opts['walkhg']))
+
+    def function(tree, destpath, opts):
+        try:
+            commands.push(ui, tree.getrepo(ui), destpath, **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, dest, opts,
+                 prehooks=[lambda tree: check_mq(tree)])
 
 
 def seed(ui, snapshot, pathalias='default', root='', tip=False, **opts):
@@ -1080,10 +1097,10 @@ def uisetup(ui):
             (pull,
              [walkhgopts, snapfileopts] + cmd_options(ui, 'pull', remove=('f',)),
              _('hg fpull [OPTION]... [SOURCE]')),
-        "fpush" :
+        "^fpush" :
             (push,
-             cmd_options(ui, 'push', remove=('f', 'r')),
-             _('hg fpush [OPTIONS] SNAPSHOT-FILE PATH-ALIAS')),
+             [walkhgopts, snapfileopts] + cmd_options(ui, 'push', remove=('f',)),
+             _('hg fpush [OPTION]... [DEST]')),
         "fseed" :
             (seed,
              [('', 'root', '',
diff -r 95a1f9aab6ab -r a45213137945 test-forest
--- a/test-forest	Mon Aug 27 13:43:06 2007 -0400
+++ b/test-forest	Mon Aug 27 13:43:43 2007 -0400
@@ -147,7 +147,7 @@ hg fpull --cwd topcopy -u ../top-snap de
     | sed "s@\(/private\)*$HGTMP at HGTMP@g"
 
 echo "# fpush + mq"
-hg fpush --cwd topcopy ../top-snap default \
+hg fpush --cwd topcopy ../top-snap default 2>&1 \
     | sed "s@\(/private\)*$HGTMP at HGTMP@g"
 
 echo "# walk **/.hg"
diff -r 95a1f9aab6ab -r a45213137945 test-forest.out
--- a/test-forest.out	Mon Aug 27 13:43:06 2007 -0400
+++ b/test-forest.out	Mon Aug 27 13:43:43 2007 -0400
@@ -469,10 +469,10 @@ no changes found
 no changes found
 
 [t]
-skipped, mq patches applied
-
-[t/t]
-skipped, mq patches applied
+skipped: 't' has mq patches applied
+
+[t/t]
+skipped: 't/t' has mq patches applied
 
 # walk **/.hg
 .



More information about the CIG-COMMITS mailing list