##// END OF EJS Templates
Abort: add a hint argument, printed in the next line inside parenthesis...
Benoit Boissinot -
r11574:6381fa7b default
parent child Browse files
Show More
@@ -252,18 +252,16 b' def prepush(repo, remote, force, revs, n'
252
252
253 def fail_multiple_heads(unsynced, branch=None):
253 def fail_multiple_heads(unsynced, branch=None):
254 if branch:
254 if branch:
255 msg = _("abort: push creates new remote heads"
255 msg = _("push creates new remote heads "
256 " on branch '%s'!\n") % branch
256 "on branch '%s'!") % branch
257 else:
257 else:
258 msg = _("abort: push creates new remote heads!\n")
258 msg = _("push creates new remote heads!")
259 repo.ui.warn(msg)
259
260 if unsynced:
260 if unsynced:
261 repo.ui.status(_("(you should pull and merge or"
261 hint = _("you should pull and merge or use push -f to force")
262 " use push -f to force)\n"))
263 else:
262 else:
264 repo.ui.status(_("(did you forget to merge?"
263 hint = _("did you forget to merge? use push -f to force")
265 " use push -f to force)\n"))
264 raise util.Abort(msg, hint=hint)
266 return None, 0
267
265
268 if remote.capable('branchmap'):
266 if remote.capable('branchmap'):
269 # Check for each named branch if we're creating new remote heads.
267 # Check for each named branch if we're creating new remote heads.
@@ -283,12 +281,10 b' def prepush(repo, remote, force, revs, n'
283 newbranches = branches - set(remotemap)
281 newbranches = branches - set(remotemap)
284 if newbranches and not newbranch: # new branch requires --new-branch
282 if newbranches and not newbranch: # new branch requires --new-branch
285 branchnames = ', '.join(sorted(newbranches))
283 branchnames = ', '.join(sorted(newbranches))
286 repo.ui.warn(_("abort: push creates "
284 raise util.Abort(_("push creates new remote branches: %s!")
287 "new remote branches: %s!\n")
285 % branchnames,
288 % branchnames)
286 hint=_("use 'hg push --new-branch' to create"
289 repo.ui.status(_("(use 'hg push --new-branch' to create new "
287 " new remote branches"))
290 "remote branches)\n"))
291 return None, 0
292 branches.difference_update(newbranches)
288 branches.difference_update(newbranches)
293
289
294 # 3. Construct the initial oldmap and newmap dicts.
290 # 3. Construct the initial oldmap and newmap dicts.
@@ -23,6 +23,8 b' def dispatch(args):'
23 u.setconfig('ui', 'traceback', 'on')
23 u.setconfig('ui', 'traceback', 'on')
24 except util.Abort, inst:
24 except util.Abort, inst:
25 sys.stderr.write(_("abort: %s\n") % inst)
25 sys.stderr.write(_("abort: %s\n") % inst)
26 if inst.hint:
27 sys.stdout.write(_("(%s)\n") % inst.hint)
26 return -1
28 return -1
27 except error.ParseError, inst:
29 except error.ParseError, inst:
28 if len(inst.args) > 1:
30 if len(inst.args) > 1:
@@ -116,6 +118,8 b' def _runcatch(ui, args):'
116 commands.help_(ui, 'shortlist')
118 commands.help_(ui, 'shortlist')
117 except util.Abort, inst:
119 except util.Abort, inst:
118 ui.warn(_("abort: %s\n") % inst)
120 ui.warn(_("abort: %s\n") % inst)
121 if inst.hint:
122 ui.status(_("(%s)\n") % inst.hint)
119 except ImportError, inst:
123 except ImportError, inst:
120 ui.warn(_("abort: %s!\n") % inst)
124 ui.warn(_("abort: %s!\n") % inst)
121 m = str(inst).split()[-1]
125 m = str(inst).split()[-1]
@@ -32,6 +32,9 b' class CommandError(Exception):'
32
32
33 class Abort(Exception):
33 class Abort(Exception):
34 """Raised if a command needs to print an error and exit."""
34 """Raised if a command needs to print an error and exit."""
35 def __init__(self, *args, **kw):
36 Exception.__init__(self, *args)
37 self.hint = kw.get('hint')
35
38
36 class ConfigError(Abort):
39 class ConfigError(Abort):
37 'Exception raised when parsing config files'
40 'Exception raised when parsing config files'
@@ -37,7 +37,7 b' pushing to ../c'
37 searching for changes
37 searching for changes
38 abort: push creates new remote heads on branch 'default'!
38 abort: push creates new remote heads on branch 'default'!
39 (did you forget to merge? use push -f to force)
39 (did you forget to merge? use push -f to force)
40 1
40 255
41 pushing to ../c
41 pushing to ../c
42 searching for changes
42 searching for changes
43 no changes found
43 no changes found
@@ -46,12 +46,12 b' pushing to ../c'
46 searching for changes
46 searching for changes
47 abort: push creates new remote heads on branch 'default'!
47 abort: push creates new remote heads on branch 'default'!
48 (did you forget to merge? use push -f to force)
48 (did you forget to merge? use push -f to force)
49 1
49 255
50 pushing to ../c
50 pushing to ../c
51 searching for changes
51 searching for changes
52 abort: push creates new remote heads on branch 'default'!
52 abort: push creates new remote heads on branch 'default'!
53 (did you forget to merge? use push -f to force)
53 (did you forget to merge? use push -f to force)
54 1
54 255
55 pushing to ../c
55 pushing to ../c
56 searching for changes
56 searching for changes
57 adding changesets
57 adding changesets
@@ -90,29 +90,29 b' 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 --new-branch' to create new remote branches)
92 (use 'hg push --new-branch' to create new remote branches)
93 1
93 255
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 --new-branch' to create new remote branches)
97 (use 'hg push --new-branch' to create new remote branches)
98 1
98 255
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 --new-branch' to create new remote branches)
103 (use 'hg push --new-branch' to create new remote branches)
104 1
104 255
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 --new-branch' to create new remote branches)
108 (use 'hg push --new-branch' to create new remote branches)
109 1
109 255
110 % fail on multiple head push
110 % fail on multiple head push
111 pushing to ../f
111 pushing to ../f
112 searching for changes
112 searching for changes
113 abort: push creates new remote heads on branch 'a'!
113 abort: push creates new remote heads on branch 'a'!
114 (did you forget to merge? use push -f to force)
114 (did you forget to merge? use push -f to force)
115 1
115 255
116 % push replacement head on existing branches
116 % push replacement head on existing branches
117 pushing to ../f
117 pushing to ../f
118 searching for changes
118 searching for changes
@@ -149,7 +149,7 b' pushing to ../f'
149 searching for changes
149 searching for changes
150 abort: push creates new remote branches: e!
150 abort: push creates new remote branches: e!
151 (use 'hg push --new-branch' to create new remote branches)
151 (use 'hg push --new-branch' to create new remote branches)
152 1
152 255
153 % using --new-branch to push new named branch
153 % using --new-branch to push new named branch
154 pushing to ../f
154 pushing to ../f
155 searching for changes
155 searching for changes
General Comments 0
You need to be logged in to leave comments. Login now