Comments
Patch
@@ -5092,8 +5092,10 @@ def push(ui, repo, dest=None, **opts):
other = hg.peer(repo, opts, url)
if revs:
revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
+ elif path.pushrevset:
+ revs = [repo[rev].node() for rev in repo.revs(path.pushrevset)]
repo._subtoppath = url
try:
# push subrepos depth-first for coherent ordering
@@ -1102,8 +1102,23 @@ The following per-path options are recog
location assigned to the main path option will be used.
Note: ``#revision`` fragments are not allowed in ``purlurl``.
+``pushrevset``
+ A revset defining the revisions to push to this path by default.
+
+ By default, :hg:`push` will attempt to push all local changesets
+ to a remote. If this is set, :hg:`push` with no ``-r`` argument
+ will use the revset specified by this option to determine what to
+ push.
+
+ e.g. use ``.pushrev = .`` to default to pushing the changeset the
+ working copy is based upon.
+
+ Note: Bookmarks will not be pushed if this option is set, even if the
+ revset specifies bookmarks to push. This is because revsets evaluate
+ to changesets, not names.
+
``phases``
----------
Specifies default handling of phases. See :hg:`help phases` for more
@@ -959,9 +959,10 @@ class paths(object):
if '.' in name:
continue
yield path(name, url=loc,
- pushurl=ui.config('paths', '%s.pushurl' % name))
+ pushurl=ui.config('paths', '%s.pushurl' % name),
+ pushrevset=ui.config('paths', '%s.pushrevset' % name))
def __getitem__(self, key):
for path in self:
if path.name == key:
@@ -1022,9 +1023,10 @@ class paths(object):
class path(object):
"""Represents an individual path and its configuration."""
- def __init__(self, name, url=None, local=None, pushurl=None):
+ def __init__(self, name, url=None, local=None, pushurl=None,
+ pushrevset=None):
"""Construct a path from its config options.
The primary URL for the path is defined as either a URL via ``url``
(preferred) or from a local, relative filesystem path (``local``).
@@ -1046,4 +1048,5 @@ class path(object):
raise util.Abort(_('pushurl may not have #revision fragment: %s') %
pushurl)
self.pushurl = pushurl or url
+ self.pushrevset = pushrevset
@@ -47,4 +47,88 @@ Push should use "pushurl"
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
+
+Push should use "pushrevset"
+
+ $ cat >> .hg/hgrc << EOF
+ > pushrevset1 = ssh://user@dummy/$TESTTMP/server
+ > pushrevset1.pushrevset = .
+ > EOF
+
+ $ echo head1 > foo
+ $ hg commit -m 'head 1'
+ $ hg -q up -r 0
+ $ echo head2 > foo
+ $ hg commit -m 'head 2'
+ created new head
+
+ $ hg push pushrevset1
+ pushing to ssh://user@dummy/$TESTTMP/server
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 1 changesets with 1 changes to 1 files
+
+We can override pushrevset via -r
+
+ $ hg push -r 1 -f pushrevset1
+ pushing to ssh://user@dummy/$TESTTMP/server
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 1 changesets with 1 changes to 1 files (+1 heads)
+
+A pushrevset with multiple branches configured will push those branches
+
+ $ hg -q up -r 0
+ $ hg branch b1
+ marked working directory as branch b1
+ (branches are permanent and global, did you want a bookmark?)
+ $ echo b1_1 > foo
+ $ hg commit -m 'branch 1 commit 1'
+ $ hg -q up -r 0
+ $ hg branch b2
+ marked working directory as branch b2
+ (branches are permanent and global, did you want a bookmark?)
+ $ echo b2_1 > foo
+ $ hg commit -m 'branch 2 commit 1'
+ $ hg -q up -r 0
+ $ hg branch b3
+ marked working directory as branch b3
+ (branches are permanent and global, did you want a bookmark?)
+ $ echo b3_1 > foo
+ $ hg commit -m 'branch 3 commit 1'
+
+ $ hg push -b b1 -b b2 -b b3 --new-branch ssh://user@dummy/$TESTTMP/server
+ pushing to ssh://user@dummy/$TESTTMP/server
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 3 changesets with 3 changes to 1 files (+3 heads)
+
+ $ cat >> .hg/hgrc << EOF
+ > twobranches = ssh://user@dummy/$TESTTMP/server
+ > twobranches.pushrevset = b1 or b2
+ > EOF
+
+ $ hg -q up b1
+ $ echo b1_2 > foo
+ $ hg commit -m 'branch 1 commit 2'
+ $ hg -q up b2
+ $ echo b2_2 > foo
+ $ hg commit -m 'branch 2 commit 2'
+ $ hg -q up b3
+ $ echo b3_2 > foo
+ $ hg commit -m 'branch 3 commit 2'
+
+ $ hg push twobranches
+ pushing to ssh://user@dummy/$TESTTMP/server
+ searching for changes
+ remote: adding changesets
+ remote: adding manifests
+ remote: adding file changes
+ remote: added 2 changesets with 2 changes to 1 files