Mercurial > hg-stable
comparison hgext/closehead.py @ 43077:687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Done with
python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py')
black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**')
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6972
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:48:39 -0400 |
parents | 2372284d9457 |
children | 9d2b2df2c2ba |
comparison
equal
deleted
inserted
replaced
43076:2372284d9457 | 43077:687b865b95ad |
---|---|
22 command = registrar.command(cmdtable) | 22 command = registrar.command(cmdtable) |
23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | 23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | 24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
25 # be specifying the version(s) of Mercurial they are tested with, or | 25 # be specifying the version(s) of Mercurial they are tested with, or |
26 # leave the attribute unspecified. | 26 # leave the attribute unspecified. |
27 testedwith = 'ships-with-hg-core' | 27 testedwith = b'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', [], _('revision to check'), _('REV'))] | 31 commitopts3 = [(b'r', b'rev', [], _(b'revision to check'), _(b'REV'))] |
32 | 32 |
33 | 33 |
34 @command( | 34 @command( |
35 'close-head|close-heads', | 35 b'close-head|close-heads', |
36 commitopts + commitopts2 + commitopts3, | 36 commitopts + commitopts2 + commitopts3, |
37 _('[OPTION]... [REV]...'), | 37 _(b'[OPTION]... [REV]...'), |
38 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, | 38 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, |
39 inferrepo=True, | 39 inferrepo=True, |
40 ) | 40 ) |
41 def close_branch(ui, repo, *revs, **opts): | 41 def close_branch(ui, repo, *revs, **opts): |
42 """close the given head revisions | 42 """close the given head revisions |
53 repo, | 53 repo, |
54 parents=[rev, None], | 54 parents=[rev, None], |
55 text=message, | 55 text=message, |
56 files=[], | 56 files=[], |
57 filectxfn=None, | 57 filectxfn=None, |
58 user=opts.get('user'), | 58 user=opts.get(b'user'), |
59 date=opts.get('date'), | 59 date=opts.get(b'date'), |
60 extra=extra, | 60 extra=extra, |
61 ) | 61 ) |
62 tr = repo.transaction('commit') | 62 tr = repo.transaction(b'commit') |
63 ret = repo.commitctx(cctx, True) | 63 ret = repo.commitctx(cctx, True) |
64 bookmarks.update(repo, [rev, None], ret) | 64 bookmarks.update(repo, [rev, None], ret) |
65 cctx.markcommitted(ret) | 65 cctx.markcommitted(ret) |
66 tr.close() | 66 tr.close() |
67 | 67 |
68 opts = pycompat.byteskwargs(opts) | 68 opts = pycompat.byteskwargs(opts) |
69 | 69 |
70 revs += tuple(opts.get('rev', [])) | 70 revs += tuple(opts.get(b'rev', [])) |
71 revs = scmutil.revrange(repo, revs) | 71 revs = scmutil.revrange(repo, revs) |
72 | 72 |
73 if not revs: | 73 if not revs: |
74 raise error.Abort(_('no revisions specified')) | 74 raise error.Abort(_(b'no revisions specified')) |
75 | 75 |
76 heads = [] | 76 heads = [] |
77 for branch in repo.branchmap(): | 77 for branch in repo.branchmap(): |
78 heads.extend(repo.branchheads(branch)) | 78 heads.extend(repo.branchheads(branch)) |
79 heads = set(repo[h].rev() for h in heads) | 79 heads = set(repo[h].rev() for h in heads) |
80 for rev in revs: | 80 for rev in revs: |
81 if rev not in heads: | 81 if rev not in heads: |
82 raise error.Abort(_('revision is not an open head: %d') % rev) | 82 raise error.Abort(_(b'revision is not an open head: %d') % rev) |
83 | 83 |
84 message = cmdutil.logmessage(ui, opts) | 84 message = cmdutil.logmessage(ui, opts) |
85 if not message: | 85 if not message: |
86 raise error.Abort(_("no commit message specified with -l or -m")) | 86 raise error.Abort(_(b"no commit message specified with -l or -m")) |
87 extra = {'close': '1'} | 87 extra = {b'close': b'1'} |
88 | 88 |
89 with repo.wlock(), repo.lock(): | 89 with repo.wlock(), repo.lock(): |
90 for rev in revs: | 90 for rev in revs: |
91 r = repo[rev] | 91 r = repo[rev] |
92 branch = r.branch() | 92 branch = r.branch() |
93 extra['branch'] = branch | 93 extra[b'branch'] = branch |
94 docommit(r) | 94 docommit(r) |
95 return 0 | 95 return 0 |