# HG changeset patch # User Benoit Boissinot # Date 1140582069 -3600 # Node ID 35a05f177267555f720721c3d30fd300981f304c # Parent b9671b41e360dfa04ea32d0e401dc6249d993438# Parent 8a1f2eae2832e07874e594e4689d3b538e5fbb5c merge with matt diff -r 8a1f2eae2832 -r 35a05f177267 mercurial/commands.py --- a/mercurial/commands.py Tue Feb 21 17:36:27 2006 -0600 +++ b/mercurial/commands.py Wed Feb 22 05:21:09 2006 +0100 @@ -1800,7 +1800,7 @@ return r -def push(ui, repo, dest="default-push", force=False, ssh=None, remotecmd=None): +def push(ui, repo, dest="default-push", **opts): """push changes to the specified destination Push changes from the local repository to the given destination. @@ -1825,13 +1825,16 @@ dest = ui.expandpath(dest, repo.root) ui.status('pushing to %s\n' % (dest)) - if ssh: - ui.setconfig("ui", "ssh", ssh) - if remotecmd: - ui.setconfig("ui", "remotecmd", remotecmd) + if opts['ssh']: + ui.setconfig("ui", "ssh", opts['ssh']) + if opts['remotecmd']: + ui.setconfig("ui", "remotecmd", opts['remotecmd']) other = hg.repository(ui, dest) - r = repo.push(other, force) + revs = None + if opts['rev']: + revs = [repo.lookup(rev) for rev in opts['rev']] + r = repo.push(other, opts['force'], revs=revs) return r def rawcommit(ui, repo, *flist, **rc): @@ -2505,14 +2508,15 @@ ('r', 'rev', [], _('a specific revision you would like to pull')), ('', 'remotecmd', '', _('specify hg command to run on the remote side'))], - _('hg pull [-u] [-e FILE] [-r rev] [--remotecmd FILE] [SOURCE]')), + _('hg pull [-u] [-e FILE] [-r rev]... [--remotecmd FILE] [SOURCE]')), "^push": (push, [('f', 'force', None, _('force push')), ('e', 'ssh', '', _('specify ssh command to use')), + ('r', 'rev', [], _('a specific revision you would like to push')), ('', 'remotecmd', '', _('specify hg command to run on the remote side'))], - _('hg push [-f] [-e FILE] [--remotecmd FILE] [DEST]')), + _('hg push [-f] [-e FILE] [-r rev]... [--remotecmd FILE] [DEST]')), "rawcommit": (rawcommit, [('p', 'parent', [], _('parent')), diff -r 8a1f2eae2832 -r 35a05f177267 mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Feb 21 17:36:27 2006 -0600 +++ b/mercurial/localrepo.py Wed Feb 22 05:21:09 2006 +0100 @@ -950,8 +950,8 @@ cg = remote.changegroupsubset(fetch, heads, 'pull') return self.addchangegroup(cg) - def push(self, remote, force=False): - l = remote.lock() + def push(self, remote, force=False, revs=None): + lock = remote.lock() base = {} heads = remote.heads() @@ -962,17 +962,25 @@ return 1 update = self.findoutgoing(remote, base) - if not update: + if revs is not None: + msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) + else: + bases, heads = update, self.changelog.heads() + + if not bases: self.ui.status(_("no changes found\n")) return 1 elif not force: - if len(heads) < len(self.changelog.heads()): + if len(bases) < len(heads): self.ui.warn(_("abort: push creates new remote branches!\n")) self.ui.status(_("(did you forget to merge?" " use push -f to force)\n")) return 1 - cg = self.changegroup(update, 'push') + if revs is None: + cg = self.changegroup(update, 'push') + else: + cg = self.changegroupsubset(update, revs, 'push') return remote.addchangegroup(cg) def changegroupsubset(self, bases, heads, source): diff -r 8a1f2eae2832 -r 35a05f177267 tests/test-push-r --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-push-r Wed Feb 22 05:21:09 2006 +0100 @@ -0,0 +1,61 @@ +#!/bin/bash + +hg init test +cd test +cat >>afile <>afile <>afile <>afile <>afile <>afile <fred <>afile <