##// END OF EJS Templates
push: add --new-branch option to allow intial push of new branches...
Sune Foldager -
r11211:e43c23d1 default
parent child Browse files
Show More
@@ -2555,10 +2555,10 b' def reposetup(ui, repo):'
2555 2555 return super(mqrepo, self).commit(text, user, date, match, force,
2556 2556 editor, extra)
2557 2557
2558 def push(self, remote, force=False, revs=None):
2558 def push(self, remote, force=False, revs=None, newbranch=False):
2559 2559 if self.mq.applied and not force and not revs:
2560 2560 raise util.Abort(_('source has mq patches applied'))
2561 return super(mqrepo, self).push(remote, force, revs)
2561 return super(mqrepo, self).push(remote, force, revs, newbranch)
2562 2562
2563 2563 def _findtags(self):
2564 2564 '''augment tags from base class with patch tags'''
@@ -2564,7 +2564,8 b' def push(ui, repo, dest=None, **opts):'
2564 2564 if not c.sub(s).push(opts.get('force')):
2565 2565 return False
2566 2566
2567 r = repo.push(other, opts.get('force'), revs=revs)
2567 r = repo.push(other, opts.get('force'), revs=revs,
2568 newbranch=opts.get('new_branch'))
2568 2569 return r == 0
2569 2570
2570 2571 def recover(ui, repo):
@@ -3948,6 +3949,7 b' table = {'
3948 3949 _('a changeset intended to be included in the destination')),
3949 3950 ('b', 'branch', [],
3950 3951 _('a specific branch you would like to push')),
3952 ('', 'new-branch', False, _('allow pushing a new branch')),
3951 3953 ] + remoteopts,
3952 3954 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
3953 3955 "recover": (recover, []),
@@ -1507,7 +1507,7 b' class localrepository(repo.repository):'
1507 1507 finally:
1508 1508 lock.release()
1509 1509
1510 def push(self, remote, force=False, revs=None):
1510 def push(self, remote, force=False, revs=None, newbranch=False):
1511 1511 '''Push outgoing changesets (limited by revs) from the current
1512 1512 repository to remote. Return an integer:
1513 1513 - 0 means HTTP error *or* nothing to push
@@ -1524,10 +1524,10 b' class localrepository(repo.repository):'
1524 1524 # servers, http servers).
1525 1525
1526 1526 if remote.capable('unbundle'):
1527 return self.push_unbundle(remote, force, revs)
1528 return self.push_addchangegroup(remote, force, revs)
1527 return self.push_unbundle(remote, force, revs, newbranch)
1528 return self.push_addchangegroup(remote, force, revs, newbranch)
1529 1529
1530 def prepush(self, remote, force, revs):
1530 def prepush(self, remote, force, revs, newbranch):
1531 1531 '''Analyze the local and remote repositories and determine which
1532 1532 changesets need to be pushed to the remote. Return value depends
1533 1533 on circumstances:
@@ -1586,13 +1586,15 b' class localrepository(repo.repository):'
1586 1586 # 2. Check for new branches on the remote.
1587 1587 remotemap = remote.branchmap()
1588 1588 newbranches = branches - set(remotemap)
1589 if newbranches: # new branch requires --force
1589 if newbranches and not newbranch: # new branch requires --new-branch
1590 1590 branchnames = ', '.join("%s" % b for b in newbranches)
1591 1591 self.ui.warn(_("abort: push creates "
1592 1592 "new remote branches: %s!\n")
1593 1593 % branchnames)
1594 self.ui.status(_("(use 'hg push -f' to force)\n"))
1594 self.ui.status(_("(use 'hg push --new-branch' to create new "
1595 "remote branches)\n"))
1595 1596 return None, 0
1597 branches.difference_update(newbranches)
1596 1598
1597 1599 # 3. Construct the initial oldmap and newmap dicts.
1598 1600 # They contain information about the remote heads before and
@@ -1654,14 +1656,14 b' class localrepository(repo.repository):'
1654 1656 cg = self.changegroupsubset(update, revs, 'push')
1655 1657 return cg, remote_heads
1656 1658
1657 def push_addchangegroup(self, remote, force, revs):
1659 def push_addchangegroup(self, remote, force, revs, newbranch):
1658 1660 '''Push a changegroup by locking the remote and sending the
1659 1661 addchangegroup command to it. Used for local and old SSH repos.
1660 1662 Return an integer: see push().
1661 1663 '''
1662 1664 lock = remote.lock()
1663 1665 try:
1664 ret = self.prepush(remote, force, revs)
1666 ret = self.prepush(remote, force, revs, newbranch)
1665 1667 if ret[0] is not None:
1666 1668 cg, remote_heads = ret
1667 1669 # here, we return an integer indicating remote head count change
@@ -1672,7 +1674,7 b' class localrepository(repo.repository):'
1672 1674 finally:
1673 1675 lock.release()
1674 1676
1675 def push_unbundle(self, remote, force, revs):
1677 def push_unbundle(self, remote, force, revs, newbranch):
1676 1678 '''Push a changegroup by unbundling it on the remote. Used for new
1677 1679 SSH and HTTP repos. Return an integer: see push().'''
1678 1680 # local repo finds heads on server, finds out what revs it
@@ -1680,7 +1682,7 b' class localrepository(repo.repository):'
1680 1682 # different heads (someone else won commit/push race), server
1681 1683 # aborts.
1682 1684
1683 ret = self.prepush(remote, force, revs)
1685 ret = self.prepush(remote, force, revs, newbranch)
1684 1686 if ret[0] is not None:
1685 1687 cg, remote_heads = ret
1686 1688 if force:
@@ -174,7 +174,7 b' init: ssh, remotecmd'
174 174 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, style, template, include, exclude
175 175 merge: force, rev, preview
176 176 pull: update, force, rev, branch, ssh, remotecmd
177 push: force, rev, branch, ssh, remotecmd
177 push: force, rev, branch, new-branch, ssh, remotecmd
178 178 remove: after, force, include, exclude
179 179 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
180 180 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude
@@ -135,6 +135,18 b' echo 12 > foo'
135 135 hg -q ci -d "1000000 0" -m 12
136 136 hg push -r 11 -r 12 ../f; echo $?
137 137
138 echo % failed push of new named branch
139 echo 12 > foo
140 hg -q ci -d "1000000 0" -m 12a
141 hg -q up 11
142 echo 13 > foo
143 hg -q branch e
144 hg -q ci -d "1000000 0" -m 13d
145 hg push -r 12 -r 13 ../f; echo $?
146
147 echo % using --new-branch to push new named branch
148 hg push --new-branch -r 12 -r 13 ../f; echo $?
149
138 150 echo % checking prepush logic does not allow silently pushing multiple new heads
139 151 cd ..
140 152 hg init h
@@ -89,23 +89,23 b' 0'
89 89 pushing to ../f
90 90 searching for changes
91 91 abort: push creates new remote branches: c!
92 (use 'hg push -f' to force)
92 (use 'hg push --new-branch' to create new remote branches)
93 93 1
94 94 pushing to ../f
95 95 searching for changes
96 96 abort: push creates new remote branches: c!
97 (use 'hg push -f' to force)
97 (use 'hg push --new-branch' to create new remote branches)
98 98 1
99 99 % multiple new branches
100 100 pushing to ../f
101 101 searching for changes
102 102 abort: push creates new remote branches: c, d!
103 (use 'hg push -f' to force)
103 (use 'hg push --new-branch' to create new remote branches)
104 104 1
105 105 pushing to ../f
106 106 searching for changes
107 107 abort: push creates new remote branches: c, d!
108 (use 'hg push -f' to force)
108 (use 'hg push --new-branch' to create new remote branches)
109 109 1
110 110 % fail on multiple head push
111 111 pushing to ../f
@@ -144,6 +144,20 b' adding manifests'
144 144 adding file changes
145 145 added 2 changesets with 2 changes to 1 files
146 146 0
147 % failed push of new named branch
148 pushing to ../f
149 searching for changes
150 abort: push creates new remote branches: e!
151 (use 'hg push --new-branch' to create new remote branches)
152 1
153 % using --new-branch to push new named branch
154 pushing to ../f
155 searching for changes
156 adding changesets
157 adding manifests
158 adding file changes
159 added 1 changesets with 1 changes to 1 files
160 0
147 161 % checking prepush logic does not allow silently pushing multiple new heads
148 162 adding init
149 163 adding a
@@ -172,7 +186,7 b' 1 files updated, 0 files merged, 0 files'
172 186 pushing to j
173 187 searching for changes
174 188 abort: push creates new remote branches: b!
175 (use 'hg push -f' to force)
189 (use 'hg push --new-branch' to create new remote branches)
176 190
177 191 % prepush -r should not allow you to sneak in new heads
178 192 pushing to ../l
General Comments 0
You need to be logged in to leave comments. Login now