hgext/closehead.py
changeset 43076 2372284d9457
parent 40293 c303d65d2e34
child 43077 687b865b95ad
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
    26 # leave the attribute unspecified.
    26 # leave the attribute unspecified.
    27 testedwith = 'ships-with-hg-core'
    27 testedwith = 'ships-with-hg-core'
    28 
    28 
    29 commitopts = cmdutil.commitopts
    29 commitopts = cmdutil.commitopts
    30 commitopts2 = cmdutil.commitopts2
    30 commitopts2 = cmdutil.commitopts2
    31 commitopts3 = [('r', 'rev', [],
    31 commitopts3 = [('r', 'rev', [], _('revision to check'), _('REV'))]
    32                _('revision to check'), _('REV'))]
       
    33 
    32 
    34 @command('close-head|close-heads', commitopts + commitopts2 + commitopts3,
    33 
       
    34 @command(
       
    35     'close-head|close-heads',
       
    36     commitopts + commitopts2 + commitopts3,
    35     _('[OPTION]... [REV]...'),
    37     _('[OPTION]... [REV]...'),
    36     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
    38     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
    37     inferrepo=True)
    39     inferrepo=True,
       
    40 )
    38 def close_branch(ui, repo, *revs, **opts):
    41 def close_branch(ui, repo, *revs, **opts):
    39     """close the given head revisions
    42     """close the given head revisions
    40 
    43 
    41     This is equivalent to checking out each revision in a clean tree and running
    44     This is equivalent to checking out each revision in a clean tree and running
    42     ``hg commit --close-branch``, except that it doesn't change the working
    45     ``hg commit --close-branch``, except that it doesn't change the working
    43     directory.
    46     directory.
    44 
    47 
    45     The commit message must be specified with -l or -m.
    48     The commit message must be specified with -l or -m.
    46     """
    49     """
       
    50 
    47     def docommit(rev):
    51     def docommit(rev):
    48         cctx = context.memctx(repo, parents=[rev, None], text=message,
    52         cctx = context.memctx(
    49                               files=[], filectxfn=None, user=opts.get('user'),
    53             repo,
    50                               date=opts.get('date'), extra=extra)
    54             parents=[rev, None],
       
    55             text=message,
       
    56             files=[],
       
    57             filectxfn=None,
       
    58             user=opts.get('user'),
       
    59             date=opts.get('date'),
       
    60             extra=extra,
       
    61         )
    51         tr = repo.transaction('commit')
    62         tr = repo.transaction('commit')
    52         ret = repo.commitctx(cctx, True)
    63         ret = repo.commitctx(cctx, True)
    53         bookmarks.update(repo, [rev, None], ret)
    64         bookmarks.update(repo, [rev, None], ret)
    54         cctx.markcommitted(ret)
    65         cctx.markcommitted(ret)
    55         tr.close()
    66         tr.close()
    71             raise error.Abort(_('revision is not an open head: %d') % rev)
    82             raise error.Abort(_('revision is not an open head: %d') % rev)
    72 
    83 
    73     message = cmdutil.logmessage(ui, opts)
    84     message = cmdutil.logmessage(ui, opts)
    74     if not message:
    85     if not message:
    75         raise error.Abort(_("no commit message specified with -l or -m"))
    86         raise error.Abort(_("no commit message specified with -l or -m"))
    76     extra = { 'close': '1' }
    87     extra = {'close': '1'}
    77 
    88 
    78     with repo.wlock(), repo.lock():
    89     with repo.wlock(), repo.lock():
    79         for rev in revs:
    90         for rev in revs:
    80             r = repo[rev]
    91             r = repo[rev]
    81             branch = r.branch()
    92             branch = r.branch()