mercurial/commands.py
changeset 47430 3ee036c6f834
parent 47429 5c49e0aa7fad
child 47431 fca9c63f160e
equal deleted inserted replaced
47429:5c49e0aa7fad 47430:3ee036c6f834
  2075         )
  2075         )
  2076         # ret can be 0 (no changes to record) or the value returned by
  2076         # ret can be 0 (no changes to record) or the value returned by
  2077         # commit(), 1 if nothing changed or None on success.
  2077         # commit(), 1 if nothing changed or None on success.
  2078         return 1 if ret == 0 else ret
  2078         return 1 if ret == 0 else ret
  2079 
  2079 
  2080     opts = pycompat.byteskwargs(opts)
  2080     if opts.get('subrepos'):
  2081     if opts.get(b'subrepos'):
  2081         cmdutil.check_incompatible_arguments(opts, 'subrepos', ['amend'])
  2082         cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'amend'])
       
  2083         # Let --subrepos on the command line override config setting.
  2082         # Let --subrepos on the command line override config setting.
  2084         ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
  2083         ui.setconfig(b'ui', b'commitsubrepos', True, b'commit')
  2085 
  2084 
  2086     cmdutil.checkunfinished(repo, commit=True)
  2085     cmdutil.checkunfinished(repo, commit=True)
  2087 
  2086 
  2088     branch = repo[None].branch()
  2087     branch = repo[None].branch()
  2089     bheads = repo.branchheads(branch)
  2088     bheads = repo.branchheads(branch)
  2090     tip = repo.changelog.tip()
  2089     tip = repo.changelog.tip()
  2091 
  2090 
  2092     extra = {}
  2091     extra = {}
  2093     if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
  2092     if opts.get('close_branch') or opts.get('force_close_branch'):
  2094         extra[b'close'] = b'1'
  2093         extra[b'close'] = b'1'
  2095 
  2094 
  2096         if repo[b'.'].closesbranch():
  2095         if repo[b'.'].closesbranch():
  2097             raise error.InputError(
  2096             raise error.InputError(
  2098                 _(b'current revision is already a branch closing head')
  2097                 _(b'current revision is already a branch closing head')
  2102                 _(b'branch "%s" has no heads to close') % branch
  2101                 _(b'branch "%s" has no heads to close') % branch
  2103             )
  2102             )
  2104         elif (
  2103         elif (
  2105             branch == repo[b'.'].branch()
  2104             branch == repo[b'.'].branch()
  2106             and repo[b'.'].node() not in bheads
  2105             and repo[b'.'].node() not in bheads
  2107             and not opts.get(b'force_close_branch')
  2106             and not opts.get('force_close_branch')
  2108         ):
  2107         ):
  2109             hint = _(
  2108             hint = _(
  2110                 b'use --force-close-branch to close branch from a non-head'
  2109                 b'use --force-close-branch to close branch from a non-head'
  2111                 b' changeset'
  2110                 b' changeset'
  2112             )
  2111             )
  2113             raise error.InputError(_(b'can only close branch heads'), hint=hint)
  2112             raise error.InputError(_(b'can only close branch heads'), hint=hint)
  2114         elif opts.get(b'amend'):
  2113         elif opts.get('amend'):
  2115             if (
  2114             if (
  2116                 repo[b'.'].p1().branch() != branch
  2115                 repo[b'.'].p1().branch() != branch
  2117                 and repo[b'.'].p2().branch() != branch
  2116                 and repo[b'.'].p2().branch() != branch
  2118             ):
  2117             ):
  2119                 raise error.InputError(_(b'can only close branch heads'))
  2118                 raise error.InputError(_(b'can only close branch heads'))
  2120 
  2119 
  2121     if opts.get(b'amend'):
  2120     if opts.get('amend'):
  2122         if ui.configbool(b'ui', b'commitsubrepos'):
  2121         if ui.configbool(b'ui', b'commitsubrepos'):
  2123             raise error.InputError(
  2122             raise error.InputError(
  2124                 _(b'cannot amend with ui.commitsubrepos enabled')
  2123                 _(b'cannot amend with ui.commitsubrepos enabled')
  2125             )
  2124             )
  2126 
  2125 
  2134         # Note: eventually this guard will be removed. Please do not expect
  2133         # Note: eventually this guard will be removed. Please do not expect
  2135         # this behavior to remain.
  2134         # this behavior to remain.
  2136         if not obsolete.isenabled(repo, obsolete.createmarkersopt):
  2135         if not obsolete.isenabled(repo, obsolete.createmarkersopt):
  2137             cmdutil.checkunfinished(repo)
  2136             cmdutil.checkunfinished(repo)
  2138 
  2137 
       
  2138         opts = pycompat.byteskwargs(opts)
  2139         node = cmdutil.amend(ui, repo, old, extra, pats, opts)
  2139         node = cmdutil.amend(ui, repo, old, extra, pats, opts)
  2140         if node == old.node():
  2140         if node == old.node():
  2141             ui.status(_(b"nothing changed\n"))
  2141             ui.status(_(b"nothing changed\n"))
  2142             return 1
  2142             return 1
  2143     else:
  2143     else:
  2163                         match,
  2163                         match,
  2164                         editor=editor,
  2164                         editor=editor,
  2165                         extra=extra,
  2165                         extra=extra,
  2166                     )
  2166                     )
  2167 
  2167 
       
  2168         opts = pycompat.byteskwargs(opts)
  2168         node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
  2169         node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
  2169 
  2170 
  2170         if not node:
  2171         if not node:
  2171             stat = cmdutil.postcommitstatus(repo, pats, opts)
  2172             stat = cmdutil.postcommitstatus(repo, pats, opts)
  2172             if stat.deleted:
  2173             if stat.deleted: