# HG changeset patch # User Simon Law # Date 1188236623 14400 # Node ID a45213137945cf40840b74d31cc9deaadfbfc366 # Parent 95a1f9aab6abf6b512977ffb40822aedf04266d3 `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 @@ 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. +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. - 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. + 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. - Skip entries that do not match or trees for which there is no entry. + Look at the help text for the push command for more information. """ - opts['force'] = None - opts['rev'] = [] + 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: + dest = ["default-push", "default"] + forest = Forest(top=top, snapfile=snapfile, + walkhg=walkhgenabled(ui, opts['walkhg'])) - def doit(repo, root, path, rev, mq_applied): - if mq_applied: - ui.write(_("skipped, mq patches applied\n")) - else: - commands.push(repo.ui, repo, path, **opts) + 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__() - snapshot = ForestSnapshot(snapfile) - snapshot(ui, toprepo, doit, pathalias) + @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 @@ (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 @@ | sed "s@\(/private\)*$HGTMP@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@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 [t] -skipped, mq patches applied +skipped: 't' has mq patches applied [t/t] -skipped, mq patches applied +skipped: 't/t' has mq patches applied # walk **/.hg .