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