Mercurial > hg-stable
annotate hgext/histedit.py @ 48214:9006eafa0942
chistedit: move layout() and dependencies onto state class
Differential Revision: https://phab.mercurial-scm.org/D11638
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 11 Oct 2021 23:02:49 -0700 |
parents | 8ac61257c807 |
children | 8dd2422b0109 |
rev | line source |
---|---|
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1 # histedit.py - interactive history editing for mercurial |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2 # |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
3 # Copyright 2009 Augie Fackler <raf@durin42.com> |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
4 # |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
7 """interactive history editing |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
8 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
9 With this extension installed, Mercurial gains one new command: histedit. Usage |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
10 is as follows, assuming the following history:: |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
11 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
12 @ 3[tip] 7c2fd3b9020c 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
13 | Add delta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
14 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
15 o 2 030b686bedc4 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
16 | Add gamma |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
17 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
18 o 1 c561b4e977df 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
19 | Add beta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
20 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
21 o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
22 Add alpha |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
23 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
24 If you were to run ``hg histedit c561b4e977df``, you would see the following |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
25 file open in your editor:: |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
26 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
27 pick c561b4e977df Add beta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
28 pick 030b686bedc4 Add gamma |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
29 pick 7c2fd3b9020c Add delta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
30 |
18322
e819c12a8bd0
histedit: correct changeset IDs in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17771
diff
changeset
|
31 # Edit history between c561b4e977df and 7c2fd3b9020c |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
32 # |
20503
23dc77874191
histedit: clarify description of fold command
Adrian Zgorzałek <adek@fb.com>
parents:
20071
diff
changeset
|
33 # Commits are listed from least to most recent |
23dc77874191
histedit: clarify description of fold command
Adrian Zgorzałek <adek@fb.com>
parents:
20071
diff
changeset
|
34 # |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
35 # Commands: |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
36 # p, pick = use commit |
46105
6f8a94bbfba1
histedit: adjust comment describing `edit` action for clarity
Augie Fackler <augie@google.com>
parents:
46104
diff
changeset
|
37 # e, edit = use commit, but allow edits before making new commit |
20511
5840da876235
histedit: shorten new fold message
Matt Mackall <mpm@selenic.com>
parents:
20503
diff
changeset
|
38 # f, fold = use commit, but combine it with the one above |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
39 # r, roll = like fold, but discard this commit's description and date |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
40 # d, drop = remove commit from history |
26100
5706d130ec16
histedit: improve discoverability of edit commit message
timeless@mozdev.org
parents:
26098
diff
changeset
|
41 # m, mess = edit commit message without changing commit content |
34489
270e344a6c74
histedit: removing the experimental config 'histeditng'
Saurabh Singh <singhsrb@fb.com>
parents:
34476
diff
changeset
|
42 # b, base = checkout changeset and apply further changesets from there |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
43 # |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
44 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
45 In this file, lines beginning with ``#`` are ignored. You must specify a rule |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
46 for each revision in your history. For example, if you had meant to add gamma |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
47 before beta, and then wanted to add delta in the same revision as beta, you |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
48 would reorganize the file to look like this:: |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
49 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
50 pick 030b686bedc4 Add gamma |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
51 pick c561b4e977df Add beta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
52 fold 7c2fd3b9020c Add delta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
53 |
18322
e819c12a8bd0
histedit: correct changeset IDs in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17771
diff
changeset
|
54 # Edit history between c561b4e977df and 7c2fd3b9020c |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
55 # |
20503
23dc77874191
histedit: clarify description of fold command
Adrian Zgorzałek <adek@fb.com>
parents:
20071
diff
changeset
|
56 # Commits are listed from least to most recent |
23dc77874191
histedit: clarify description of fold command
Adrian Zgorzałek <adek@fb.com>
parents:
20071
diff
changeset
|
57 # |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
58 # Commands: |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
59 # p, pick = use commit |
46105
6f8a94bbfba1
histedit: adjust comment describing `edit` action for clarity
Augie Fackler <augie@google.com>
parents:
46104
diff
changeset
|
60 # e, edit = use commit, but allow edits before making new commit |
20511
5840da876235
histedit: shorten new fold message
Matt Mackall <mpm@selenic.com>
parents:
20503
diff
changeset
|
61 # f, fold = use commit, but combine it with the one above |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
62 # r, roll = like fold, but discard this commit's description and date |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
63 # d, drop = remove commit from history |
26100
5706d130ec16
histedit: improve discoverability of edit commit message
timeless@mozdev.org
parents:
26098
diff
changeset
|
64 # m, mess = edit commit message without changing commit content |
34489
270e344a6c74
histedit: removing the experimental config 'histeditng'
Saurabh Singh <singhsrb@fb.com>
parents:
34476
diff
changeset
|
65 # b, base = checkout changeset and apply further changesets from there |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
66 # |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
67 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
68 At which point you close the editor and ``histedit`` starts working. When you |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
69 specify a ``fold`` operation, ``histedit`` will open an editor when it folds |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
70 those revisions together, offering you a chance to clean up the commit message:: |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
71 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
72 Add beta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
73 *** |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
74 Add delta |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
75 |
31075
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
76 Edit the commit message to your liking, then close the editor. The date used |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
77 for the commit will be the later of the two commits' dates. For this example, |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
78 let's assume that the commit message was changed to ``Add beta and delta.`` |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
79 After histedit has run and had a chance to remove any old or temporary |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
80 revisions it needed, the history looks like this:: |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
81 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
82 @ 2[tip] 989b4d060121 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
83 | Add beta and delta. |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
84 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
85 o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
86 | Add gamma |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
87 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
88 o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
89 Add alpha |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
90 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
91 Note that ``histedit`` does *not* remove any revisions (even its own temporary |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
92 ones) until after it has completed all the editing operations, so it will |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
93 probably perform several strip operations when it's done. For the above example, |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
94 it had to run strip twice. Strip can be slow depending on a variety of factors, |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
95 so you might need to be a little patient. You can choose to keep the original |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
96 revisions by passing the ``--keep`` flag. |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
97 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
98 The ``edit`` operation will drop you back to a command prompt, |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
99 allowing you to edit files freely, or even use ``hg record`` to commit |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
100 some changes as a separate commit. When you're done, any remaining |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
101 uncommitted changes will be committed as well. When done, run ``hg |
31075
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
102 histedit --continue`` to finish this step. If there are uncommitted |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
103 changes, you'll be prompted for a new commit message, but the default |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
104 commit message will be the original message for the ``edit`` ed |
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
105 revision, and the date of the original commit will be preserved. |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
106 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
107 The ``message`` operation will give you a chance to revise a commit |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
108 message without changing the contents. It's a shortcut for doing |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
109 ``edit`` immediately followed by `hg histedit --continue``. |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
110 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
111 If ``histedit`` encounters a conflict when moving a revision (while |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
112 handling ``pick`` or ``fold``), it'll stop in a similar manner to |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
113 ``edit`` with the difference that it won't prompt you for a commit |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
114 message when done. If you decide at this point that you don't like how |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
115 much work it will be to rearrange history, or that you made a mistake, |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
116 you can use ``hg histedit --abort`` to abandon the new changes you |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
117 have made and return to the state before you attempted to edit your |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
118 history. |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
119 |
18323
7648b87e76db
histedit: correct the number of added revisions in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18322
diff
changeset
|
120 If we clone the histedit-ed example repository above and add four more |
7648b87e76db
histedit: correct the number of added revisions in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18322
diff
changeset
|
121 changes, such that we have the following history:: |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
122 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
123 @ 6[tip] 038383181893 2009-04-27 18:04 -0500 stefan |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
124 | Add theta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
125 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
126 o 5 140988835471 2009-04-27 18:04 -0500 stefan |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
127 | Add eta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
128 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
129 o 4 122930637314 2009-04-27 18:04 -0500 stefan |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
130 | Add zeta |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
131 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
132 o 3 836302820282 2009-04-27 18:04 -0500 stefan |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
133 | Add epsilon |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
134 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
135 o 2 989b4d060121 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
136 | Add beta and delta. |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
137 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
138 o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
139 | Add gamma |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
140 | |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
141 o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
142 Add alpha |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
143 |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
144 If you run ``hg histedit --outgoing`` on the clone then it is the same |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
145 as running ``hg histedit 836302820282``. If you need plan to push to a |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
146 repository that Mercurial does not detect to be related to the source |
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
147 repo, you can add a ``--force`` option. |
24199
4047982904f8
histedit: add a config allowing changing histedit rule line length limit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24196
diff
changeset
|
148 |
27414
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
149 Config |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
150 ------ |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
151 |
24199
4047982904f8
histedit: add a config allowing changing histedit rule line length limit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24196
diff
changeset
|
152 Histedit rule lines are truncated to 80 characters by default. You |
26171 | 153 can customize this behavior by setting a different length in your |
24869
95a67d687903
histedit: fix reST syntax problem of example code in help document
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24831
diff
changeset
|
154 configuration file:: |
24199
4047982904f8
histedit: add a config allowing changing histedit rule line length limit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24196
diff
changeset
|
155 |
24869
95a67d687903
histedit: fix reST syntax problem of example code in help document
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24831
diff
changeset
|
156 [histedit] |
95a67d687903
histedit: fix reST syntax problem of example code in help document
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24831
diff
changeset
|
157 linelen = 120 # truncate rule lines at 120 characters |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
158 |
41523
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
159 The summary of a change can be customized as well:: |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
160 |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
161 [histedit] |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
162 summary-template = '{rev} {bookmarks} {desc|firstline}' |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
163 |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
164 The customized summary should be kept short enough that rule lines |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
165 will fit in the configured line length. See above if that requires |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
166 customization. |
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
167 |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
168 ``hg histedit`` attempts to automatically choose an appropriate base |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
169 revision to use. To change which base revision is used, define a |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
170 revset in your configuration file:: |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
171 |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
172 [histedit] |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
173 defaultrev = only(.) & draft() |
27414
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
174 |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
175 By default each edited revision needs to be present in histedit commands. |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
176 To remove revision you need to use ``drop`` operation. You can configure |
27957
c54f017fcd52
doc: prevent literal text block from being treated as non-literal one
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27956
diff
changeset
|
177 the drop to be implicit for missing commits by adding:: |
27414
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
178 |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
179 [histedit] |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
180 dropmissing = True |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
181 |
31520
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
182 By default, histedit will close the transaction after each action. For |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
183 performance purposes, you can configure histedit to use a single transaction |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
184 across the entire histedit. WARNING: This setting introduces a significant risk |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
185 of losing the work you've done in a histedit if the histedit aborts |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
186 unexpectedly:: |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
187 |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
188 [histedit] |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
189 singletransaction = True |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
190 |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
191 """ |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
192 |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
193 from __future__ import absolute_import |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
194 |
40695
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
195 # chistedit dependencies that are not available everywhere |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
196 try: |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
197 import fcntl |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
198 import termios |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
199 except ImportError: |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
200 fcntl = None |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
201 termios = None |
291080871f50
histedit: conditionalize the imports of 'fcntl' and 'termios'
Matt Harbison <matt_harbison@yahoo.com>
parents:
40649
diff
changeset
|
202 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
203 import functools |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
204 import os |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
205 import struct |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
29126
diff
changeset
|
206 |
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
29126
diff
changeset
|
207 from mercurial.i18n import _ |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
208 from mercurial.pycompat import ( |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
209 getattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
210 open, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
211 ) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
212 from mercurial.node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
213 bin, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
214 hex, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
215 short, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
216 ) |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
217 from mercurial import ( |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
218 bundle2, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
219 cmdutil, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
220 context, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
221 copies, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
222 destutil, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
223 discovery, |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
224 encoding, |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
225 error, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
226 exchange, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
227 extensions, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
228 hg, |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
229 logcmdutil, |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
230 merge as mergemod, |
44915
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44663
diff
changeset
|
231 mergestate as mergestatemod, |
32057
e5ffc91a2276
histedit: make check for unresolved conflicts explicit (issue5545)
Siddharth Agarwal <sid0@fb.com>
parents:
31643
diff
changeset
|
232 mergeutil, |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
233 obsolete, |
35040
c4b769bc86da
py3: handle keyword arguments in hgext/histedit.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34917
diff
changeset
|
234 pycompat, |
32376
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32366
diff
changeset
|
235 registrar, |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
236 repair, |
43939
bde97bee321f
histedit: use rewriteutil.precheck() instead of reimplementing it
Martin von Zweigbergk <martinvonz@google.com>
parents:
43811
diff
changeset
|
237 rewriteutil, |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
238 scmutil, |
38510
18f348e035fb
histedit: add a stateobj variable to histeditstate class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38509
diff
changeset
|
239 state as statemod, |
29126
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
240 util, |
7dd5d19c9773
py3: make hgext/hisedit.py use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28592
diff
changeset
|
241 ) |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
242 from mercurial.utils import ( |
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
41212
diff
changeset
|
243 dateutil, |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
244 stringutil, |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46468
diff
changeset
|
245 urlutil, |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
246 ) |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
247 |
29324
b501579147f1
py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29214
diff
changeset
|
248 pickle = util.pickle |
17147
80e861511e2b
histedit: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
17131
diff
changeset
|
249 cmdtable = {} |
32376
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32366
diff
changeset
|
250 command = registrar.command(cmdtable) |
17147
80e861511e2b
histedit: use cmdutil.command decorator
Adrian Buehlmann <adrian@cadifra.com>
parents:
17131
diff
changeset
|
251 |
34471
6567002ae87e
configitems: register the 'histedit.defaultrev' config
Boris Feld <boris.feld@octobus.net>
parents:
34046
diff
changeset
|
252 configtable = {} |
6567002ae87e
configitems: register the 'histedit.defaultrev' config
Boris Feld <boris.feld@octobus.net>
parents:
34046
diff
changeset
|
253 configitem = registrar.configitem(configtable) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
254 configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
255 b'experimental', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
256 b'histedit.autoverb', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
257 default=False, |
34475
b068a87e951d
configitems: register the 'experimental.histedit.autoverb' config
Boris Feld <boris.feld@octobus.net>
parents:
34474
diff
changeset
|
258 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
259 configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
260 b'histedit', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
261 b'defaultrev', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
262 default=None, |
34471
6567002ae87e
configitems: register the 'histedit.defaultrev' config
Boris Feld <boris.feld@octobus.net>
parents:
34046
diff
changeset
|
263 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
264 configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
265 b'histedit', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
266 b'dropmissing', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
267 default=False, |
34472
1e37cb4da6f8
configitems: register the 'histedit.dropmissing' config
Boris Feld <boris.feld@octobus.net>
parents:
34471
diff
changeset
|
268 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
269 configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
270 b'histedit', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
271 b'linelen', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
272 default=80, |
34474
a746472c3d09
configitems: register the 'histedit.singletransaction' config
Boris Feld <boris.feld@octobus.net>
parents:
34473
diff
changeset
|
273 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
274 configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
275 b'histedit', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
276 b'singletransaction', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
277 default=False, |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
278 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
279 configitem( |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
280 b'ui', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
281 b'interface.histedit', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
282 default=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
283 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
284 configitem(b'histedit', b'summary-template', default=b'{rev} {desc|firstline}') |
34471
6567002ae87e
configitems: register the 'histedit.defaultrev' config
Boris Feld <boris.feld@octobus.net>
parents:
34046
diff
changeset
|
285 |
29852
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29831
diff
changeset
|
286 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
25149
diff
changeset
|
287 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
25149
diff
changeset
|
288 # be specifying the version(s) of Mercurial they are tested with, or |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
25149
diff
changeset
|
289 # leave the attribute unspecified. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
290 testedwith = b'ships-with-hg-core' |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
291 |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
292 actiontable = {} |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
293 primaryactions = set() |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
294 secondaryactions = set() |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
295 tertiaryactions = set() |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
296 internalactions = set() |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
297 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
298 |
28592
cdbd9c0c0775
histedit: add a hint about enabled dropmissing to histedit edit comment
Mateusz Kwapich <mitrandir@fb.com>
parents:
28550
diff
changeset
|
299 def geteditcomment(ui, first, last): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
300 """construct the editor comment |
27673
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
301 The comment includes:: |
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
302 - an intro |
27674
78d86664e3a2
histedit: prefer edit commit, edit message, use commit
timeless <timeless@mozdev.org>
parents:
27673
diff
changeset
|
303 - sorted primary commands |
78d86664e3a2
histedit: prefer edit commit, edit message, use commit
timeless <timeless@mozdev.org>
parents:
27673
diff
changeset
|
304 - sorted short commands |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
305 - sorted long commands |
28592
cdbd9c0c0775
histedit: add a hint about enabled dropmissing to histedit edit comment
Mateusz Kwapich <mitrandir@fb.com>
parents:
28550
diff
changeset
|
306 - additional hints |
27673
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
307 |
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
308 Commands are only included once. |
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
309 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
310 intro = _( |
44216
8fca7e8449a8
histedit: add missing b prefix to a string
Kyle Lippincott <spectral@google.com>
parents:
44197
diff
changeset
|
311 b"""Edit history between %s and %s |
27673
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
312 |
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
313 Commits are listed from least to most recent |
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
314 |
28396
5490b04e6132
histedit: adds hint how to reorder changesets at editor (issue3766)
liscju <piotr.listkiewicz@gmail.com>
parents:
28340
diff
changeset
|
315 You can reorder changesets by reordering the lines |
5490b04e6132
histedit: adds hint how to reorder changesets at editor (issue3766)
liscju <piotr.listkiewicz@gmail.com>
parents:
28340
diff
changeset
|
316 |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
317 Commands: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
318 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
319 ) |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
320 actions = [] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
321 |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
322 def addverb(v): |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
323 a = actiontable[v] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
324 lines = a.message.split(b"\n") |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
325 if len(a.verbs): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
326 v = b', '.join(sorted(a.verbs, key=lambda v: len(v))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
327 actions.append(b" %s = %s" % (v, lines[0])) |
44000
801b8d314791
histedit: avoid using a list comprehension to fill a list with fixed values
Matt Harbison <matt_harbison@yahoo.com>
parents:
43939
diff
changeset
|
328 actions.extend([b' %s'] * (len(lines) - 1)) |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
329 |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
330 for v in ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
331 sorted(primaryactions) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
332 + sorted(secondaryactions) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
333 + sorted(tertiaryactions) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
334 ): |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
335 addverb(v) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
336 actions.append(b'') |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
337 |
28592
cdbd9c0c0775
histedit: add a hint about enabled dropmissing to histedit edit comment
Mateusz Kwapich <mitrandir@fb.com>
parents:
28550
diff
changeset
|
338 hints = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
339 if ui.configbool(b'histedit', b'dropmissing'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
340 hints.append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 b"Deleting a changeset from the list " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
342 b"will DISCARD it from the edited history!" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
343 ) |
28592
cdbd9c0c0775
histedit: add a hint about enabled dropmissing to histedit edit comment
Mateusz Kwapich <mitrandir@fb.com>
parents:
28550
diff
changeset
|
344 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
345 lines = (intro % (first, last)).split(b'\n') + actions + hints |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
346 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
347 return b''.join([b'# %s\n' % l if l else b'#\n' for l in lines]) |
27673
d93d340dc6ee
histedit: replace editcomment with a function
timeless <timeless@mozdev.org>
parents:
27630
diff
changeset
|
348 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
349 |
22976
886711722db6
histedit: add histedit state class
David Soria Parra <davidsp@fb.com>
parents:
22952
diff
changeset
|
350 class histeditstate(object): |
41165
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
351 def __init__(self, repo): |
22976
886711722db6
histedit: add histedit state class
David Soria Parra <davidsp@fb.com>
parents:
22952
diff
changeset
|
352 self.repo = repo |
41165
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
353 self.actions = None |
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
354 self.keep = None |
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
355 self.topmost = None |
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
356 self.parentctxnode = None |
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
357 self.lock = None |
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
358 self.wlock = None |
24757
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
359 self.backupfile = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
360 self.stateobj = statemod.cmdstate(repo, b'histedit-state') |
41165
a3a24ad10efb
histedit: drop unused constructor arguments (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41151
diff
changeset
|
361 self.replacements = [] |
22976
886711722db6
histedit: add histedit state class
David Soria Parra <davidsp@fb.com>
parents:
22952
diff
changeset
|
362 |
22983
a3a981563ce8
histedit: read state from histeditstate
David Soria Parra <davidsp@fb.com>
parents:
22982
diff
changeset
|
363 def read(self): |
22986
7b93b49286d0
histedit: update docstring on histeditstate.read()
Augie Fackler <raf@durin42.com>
parents:
22985
diff
changeset
|
364 """Load histedit state from disk and set fields appropriately.""" |
38511
03e7ec8180f0
histedit: use self.stateobj to check whether interrupted histedit exists
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38510
diff
changeset
|
365 if not self.stateobj.exists(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
366 cmdutil.wrongtooltocontinue(self.repo, _(b'histedit')) |
22983
a3a981563ce8
histedit: read state from histeditstate
David Soria Parra <davidsp@fb.com>
parents:
22982
diff
changeset
|
367 |
38511
03e7ec8180f0
histedit: use self.stateobj to check whether interrupted histedit exists
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38510
diff
changeset
|
368 data = self._read() |
38509
c6a2ce82e60b
histedit: factor out logic of processing state data in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38508
diff
changeset
|
369 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
370 self.parentctxnode = data[b'parentctxnode'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
371 actions = parserules(data[b'rules'], self) |
38509
c6a2ce82e60b
histedit: factor out logic of processing state data in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38508
diff
changeset
|
372 self.actions = actions |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
373 self.keep = data[b'keep'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
374 self.topmost = data[b'topmost'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
375 self.replacements = data[b'replacements'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
376 self.backupfile = data[b'backupfile'] |
38509
c6a2ce82e60b
histedit: factor out logic of processing state data in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38508
diff
changeset
|
377 |
38511
03e7ec8180f0
histedit: use self.stateobj to check whether interrupted histedit exists
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38510
diff
changeset
|
378 def _read(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
379 fp = self.repo.vfs.read(b'histedit-state') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
380 if fp.startswith(b'v1\n'): |
27527
dbfaf361c062
histedit: only use pickle if not using the modern save format
Bryan O'Sullivan <bos@serpentine.com>
parents:
27451
diff
changeset
|
381 data = self._load() |
dbfaf361c062
histedit: only use pickle if not using the modern save format
Bryan O'Sullivan <bos@serpentine.com>
parents:
27451
diff
changeset
|
382 parentctxnode, rules, keep, topmost, replacements, backupfile = data |
dbfaf361c062
histedit: only use pickle if not using the modern save format
Bryan O'Sullivan <bos@serpentine.com>
parents:
27451
diff
changeset
|
383 else: |
38509
c6a2ce82e60b
histedit: factor out logic of processing state data in separate fn
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38508
diff
changeset
|
384 data = pickle.loads(fp) |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
385 parentctxnode, rules, keep, topmost, replacements = data |
24757
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
386 backupfile = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
387 rules = b"\n".join([b"%s %s" % (verb, rest) for [verb, rest] in rules]) |
22983
a3a981563ce8
histedit: read state from histeditstate
David Soria Parra <davidsp@fb.com>
parents:
22982
diff
changeset
|
388 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
389 return { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
390 b'parentctxnode': parentctxnode, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
391 b"rules": rules, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 b"keep": keep, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
393 b"topmost": topmost, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
394 b"replacements": replacements, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
395 b"backupfile": backupfile, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
396 } |
22983
a3a981563ce8
histedit: read state from histeditstate
David Soria Parra <davidsp@fb.com>
parents:
22982
diff
changeset
|
397 |
31518
fa8aaff2001a
histedit: add transaction support to writing the state file
Durham Goode <durham@fb.com>
parents:
31468
diff
changeset
|
398 def write(self, tr=None): |
fa8aaff2001a
histedit: add transaction support to writing the state file
Durham Goode <durham@fb.com>
parents:
31468
diff
changeset
|
399 if tr: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
400 tr.addfilegenerator( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
401 b'histedit-state', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
402 (b'histedit-state',), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
403 self._write, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
404 location=b'plain', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
405 ) |
31518
fa8aaff2001a
histedit: add transaction support to writing the state file
Durham Goode <durham@fb.com>
parents:
31468
diff
changeset
|
406 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
407 with self.repo.vfs(b"histedit-state", b"w") as f: |
31518
fa8aaff2001a
histedit: add transaction support to writing the state file
Durham Goode <durham@fb.com>
parents:
31468
diff
changeset
|
408 self._write(f) |
fa8aaff2001a
histedit: add transaction support to writing the state file
Durham Goode <durham@fb.com>
parents:
31468
diff
changeset
|
409 |
fa8aaff2001a
histedit: add transaction support to writing the state file
Durham Goode <durham@fb.com>
parents:
31468
diff
changeset
|
410 def _write(self, fp): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
411 fp.write(b'v1\n') |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
412 fp.write(b'%s\n' % hex(self.parentctxnode)) |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
413 fp.write(b'%s\n' % hex(self.topmost)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
414 fp.write(b'%s\n' % (b'True' if self.keep else b'False')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 fp.write(b'%d\n' % len(self.actions)) |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
416 for action in self.actions: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 fp.write(b'%s\n' % action.tostate()) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 fp.write(b'%d\n' % len(self.replacements)) |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
419 for replacement in self.replacements: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
420 fp.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
421 b'%s%s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
422 % ( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
423 hex(replacement[0]), |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
424 b''.join(hex(r) for r in replacement[1]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
425 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
426 ) |
24958
a920abf5a592
histedit: fix serializing of None backupfile
Durham Goode <durham@fb.com>
parents:
24920
diff
changeset
|
427 backupfile = self.backupfile |
a920abf5a592
histedit: fix serializing of None backupfile
Durham Goode <durham@fb.com>
parents:
24920
diff
changeset
|
428 if not backupfile: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
429 backupfile = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
430 fp.write(b'%s\n' % backupfile) |
22976
886711722db6
histedit: add histedit state class
David Soria Parra <davidsp@fb.com>
parents:
22952
diff
changeset
|
431 |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
432 def _load(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 fp = self.repo.vfs(b'histedit-state', b'r') |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
434 lines = [l[:-1] for l in fp.readlines()] |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
435 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
436 index = 0 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
437 lines[index] # version number |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
438 index += 1 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
439 |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
440 parentctxnode = bin(lines[index]) |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
441 index += 1 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
442 |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
443 topmost = bin(lines[index]) |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
444 index += 1 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
445 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
446 keep = lines[index] == b'True' |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
447 index += 1 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
448 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
449 # Rules |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
450 rules = [] |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
451 rulelen = int(lines[index]) |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
452 index += 1 |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38738
diff
changeset
|
453 for i in pycompat.xrange(rulelen): |
24810
f5416657e661
histedit: change state format to allow non-hash lines
Durham Goode <durham@fb.com>
parents:
24774
diff
changeset
|
454 ruleaction = lines[index] |
f5416657e661
histedit: change state format to allow non-hash lines
Durham Goode <durham@fb.com>
parents:
24774
diff
changeset
|
455 index += 1 |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
456 rule = lines[index] |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
457 index += 1 |
24810
f5416657e661
histedit: change state format to allow non-hash lines
Durham Goode <durham@fb.com>
parents:
24774
diff
changeset
|
458 rules.append((ruleaction, rule)) |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
459 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
460 # Replacements |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
461 replacements = [] |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
462 replacementlen = int(lines[index]) |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
463 index += 1 |
38823
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38738
diff
changeset
|
464 for i in pycompat.xrange(replacementlen): |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
465 replacement = lines[index] |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
466 original = bin(replacement[:40]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
467 succ = [ |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
468 bin(replacement[i : i + 40]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
469 for i in range(40, len(replacement), 40) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
470 ] |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
471 replacements.append((original, succ)) |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
472 index += 1 |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
473 |
24757
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
474 backupfile = lines[index] |
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
475 index += 1 |
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
476 |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
477 fp.close() |
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
478 |
24757
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
479 return parentctxnode, rules, keep, topmost, replacements, backupfile |
24756
d71c2da01d0d
histedit: replace pickle with custom serialization
Durham Goode <durham@fb.com>
parents:
24626
diff
changeset
|
480 |
22978
d4e764521249
histedit: add clear method to remove state
David Soria Parra <davidsp@fb.com>
parents:
22977
diff
changeset
|
481 def clear(self): |
26583
49b568a4e539
histedit: check presence of statefile before deleting it
Christian Delahousse <cdelahousse@fb.com>
parents:
26582
diff
changeset
|
482 if self.inprogress(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
483 self.repo.vfs.unlink(b'histedit-state') |
22978
d4e764521249
histedit: add clear method to remove state
David Soria Parra <davidsp@fb.com>
parents:
22977
diff
changeset
|
484 |
26582
42b908673866
histedit: add inprogress method to state class
Christian Delahousse <cdelahousse@fb.com>
parents:
26335
diff
changeset
|
485 def inprogress(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
486 return self.repo.vfs.exists(b'histedit-state') |
26582
42b908673866
histedit: add inprogress method to state class
Christian Delahousse <cdelahousse@fb.com>
parents:
26335
diff
changeset
|
487 |
27200
62b9a87a365e
histedit: add actions property to histedit state
Mateusz Kwapich <mitrandir@fb.com>
parents:
27171
diff
changeset
|
488 |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
489 class histeditaction(object): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
490 def __init__(self, state, node): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
491 self.state = state |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
492 self.repo = state.repo |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
493 self.node = node |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
494 |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
495 @classmethod |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
496 def fromrule(cls, state, rule): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
497 """Parses the given rule, returning an instance of the histeditaction.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
498 ruleid = rule.strip().split(b' ', 1)[0] |
37109
3d3cff1f6bde
histedit: make histedit's commands accept revsets (issue5746)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents:
37087
diff
changeset
|
499 # ruleid can be anything from rev numbers, hashes, "bookmarks" etc |
3d3cff1f6bde
histedit: make histedit's commands accept revsets (issue5746)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents:
37087
diff
changeset
|
500 # Check for validation of rule ids and get the rulehash |
27547
1cbfeb1dc5aa
histedit: handle exceptions from node.bin in fromrule
timeless <timeless@mozdev.org>
parents:
27546
diff
changeset
|
501 try: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
502 rev = bin(ruleid) |
36275
f574cc00831a
node: make bin() be a wrapper instead of just an alias
Augie Fackler <augie@google.com>
parents:
36213
diff
changeset
|
503 except TypeError: |
37109
3d3cff1f6bde
histedit: make histedit's commands accept revsets (issue5746)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents:
37087
diff
changeset
|
504 try: |
3d3cff1f6bde
histedit: make histedit's commands accept revsets (issue5746)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents:
37087
diff
changeset
|
505 _ctx = scmutil.revsingle(state.repo, ruleid) |
3d3cff1f6bde
histedit: make histedit's commands accept revsets (issue5746)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents:
37087
diff
changeset
|
506 rulehash = _ctx.hex() |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
507 rev = bin(rulehash) |
37109
3d3cff1f6bde
histedit: make histedit's commands accept revsets (issue5746)
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com>
parents:
37087
diff
changeset
|
508 except error.RepoLookupError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
509 raise error.ParseError(_(b"invalid changeset %s") % ruleid) |
27547
1cbfeb1dc5aa
histedit: handle exceptions from node.bin in fromrule
timeless <timeless@mozdev.org>
parents:
27546
diff
changeset
|
510 return cls(state, rev) |
27202
2226cd4f32ed
histedit: add verify() to histeditaction
Mateusz Kwapich <mitrandir@fb.com>
parents:
27201
diff
changeset
|
511 |
29883
b566c5992e07
histedit: move constraint verification to the 'action.verify' method
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29882
diff
changeset
|
512 def verify(self, prev, expected, seen): |
47031
f38bf44e077f
black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents:
46941
diff
changeset
|
513 """Verifies semantic correctness of the rule""" |
27202
2226cd4f32ed
histedit: add verify() to histeditaction
Mateusz Kwapich <mitrandir@fb.com>
parents:
27201
diff
changeset
|
514 repo = self.repo |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
515 ha = hex(self.node) |
37678
5f8f013e7d52
scmutil: rename resolvepartialhexnodeid() to resolvehexnodeidprefix()
Martin von Zweigbergk <martinvonz@google.com>
parents:
37506
diff
changeset
|
516 self.node = scmutil.resolvehexnodeidprefix(repo, ha) |
37506
c4131138eadb
histedit: look up partial nodeid as partial nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37505
diff
changeset
|
517 if self.node is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
518 raise error.ParseError(_(b'unknown changeset %s listed') % ha[:12]) |
37505
966061b8826d
histedit: drop unnecessary check for "self.node is not None"
Martin von Zweigbergk <martinvonz@google.com>
parents:
37314
diff
changeset
|
519 self._verifynodeconstraints(prev, expected, seen) |
29883
b566c5992e07
histedit: move constraint verification to the 'action.verify' method
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29882
diff
changeset
|
520 |
29884
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
521 def _verifynodeconstraints(self, prev, expected, seen): |
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
522 # by default command need a node in the edited list |
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
523 if self.node not in expected: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
524 raise error.ParseError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
525 _(b'%s "%s" changeset was not a candidate') |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
526 % (self.verb, short(self.node)), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
527 hint=_(b'only use listed changesets'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
528 ) |
29884
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
529 # and only one command per node |
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
530 if self.node in seen: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
531 raise error.ParseError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
532 _(b'duplicated command for changeset %s') % short(self.node) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
533 ) |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
534 |
29466
a0efbfbba7b5
histedit: remove unneeded initial parameter
Sean Farley <sean@farley.io>
parents:
29465
diff
changeset
|
535 def torule(self): |
27203
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
536 """build a histedit rule line for an action |
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
537 |
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
538 by default lines are in the form: |
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
539 <hash> <rev> <summary> |
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
540 """ |
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
541 ctx = self.repo[self.node] |
41523
11c076786d56
histedit: add templating support to histedit's rule file generation
Augie Fackler <augie@google.com>
parents:
41421
diff
changeset
|
542 ui = self.repo.ui |
45873
62983988bbf5
histedit: disable color while rendering template for use in plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45872
diff
changeset
|
543 # We don't want color codes in the commit message template, so |
62983988bbf5
histedit: disable color while rendering template for use in plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45872
diff
changeset
|
544 # disable the label() template function while we render it. |
62983988bbf5
histedit: disable color while rendering template for use in plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45872
diff
changeset
|
545 with ui.configoverride( |
62983988bbf5
histedit: disable color while rendering template for use in plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45872
diff
changeset
|
546 {(b'templatealias', b'label(l,x)'): b"x"}, b'histedit' |
62983988bbf5
histedit: disable color while rendering template for use in plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45872
diff
changeset
|
547 ): |
45872
ec6ba70be853
tests: show how `hg histedit` can put color codes in histedit plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45814
diff
changeset
|
548 summary = cmdutil.rendertemplate( |
ec6ba70be853
tests: show how `hg histedit` can put color codes in histedit plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45814
diff
changeset
|
549 ctx, ui.config(b'histedit', b'summary-template') |
ec6ba70be853
tests: show how `hg histedit` can put color codes in histedit plan
Martin von Zweigbergk <martinvonz@google.com>
parents:
45814
diff
changeset
|
550 ) |
45908
f4065c3f09b8
histedit: don't crash if commit message is empty
Martin von Zweigbergk <martinvonz@google.com>
parents:
45873
diff
changeset
|
551 # Handle the fact that `''.splitlines() => []` |
f4065c3f09b8
histedit: don't crash if commit message is empty
Martin von Zweigbergk <martinvonz@google.com>
parents:
45873
diff
changeset
|
552 summary = summary.splitlines()[0] if summary else b'' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
553 line = b'%s %s %s' % (self.verb, ctx, summary) |
27203
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
554 # trim to 75 columns by default so it's not stupidly wide in my editor |
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
555 # (the 5 more are left for verb) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
556 maxlen = self.repo.ui.configint(b'histedit', b'linelen') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
557 maxlen = max(maxlen, 22) # avoid truncating hash |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
558 return stringutil.ellipsis(line, maxlen) |
27203
b6a0f0895a25
histedit: add torule method to histedit action objects
Mateusz Kwapich <mitrandir@fb.com>
parents:
27202
diff
changeset
|
559 |
27206
7a523b6d5265
histedit: add tostate method to histedit action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27205
diff
changeset
|
560 def tostate(self): |
7a523b6d5265
histedit: add tostate method to histedit action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27205
diff
changeset
|
561 """Print an action in format used by histedit state files |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
562 (the first line is a verb, the remainder is the second) |
27206
7a523b6d5265
histedit: add tostate method to histedit action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27205
diff
changeset
|
563 """ |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
564 return b"%s\n%s" % (self.verb, hex(self.node)) |
27206
7a523b6d5265
histedit: add tostate method to histedit action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27205
diff
changeset
|
565 |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
566 def run(self): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
567 """Runs the action. The default behavior is simply apply the action's |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
568 rulectx onto the current parentctx.""" |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
569 self.applychange() |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
570 self.continuedirty() |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
571 return self.continueclean() |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
572 |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
573 def applychange(self): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
574 """Applies the changes from this action's rulectx onto the current |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
575 parentctx, but does not commit them.""" |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
576 repo = self.repo |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
577 rulectx = repo[self.node] |
47443
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47441
diff
changeset
|
578 with repo.ui.silent(): |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47441
diff
changeset
|
579 hg.update(repo, self.state.parentctxnode, quietempty=True) |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
580 stats = applychanges(repo.ui, repo, rulectx, {}) |
35004
7b73bf1a48d4
histedit: preserve active branch while histediting
Boris Feld <boris.feld@octobus.net>
parents:
34917
diff
changeset
|
581 repo.dirstate.setbranch(rulectx.branch()) |
37128
6f570c501e3e
merge: deprecate accessing update results by index
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37111
diff
changeset
|
582 if stats.unresolvedcount: |
27629
e7ff83b2bcfe
histedit: list action when intervention is required
timeless <timeless@mozdev.org>
parents:
27627
diff
changeset
|
583 raise error.InterventionRequired( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
584 _(b'Fix up the change (%s %s)') % (self.verb, short(self.node)), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
585 hint=_(b'hg histedit --continue to resume'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
586 ) |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
587 |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
588 def continuedirty(self): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
589 """Continues the action when changes have been applied to the working |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
590 copy. The default behavior is to commit the dirty changes.""" |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
591 repo = self.repo |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
592 rulectx = repo[self.node] |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
593 |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
594 editor = self.commiteditor() |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
595 commit = commitfuncfor(repo, rulectx) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
596 if repo.ui.configbool(b'rewrite', b'update-timestamp'): |
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
41212
diff
changeset
|
597 date = dateutil.makedate() |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
41212
diff
changeset
|
598 else: |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
41212
diff
changeset
|
599 date = rulectx.date() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
600 commit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
601 text=rulectx.description(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
602 user=rulectx.user(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
603 date=date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
604 extra=rulectx.extra(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
605 editor=editor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
606 ) |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
607 |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
608 def commiteditor(self): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
609 """The editor to be used to edit the commit message.""" |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
610 return False |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
611 |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
612 def continueclean(self): |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
613 """Continues the action when the working copy is clean. The default |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
614 behavior is to accept the current commit as the new version of the |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
615 rulectx.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
616 ctx = self.repo[b'.'] |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
617 if ctx.node() == self.state.parentctxnode: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
618 self.repo.ui.warn( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
619 _(b'%s: skipping changeset (no changes)\n') % short(self.node) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
620 ) |
24765
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
621 return ctx, [(self.node, tuple())] |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
622 if ctx.node() == self.node: |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
623 # Nothing changed |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
624 return ctx, [] |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
625 return ctx, [(self.node, (ctx.node(),))] |
bdf84cc2115b
histedit: add a new histeditaction class
Durham Goode <durham@fb.com>
parents:
24764
diff
changeset
|
626 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
627 |
18436
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
628 def commitfuncfor(repo, src): |
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
629 """Build a commit function for the replacement of <src> |
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
630 |
18644
3e92772d5383
spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents:
18609
diff
changeset
|
631 This function ensure we apply the same treatment to all changesets. |
18436
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
632 |
18437
358c23e8f1c6
histedit: record histedit source (issue3681)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18436
diff
changeset
|
633 - Add a 'histedit_source' entry in extra. |
18436
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
634 |
25450
7e36c3000ead
histedit: copyedit docstring wording problem I noticed while here
Augie Fackler <augie@google.com>
parents:
25412
diff
changeset
|
635 Note that fold has its own separated logic because its handling is a bit |
18436
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
636 different and not easily factored out of the fold method. |
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
637 """ |
18440
35513c59f376
histedit: proper phase conservation (issue3724)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18437
diff
changeset
|
638 phasemin = src.phase() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
639 |
18436
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
640 def commitfunc(**kwargs): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
641 overrides = {(b'phases', b'new-commit'): phasemin} |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
642 with repo.ui.configoverride(overrides, b'histedit'): |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43376
diff
changeset
|
643 extra = kwargs.get('extra', {}).copy() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
644 extra[b'histedit_source'] = src.hex() |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43376
diff
changeset
|
645 kwargs['extra'] = extra |
18440
35513c59f376
histedit: proper phase conservation (issue3724)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18437
diff
changeset
|
646 return repo.commit(**kwargs) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
647 |
18436
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
648 return commitfunc |
b38c10502af9
histedit: factor most commit creation in a function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18370
diff
changeset
|
649 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
650 |
17647
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
651 def applychanges(ui, repo, ctx, opts): |
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
652 """Merge changeset from ctx (only) in the current working directory""" |
45395
8c466bcb0879
revert: remove dangerous `parents` argument from `cmdutil.revert()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
45034
diff
changeset
|
653 if ctx.p1().node() == repo.dirstate.p1(): |
26171 | 654 # edits are "in place" we do not need to make any merge, |
27603
8a87627d263a
histedit: fix comment in applychanges
timeless <timeless@mozdev.org>
parents:
27600
diff
changeset
|
655 # just applies changes on parent for editing |
47443
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47441
diff
changeset
|
656 with ui.silent(): |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47441
diff
changeset
|
657 cmdutil.revert(ui, repo, ctx, all=True) |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47441
diff
changeset
|
658 stats = mergemod.updateresult(0, 0, 0, 0) |
17647
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
659 else: |
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
660 try: |
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
661 # ui.forcemerge is an internal variable, do not document |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
662 repo.ui.setconfig( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
663 b'ui', b'forcemerge', opts.get(b'tool', b''), b'histedit' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
664 ) |
44286
cb8b67016110
graft: default `base` argument to common case of `ctx.p1()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44000
diff
changeset
|
665 stats = mergemod.graft(repo, ctx, labels=[b'local', b'histedit']) |
17647
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
666 finally: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
667 repo.ui.setconfig(b'ui', b'forcemerge', b'', b'histedit') |
17647
d34ba4991188
histedit: replaces patching logic by merges
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17645
diff
changeset
|
668 return stats |
17407
31c123a2f273
histedit: factored out diff/patch logic
Leah Xue <leahxue@fb.com>
parents:
17340
diff
changeset
|
669 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
670 |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
671 def collapse(repo, firstctx, lastctx, commitopts, skipprompt=False): |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
672 """collapse the set of revisions from first to last as new one. |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
673 |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
674 Expected commit options are: |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
675 - message |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
676 - date |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
677 - username |
17738
b8424c92ba2b
spelling: fix minor spell checker issues
Mads Kiilerich <mads@kiilerich.com>
parents:
17666
diff
changeset
|
678 Commit message is edited in all cases. |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
679 |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
680 This function works in memory.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
681 ctxs = list(repo.set(b'%d::%d', firstctx.rev(), lastctx.rev())) |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
682 if not ctxs: |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
683 return None |
25452
43906060a3f4
histedit: abort rather than edit a public changeset (issue4704)
Augie Fackler <augie@google.com>
parents:
25450
diff
changeset
|
684 for c in ctxs: |
43906060a3f4
histedit: abort rather than edit a public changeset (issue4704)
Augie Fackler <augie@google.com>
parents:
25450
diff
changeset
|
685 if not c.mutable(): |
27545
a67d2e059a51
histedit: use parse-error exception for parsing
timeless <timeless@mozdev.org>
parents:
27543
diff
changeset
|
686 raise error.ParseError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
687 _(b"cannot fold into public change %s") % short(c.node()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
688 ) |
41419
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41223
diff
changeset
|
689 base = firstctx.p1() |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
690 |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
691 # commit a new version of the old changeset, including the update |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
692 # collect all files which might be affected |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
693 files = set() |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
694 for ctx in ctxs: |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
695 files.update(ctx.files()) |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
696 |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
697 # Recompute copies (avoid recording a -> b -> a) |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
698 copied = copies.pathcopies(base, lastctx) |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
699 |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
700 # prune files which were reverted by the updates |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
701 files = [f for f in files if not cmdutil.samefile(f, lastctx, base)] |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
702 # commit version of these files as defined by head |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
703 headmf = lastctx.manifest() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
704 |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
705 def filectxfn(repo, ctx, path): |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
706 if path in headmf: |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
707 fctx = lastctx[path] |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
708 flags = fctx.flags() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
709 mctx = context.memfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
710 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
711 ctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
712 fctx.path(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
713 fctx.data(), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
714 islink=b'l' in flags, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
715 isexec=b'x' in flags, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
716 copysource=copied.get(path), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
717 ) |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
718 return mctx |
22296
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22280
diff
changeset
|
719 return None |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
720 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
721 if commitopts.get(b'message'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
722 message = commitopts[b'message'] |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
723 else: |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
724 message = firstctx.description() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
725 user = commitopts.get(b'user') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
726 date = commitopts.get(b'date') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
727 extra = commitopts.get(b'extra') |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
728 |
36433
10de411d7207
histedit: rename variables so they have "ctx" in them
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36275
diff
changeset
|
729 parents = (firstctx.p1().node(), firstctx.p2().node()) |
22152
d2a5986cb89d
histedit: add "roll" command to fold commit data and drop message (issue4256)
Mike Edgar <adgar@google.com>
parents:
22059
diff
changeset
|
730 editor = None |
24828
5045a003260b
histedit: fix rollup prompting for a commit message (issue4606)
Durham Goode <durham@fb.com>
parents:
24810
diff
changeset
|
731 if not skipprompt: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
732 editor = cmdutil.getcommiteditor(edit=True, editform=b'histedit.fold') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
733 new = context.memctx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
734 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
735 parents=parents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
736 text=message, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
737 files=files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
738 filectxfn=filectxfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
739 user=user, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
740 date=date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
741 extra=extra, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
742 editor=editor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
743 ) |
17644
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
744 return repo.commitctx(new) |
9ae073f10572
histedit: fold in memory
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17643
diff
changeset
|
745 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
746 |
26981
cda2e980281e
histedit: extracts _isdirtywc function
liscju <piotr.listkiewicz@gmail.com>
parents:
26798
diff
changeset
|
747 def _isdirtywc(repo): |
cda2e980281e
histedit: extracts _isdirtywc function
liscju <piotr.listkiewicz@gmail.com>
parents:
26798
diff
changeset
|
748 return repo[None].dirty(missing=True) |
cda2e980281e
histedit: extracts _isdirtywc function
liscju <piotr.listkiewicz@gmail.com>
parents:
26798
diff
changeset
|
749 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
750 |
27084
383f10b67fd6
histedit: add abortdirty function
Mateusz Kwapich <mitrandir@fb.com>
parents:
27083
diff
changeset
|
751 def abortdirty(): |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
752 raise error.StateError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
753 _(b'working copy has pending changes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
754 hint=_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
755 b'amend, commit, or revert them and run histedit ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
756 b'--continue, or abort with histedit --abort' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
757 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
758 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
759 |
27084
383f10b67fd6
histedit: add abortdirty function
Mateusz Kwapich <mitrandir@fb.com>
parents:
27083
diff
changeset
|
760 |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
761 def action(verbs, message, priority=False, internal=False): |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
762 def wrap(cls): |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
763 assert not priority or not internal |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
764 verb = verbs[0] |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
765 if priority: |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
766 primaryactions.add(verb) |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
767 elif internal: |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
768 internalactions.add(verb) |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
769 elif len(verbs) > 1: |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
770 secondaryactions.add(verb) |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
771 else: |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
772 tertiaryactions.add(verb) |
27201
dcb536d2e138
histedit: add addhisteditaction decorator
Mateusz Kwapich <mitrandir@fb.com>
parents:
27200
diff
changeset
|
773 |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
774 cls.verb = verb |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
775 cls.verbs = verbs |
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
776 cls.message = message |
27201
dcb536d2e138
histedit: add addhisteditaction decorator
Mateusz Kwapich <mitrandir@fb.com>
parents:
27200
diff
changeset
|
777 for verb in verbs: |
dcb536d2e138
histedit: add addhisteditaction decorator
Mateusz Kwapich <mitrandir@fb.com>
parents:
27200
diff
changeset
|
778 actiontable[verb] = cls |
dcb536d2e138
histedit: add addhisteditaction decorator
Mateusz Kwapich <mitrandir@fb.com>
parents:
27200
diff
changeset
|
779 return cls |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
780 |
27201
dcb536d2e138
histedit: add addhisteditaction decorator
Mateusz Kwapich <mitrandir@fb.com>
parents:
27200
diff
changeset
|
781 return wrap |
dcb536d2e138
histedit: add addhisteditaction decorator
Mateusz Kwapich <mitrandir@fb.com>
parents:
27200
diff
changeset
|
782 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
783 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
784 @action([b'pick', b'p'], _(b'use commit'), priority=True) |
24767
477e76936b1d
histedit: convert pick action into a class
Durham Goode <durham@fb.com>
parents:
24766
diff
changeset
|
785 class pick(histeditaction): |
477e76936b1d
histedit: convert pick action into a class
Durham Goode <durham@fb.com>
parents:
24766
diff
changeset
|
786 def run(self): |
477e76936b1d
histedit: convert pick action into a class
Durham Goode <durham@fb.com>
parents:
24766
diff
changeset
|
787 rulectx = self.repo[self.node] |
41419
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41223
diff
changeset
|
788 if rulectx.p1().node() == self.state.parentctxnode: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
789 self.repo.ui.debug(b'node %s unchanged\n' % short(self.node)) |
24767
477e76936b1d
histedit: convert pick action into a class
Durham Goode <durham@fb.com>
parents:
24766
diff
changeset
|
790 return rulectx, [] |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
791 |
24767
477e76936b1d
histedit: convert pick action into a class
Durham Goode <durham@fb.com>
parents:
24766
diff
changeset
|
792 return super(pick, self).run() |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
793 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
794 |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
795 @action( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
796 [b'edit', b'e'], |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
797 _(b'use commit, but allow edits before making new commit'), |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
798 priority=True, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
799 ) |
24770
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
800 class edit(histeditaction): |
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
801 def run(self): |
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
802 repo = self.repo |
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
803 rulectx = repo[self.node] |
27407
bf4d5d8dc2aa
histedit: omit useless message from update (edit)
timeless <timeless@mozdev.org>
parents:
27406
diff
changeset
|
804 hg.update(repo, self.state.parentctxnode, quietempty=True) |
24770
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
805 applychanges(repo.ui, repo, rulectx, {}) |
46104
3f82a915ab2a
histedit: tweak `edit` message to try and guide users to our workflow
Augie Fackler <augie@google.com>
parents:
45957
diff
changeset
|
806 hint = _(b'to edit %s, `hg histedit --continue` after making changes') |
24770
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
807 raise error.InterventionRequired( |
46104
3f82a915ab2a
histedit: tweak `edit` message to try and guide users to our workflow
Augie Fackler <augie@google.com>
parents:
45957
diff
changeset
|
808 _(b'Editing (%s), commit as needed now to split the change') |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
809 % short(self.node), |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
810 hint=hint % short(self.node), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
811 ) |
24770
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
812 |
facdb20e60e9
histedit: convert edit action into a class
Durham Goode <durham@fb.com>
parents:
24769
diff
changeset
|
813 def commiteditor(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
814 return cmdutil.getcommiteditor(edit=True, editform=b'histedit.edit') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
815 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
816 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
817 @action([b'fold', b'f'], _(b'use commit, but combine it with the one above')) |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
818 class fold(histeditaction): |
29883
b566c5992e07
histedit: move constraint verification to the 'action.verify' method
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29882
diff
changeset
|
819 def verify(self, prev, expected, seen): |
47031
f38bf44e077f
black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents:
46941
diff
changeset
|
820 """Verifies semantic correctness of the fold rule""" |
29883
b566c5992e07
histedit: move constraint verification to the 'action.verify' method
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29882
diff
changeset
|
821 super(fold, self).verify(prev, expected, seen) |
27542
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
822 repo = self.repo |
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
823 if not prev: |
41419
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41223
diff
changeset
|
824 c = repo[self.node].p1() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
825 elif not prev.verb in (b'pick', b'base'): |
27542
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
826 return |
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
827 else: |
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
828 c = repo[prev.node] |
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
829 if not c.mutable(): |
27545
a67d2e059a51
histedit: use parse-error exception for parsing
timeless <timeless@mozdev.org>
parents:
27543
diff
changeset
|
830 raise error.ParseError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
831 _(b"cannot fold into public change %s") % short(c.node()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
832 ) |
27542
bf0900d3819c
histedit: check fold of public change during verify
timeless <timeless@mozdev.org>
parents:
27541
diff
changeset
|
833 |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
834 def continuedirty(self): |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
835 repo = self.repo |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
836 rulectx = repo[self.node] |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
837 |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
838 commit = commitfuncfor(repo, rulectx) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
839 commit( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
840 text=b'fold-temp-revision %s' % short(self.node), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
841 user=rulectx.user(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
842 date=rulectx.date(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
843 extra=rulectx.extra(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
844 ) |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
845 |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
846 def continueclean(self): |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
847 repo = self.repo |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
848 ctx = repo[b'.'] |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
849 rulectx = repo[self.node] |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
850 parentctxnode = self.state.parentctxnode |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
851 if ctx.node() == parentctxnode: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
852 repo.ui.warn(_(b'%s: empty changeset\n') % short(self.node)) |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
853 return ctx, [(self.node, (parentctxnode,))] |
22152
d2a5986cb89d
histedit: add "roll" command to fold commit data and drop message (issue4256)
Mike Edgar <adgar@google.com>
parents:
22059
diff
changeset
|
854 |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
855 parentctx = repo[parentctxnode] |
44470
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44461
diff
changeset
|
856 newcommits = { |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
857 c.node() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
858 for c in repo.set(b'(%d::. - %d)', parentctx.rev(), parentctx.rev()) |
44470
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44461
diff
changeset
|
859 } |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
860 if not newcommits: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
861 repo.ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
862 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
863 b'%s: cannot fold - working copy is not a ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
864 b'descendant of previous commit %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
865 ) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
866 % (short(self.node), short(parentctxnode)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
867 ) |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
868 return ctx, [(self.node, (ctx.node(),))] |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
869 |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
870 middlecommits = newcommits.copy() |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
871 middlecommits.discard(ctx.node()) |
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
872 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
873 return self.finishfold( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
874 repo.ui, repo, parentctx, rulectx, ctx.node(), middlecommits |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
875 ) |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
876 |
24773
090da03361c5
histedit: improve roll action integration with fold
Durham Goode <durham@fb.com>
parents:
24772
diff
changeset
|
877 def skipprompt(self): |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
878 """Returns true if the rule should skip the message editor. |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
879 |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
880 For example, 'fold' wants to show an editor, but 'rollup' |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
881 doesn't want to. |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
882 """ |
24773
090da03361c5
histedit: improve roll action integration with fold
Durham Goode <durham@fb.com>
parents:
24772
diff
changeset
|
883 return False |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
884 |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
885 def mergedescs(self): |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
886 """Returns true if the rule should merge messages of multiple changes. |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
887 |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
888 This exists mainly so that 'rollup' rules can be a subclass of |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
889 'fold'. |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
890 """ |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
891 return True |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
892 |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
893 def firstdate(self): |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
894 """Returns true if the rule should preserve the date of the first |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
895 change. |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
896 |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
897 This exists mainly so that 'rollup' rules can be a subclass of |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
898 'fold'. |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
899 """ |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
900 return False |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
901 |
24773
090da03361c5
histedit: improve roll action integration with fold
Durham Goode <durham@fb.com>
parents:
24772
diff
changeset
|
902 def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges): |
45580
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45461
diff
changeset
|
903 mergemod.update(ctx.p1()) |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
904 ### prepare new commit data |
24773
090da03361c5
histedit: improve roll action integration with fold
Durham Goode <durham@fb.com>
parents:
24772
diff
changeset
|
905 commitopts = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
906 commitopts[b'user'] = ctx.user() |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
907 # commit message |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
908 if not self.mergedescs(): |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
909 newmessage = ctx.description() |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
910 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
911 newmessage = ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
912 b'\n***\n'.join( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
913 [ctx.description()] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
914 + [repo[r].description() for r in internalchanges] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
915 + [oldctx.description()] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
916 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
917 + b'\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
918 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
919 commitopts[b'message'] = newmessage |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
920 # date |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
921 if self.firstdate(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
922 commitopts[b'date'] = ctx.date() |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
923 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
924 commitopts[b'date'] = max(ctx.date(), oldctx.date()) |
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
41212
diff
changeset
|
925 # if date is to be updated to current |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
926 if ui.configbool(b'rewrite', b'update-timestamp'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
927 commitopts[b'date'] = dateutil.makedate() |
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
41212
diff
changeset
|
928 |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
929 extra = ctx.extra().copy() |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
930 # histedit_source |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
931 # note: ctx is likely a temporary commit but that the best we can do |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
932 # here. This is sufficient to solve issue3681 anyway. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
933 extra[b'histedit_source'] = b'%s,%s' % (ctx.hex(), oldctx.hex()) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
934 commitopts[b'extra'] = extra |
31468
f84fbd27b6d3
histedit: get rid of ui.backupconfig
Jun Wu <quark@fb.com>
parents:
31338
diff
changeset
|
935 phasemin = max(ctx.phase(), oldctx.phase()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 overrides = {(b'phases', b'new-commit'): phasemin} |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
937 with repo.ui.configoverride(overrides, b'histedit'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
938 n = collapse( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
939 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
940 ctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
941 repo[newnode], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
942 commitopts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
943 skipprompt=self.skipprompt(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
944 ) |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
945 if n is None: |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
946 return ctx, [] |
45580
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45461
diff
changeset
|
947 mergemod.update(repo[n]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
948 replacements = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
949 (oldctx.node(), (newnode,)), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
950 (ctx.node(), (n,)), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
951 (newnode, (n,)), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
952 ] |
24772
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
953 for ich in internalchanges: |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
954 replacements.append((ich, (n,))) |
8f6494eb16eb
histedit: move finishfold into fold class
Durham Goode <durham@fb.com>
parents:
24771
diff
changeset
|
955 return repo[n], replacements |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
956 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
957 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
958 @action( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
959 [b'base', b'b'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
960 _(b'checkout changeset and apply further changesets from there'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
961 ) |
27085
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
962 class base(histeditaction): |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
963 def run(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
964 if self.repo[b'.'].node() != self.node: |
44317
f546d2170b0f
merge: introduce a clean_update() for that use-case
Martin von Zweigbergk <martinvonz@google.com>
parents:
44286
diff
changeset
|
965 mergemod.clean_update(self.repo[self.node]) |
27085
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
966 return self.continueclean() |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
967 |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
968 def continuedirty(self): |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
969 abortdirty() |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
970 |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
971 def continueclean(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
972 basectx = self.repo[b'.'] |
27085
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
973 return basectx, [] |
d50ff8f4891f
histedit: add an experimental base action
Mateusz Kwapich <mitrandir@fb.com>
parents:
27084
diff
changeset
|
974 |
29884
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
975 def _verifynodeconstraints(self, prev, expected, seen): |
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
976 # base can only be use with a node not in the edited set |
a485ec066867
histedt: use inheritance to override the constraints in 'base'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29883
diff
changeset
|
977 if self.node in expected: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
978 msg = _(b'%s "%s" changeset was an edited list candidate') |
29891
6d66200bff3b
histedit: correct output of error when 'base' is from the edit list
Augie Fackler <augie@google.com>
parents:
29885
diff
changeset
|
979 raise error.ParseError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
980 msg % (self.verb, short(self.node)), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
981 hint=_(b'base must only use unlisted changesets'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
982 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
983 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
984 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
985 @action( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
986 [b'_multifold'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
987 _( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
988 """fold subclass used for when multiple folds happen in a row |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
989 |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
990 We only want to fire the editor for the folded message once when |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
991 (say) four changes are folded down into a single change. This is |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
992 similar to rollup, but we should preserve both messages so that |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
993 when the last fold operation runs we can show the user all the |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
994 commit messages in their editor. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
995 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
996 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
997 internal=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
998 ) |
27675
d073f4c70575
histedit: replace @addhisteditaction with @action
timeless <timeless@mozdev.org>
parents:
27674
diff
changeset
|
999 class _multifold(fold): |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
1000 def skipprompt(self): |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
1001 return True |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
1002 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1003 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1004 @action( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1005 [b"roll", b"r"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1006 _(b"like fold, but discard this commit's description and date"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1007 ) |
24771
3133e246c912
histedit: convert fold/roll actions into a class
Durham Goode <durham@fb.com>
parents:
24770
diff
changeset
|
1008 class rollup(fold): |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
1009 def mergedescs(self): |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
1010 return False |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
1011 |
24773
090da03361c5
histedit: improve roll action integration with fold
Durham Goode <durham@fb.com>
parents:
24772
diff
changeset
|
1012 def skipprompt(self): |
090da03361c5
histedit: improve roll action integration with fold
Durham Goode <durham@fb.com>
parents:
24772
diff
changeset
|
1013 return True |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1014 |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
1015 def firstdate(self): |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
1016 return True |
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
1017 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1018 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1019 @action([b"drop", b"d"], _(b'remove commit from history')) |
24768
342671704344
histedit: convert drop action into a class
Durham Goode <durham@fb.com>
parents:
24767
diff
changeset
|
1020 class drop(histeditaction): |
342671704344
histedit: convert drop action into a class
Durham Goode <durham@fb.com>
parents:
24767
diff
changeset
|
1021 def run(self): |
342671704344
histedit: convert drop action into a class
Durham Goode <durham@fb.com>
parents:
24767
diff
changeset
|
1022 parentctx = self.repo[self.state.parentctxnode] |
342671704344
histedit: convert drop action into a class
Durham Goode <durham@fb.com>
parents:
24767
diff
changeset
|
1023 return parentctx, [(self.node, tuple())] |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1024 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1025 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1026 @action( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1027 [b"mess", b"m"], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1028 _(b'edit commit message without changing commit content'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1029 priority=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1030 ) |
24769
e875b94dc94c
histedit: convert message action into a class
Durham Goode <durham@fb.com>
parents:
24768
diff
changeset
|
1031 class message(histeditaction): |
e875b94dc94c
histedit: convert message action into a class
Durham Goode <durham@fb.com>
parents:
24768
diff
changeset
|
1032 def commiteditor(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1033 return cmdutil.getcommiteditor(edit=True, editform=b'histedit.mess') |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1034 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1035 |
26335
6c93834d7d66
histedit: remove a mutable default argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26246
diff
changeset
|
1036 def findoutgoing(ui, repo, remote=None, force=False, opts=None): |
19021
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1037 """utility function to find the first outgoing changeset |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1038 |
26171 | 1039 Used by initialization code""" |
26335
6c93834d7d66
histedit: remove a mutable default argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26246
diff
changeset
|
1040 if opts is None: |
6c93834d7d66
histedit: remove a mutable default argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26246
diff
changeset
|
1041 opts = {} |
46941
d689d48527ea
histedit: use `get_unique_push_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1042 path = urlutil.get_unique_push_path(b'histedit', repo, ui, remote) |
d689d48527ea
histedit: use `get_unique_push_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1043 dest = path.pushloc or path.loc |
d689d48527ea
histedit: use `get_unique_push_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1044 |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46468
diff
changeset
|
1045 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(dest)) |
19021
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1046 |
46941
d689d48527ea
histedit: use `get_unique_push_path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1047 revs, checkout = hg.addbranchrevs(repo, repo, (path.branch, []), None) |
19021
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1048 other = hg.peer(repo, opts, dest) |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1049 |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1050 if revs: |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1051 revs = [repo.lookup(rev) for rev in revs] |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1052 |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1053 outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force) |
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1054 if not outgoing.missing: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1055 raise error.StateError(_(b'no outgoing ancestors')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1056 roots = list(repo.revs(b"roots(%ln)", outgoing.missing)) |
40030
e2697acd9381
cleanup: some Yoda conditions, this patch removes
Martin von Zweigbergk <martinvonz@google.com>
parents:
39919
diff
changeset
|
1057 if len(roots) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1058 msg = _(b'there are ambiguous outgoing revisions') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1059 hint = _(b"see 'hg help histedit' for more detail") |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1060 raise error.StateError(msg, hint=hint) |
37314
8474005fcfe2
histedit: avoid repo.lookup() for converting revnum to nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37270
diff
changeset
|
1061 return repo[roots[0]].node() |
19021
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1062 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1063 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1064 # Curses Support |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1065 try: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1066 import curses |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1067 except ImportError: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1068 curses = None |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1069 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1070 KEY_LIST = [b'pick', b'edit', b'fold', b'drop', b'mess', b'roll'] |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1071 ACTION_LABELS = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1072 b'fold': b'^fold', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1073 b'roll': b'^roll', |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1074 } |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1075 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1076 COLOR_HELP, COLOR_SELECTED, COLOR_OK, COLOR_WARN, COLOR_CURRENT = 1, 2, 3, 4, 5 |
42089
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1077 COLOR_DIFF_ADD_LINE, COLOR_DIFF_DEL_LINE, COLOR_DIFF_OFFSET = 6, 7, 8 |
43707
1d29da62af76
histedit: define new colour pairs for roll action
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43706
diff
changeset
|
1078 COLOR_ROLL, COLOR_ROLL_CURRENT, COLOR_ROLL_SELECTED = 9, 10, 11 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1079 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1080 E_QUIT, E_HISTEDIT = 1, 2 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1081 E_PAGEDOWN, E_PAGEUP, E_LINEUP, E_LINEDOWN, E_RESIZE = 3, 4, 5, 6, 7 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1082 MODE_INIT, MODE_PATCH, MODE_RULES, MODE_HELP = 0, 1, 2, 3 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1083 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1084 KEYTABLE = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1085 b'global': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1086 b'h': b'next-action', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1087 b'KEY_RIGHT': b'next-action', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1088 b'l': b'prev-action', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1089 b'KEY_LEFT': b'prev-action', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1090 b'q': b'quit', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1091 b'c': b'histedit', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1092 b'C': b'histedit', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1093 b'v': b'showpatch', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1094 b'?': b'help', |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1095 }, |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1096 MODE_RULES: { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1097 b'd': b'action-drop', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1098 b'e': b'action-edit', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1099 b'f': b'action-fold', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1100 b'm': b'action-mess', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1101 b'p': b'action-pick', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1102 b'r': b'action-roll', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1103 b' ': b'select', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1104 b'j': b'down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1105 b'k': b'up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1106 b'KEY_DOWN': b'down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1107 b'KEY_UP': b'up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1108 b'J': b'move-down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1109 b'K': b'move-up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1110 b'KEY_NPAGE': b'move-down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1111 b'KEY_PPAGE': b'move-up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1112 b'0': b'goto', # Used for 0..9 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1113 }, |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1114 MODE_PATCH: { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1115 b' ': b'page-down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1116 b'KEY_NPAGE': b'page-down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1117 b'KEY_PPAGE': b'page-up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1118 b'j': b'line-down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1119 b'k': b'line-up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1120 b'KEY_DOWN': b'line-down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1121 b'KEY_UP': b'line-up', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1122 b'J': b'down', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1123 b'K': b'up', |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1124 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1125 MODE_HELP: {}, |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1126 } |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1127 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1128 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1129 def screen_size(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1130 return struct.unpack(b'hh', fcntl.ioctl(1, termios.TIOCGWINSZ, b' ')) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1131 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1132 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1133 class histeditrule(object): |
44576
ad5a10f49dfa
chistedit: support histedit.summary-template in curses histedit plan
Kyle Lippincott <spectral@google.com>
parents:
44470
diff
changeset
|
1134 def __init__(self, ui, ctx, pos, action=b'pick'): |
ad5a10f49dfa
chistedit: support histedit.summary-template in curses histedit plan
Kyle Lippincott <spectral@google.com>
parents:
44470
diff
changeset
|
1135 self.ui = ui |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1136 self.ctx = ctx |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1137 self.action = action |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1138 self.origpos = pos |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1139 self.pos = pos |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1140 self.conflicts = [] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1141 |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1142 def __bytes__(self): |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1143 # Example display of several histeditrules: |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1144 # |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1145 # #10 pick 316392:06a16c25c053 add option to skip tests |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1146 # #11 ^roll 316393:71313c964cc5 <RED>oops a fixup commit</RED> |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1147 # #12 pick 316394:ab31f3973b0d include mfbt for mozilla-config.h |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1148 # #13 ^fold 316395:14ce5803f4c3 fix warnings |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1149 # |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1150 # The carets point to the changeset being folded into ("roll this |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1151 # changeset into the changeset above"). |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1152 return b'%s%s' % (self.prefix, self.desc) |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1153 |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1154 __str__ = encoding.strmethod(__bytes__) |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1155 |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1156 @property |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1157 def prefix(self): |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1158 # Some actions ('fold' and 'roll') combine a patch with a |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1159 # previous one. Add a marker showing which patch they apply |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1160 # to. |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1161 action = ACTION_LABELS.get(self.action, self.action) |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1162 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1163 h = self.ctx.hex()[0:12] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1164 r = self.ctx.rev() |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1165 |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1166 return b"#%s %s %d:%s " % ( |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1167 (b'%d' % self.origpos).ljust(2), |
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1168 action.ljust(6), |
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1169 r, |
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1170 h, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1171 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1172 |
45461
47d10ade5bc4
histedit: cache description line
Martin von Zweigbergk <martinvonz@google.com>
parents:
45395
diff
changeset
|
1173 @util.propertycache |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1174 def desc(self): |
45814
1f9736eb0e65
histedit: drop fallback to empty string from rendertemplate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45580
diff
changeset
|
1175 summary = cmdutil.rendertemplate( |
1f9736eb0e65
histedit: drop fallback to empty string from rendertemplate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45580
diff
changeset
|
1176 self.ctx, self.ui.config(b'histedit', b'summary-template') |
44576
ad5a10f49dfa
chistedit: support histedit.summary-template in curses histedit plan
Kyle Lippincott <spectral@google.com>
parents:
44470
diff
changeset
|
1177 ) |
ad5a10f49dfa
chistedit: support histedit.summary-template in curses histedit plan
Kyle Lippincott <spectral@google.com>
parents:
44470
diff
changeset
|
1178 if summary: |
ad5a10f49dfa
chistedit: support histedit.summary-template in curses histedit plan
Kyle Lippincott <spectral@google.com>
parents:
44470
diff
changeset
|
1179 return summary |
43706
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1180 # This is split off from the prefix property so that we can |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1181 # separately make the description for 'roll' red (since it |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1182 # will get discarded). |
4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43617
diff
changeset
|
1183 return self.ctx.description().splitlines()[0].strip() |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1184 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1185 def checkconflicts(self, other): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1186 if other.pos > self.pos and other.origpos <= self.origpos: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1187 if set(other.ctx.files()) & set(self.ctx.files()) != set(): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1188 self.conflicts.append(other) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1189 return self.conflicts |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1190 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1191 if other in self.conflicts: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1192 self.conflicts.remove(other) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1193 return self.conflicts |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1194 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1195 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1196 # ============ EVENTS =============== |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1197 def movecursor(state, oldpos, newpos): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
1198 """Change the rule/changeset that the cursor is pointing to, regardless of |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
1199 current mode (you can switch between patches from the view patch window).""" |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1200 state.pos = newpos |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1201 |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1202 mode, _ = state.mode |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1203 if mode == MODE_RULES: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1204 # Scroll through the list by updating the view for MODE_RULES, so that |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1205 # even if we are not currently viewing the rules, switching back will |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1206 # result in the cursor's rule being visible. |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1207 modestate = state.modes[MODE_RULES] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1208 if newpos < modestate[b'line_offset']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1209 modestate[b'line_offset'] = newpos |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1210 elif newpos > modestate[b'line_offset'] + state.page_height - 1: |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1211 modestate[b'line_offset'] = newpos - state.page_height + 1 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1212 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1213 # Reset the patch view region to the top of the new patch. |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1214 state.modes[MODE_PATCH][b'line_offset'] = 0 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1215 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1216 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1217 def changemode(state, mode): |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1218 curmode, _ = state.mode |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1219 state.mode = (mode, curmode) |
42263
c4a50e863ee2
histedit: Speed up scrolling in patch view mode
feyu@google.com
parents:
42262
diff
changeset
|
1220 if mode == MODE_PATCH: |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1221 state.modes[MODE_PATCH][b'patchcontents'] = patchcontents(state) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1222 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1223 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1224 def makeselection(state, pos): |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1225 state.selected = pos |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1226 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1227 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1228 def swap(state, oldpos, newpos): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1229 """Swap two positions and calculate necessary conflicts in |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1230 O(|newpos-oldpos|) time""" |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1231 |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1232 rules = state.rules |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1233 assert 0 <= oldpos < len(rules) and 0 <= newpos < len(rules) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1234 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1235 rules[oldpos], rules[newpos] = rules[newpos], rules[oldpos] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1236 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1237 # TODO: swap should not know about histeditrule's internals |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1238 rules[newpos].pos = newpos |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1239 rules[oldpos].pos = oldpos |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1240 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1241 start = min(oldpos, newpos) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1242 end = max(oldpos, newpos) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1243 for r in pycompat.xrange(start, end + 1): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1244 rules[newpos].checkconflicts(rules[r]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1245 rules[oldpos].checkconflicts(rules[r]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1246 |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1247 if state.selected: |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1248 makeselection(state, newpos) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1249 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1250 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1251 def changeaction(state, pos, action): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1252 """Change the action state on the given position to the new action""" |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1253 rules = state.rules |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1254 assert 0 <= pos < len(rules) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1255 rules[pos].action = action |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1256 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1257 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1258 def cycleaction(state, pos, next=False): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1259 """Changes the action state the next or the previous action from |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1260 the action list""" |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1261 rules = state.rules |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1262 assert 0 <= pos < len(rules) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1263 current = rules[pos].action |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1264 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1265 assert current in KEY_LIST |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1266 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1267 index = KEY_LIST.index(current) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1268 if next: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1269 index += 1 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1270 else: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1271 index -= 1 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1272 changeaction(state, pos, KEY_LIST[index % len(KEY_LIST)]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1273 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1274 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1275 def changeview(state, delta, unit): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
1276 """Change the region of whatever is being viewed (a patch or the list of |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45908
diff
changeset
|
1277 changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'.""" |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1278 mode, _ = state.mode |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1279 if mode != MODE_PATCH: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1280 return |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1281 mode_state = state.modes[mode] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1282 num_lines = len(mode_state[b'patchcontents']) |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1283 page_height = state.page_height |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1284 unit = page_height if unit == b'page' else 1 |
44608
d06e748cfd02
py3: use integer division in histedit
Martin von Zweigbergk <martinvonz@google.com>
parents:
44576
diff
changeset
|
1285 num_pages = 1 + (num_lines - 1) // page_height |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1286 max_offset = (num_pages - 1) * page_height |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1287 newline = mode_state[b'line_offset'] + delta * unit |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1288 mode_state[b'line_offset'] = max(0, min(max_offset, newline)) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1289 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1290 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1291 def event(state, ch): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1292 """Change state based on the current character input |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1293 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1294 This takes the current state and based on the current character input from |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1295 the user we change the state. |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1296 """ |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1297 selected = state.selected |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1298 oldpos = state.pos |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1299 rules = state.rules |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1300 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1301 if ch in (curses.KEY_RESIZE, b"KEY_RESIZE"): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1302 return E_RESIZE |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1303 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1304 lookup_ch = ch |
43228
0d609ed185ea
py3: prevent comparison with None in curses histedit (issue6196)
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
43117
diff
changeset
|
1305 if ch is not None and b'0' <= ch <= b'9': |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1306 lookup_ch = b'0' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1307 |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1308 curmode, prevmode = state.mode |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1309 action = KEYTABLE[curmode].get( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1310 lookup_ch, KEYTABLE[b'global'].get(lookup_ch) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1311 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1312 if action is None: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1313 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1314 if action in (b'down', b'move-down'): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1315 newpos = min(oldpos + 1, len(rules) - 1) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1316 movecursor(state, oldpos, newpos) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1317 if selected is not None or action == b'move-down': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1318 swap(state, oldpos, newpos) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1319 elif action in (b'up', b'move-up'): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1320 newpos = max(0, oldpos - 1) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1321 movecursor(state, oldpos, newpos) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1322 if selected is not None or action == b'move-up': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1323 swap(state, oldpos, newpos) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1324 elif action == b'next-action': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1325 cycleaction(state, oldpos, next=True) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1326 elif action == b'prev-action': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1327 cycleaction(state, oldpos, next=False) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1328 elif action == b'select': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1329 selected = oldpos if selected is None else None |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1330 makeselection(state, selected) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1331 elif action == b'goto' and int(ch) < len(rules) and len(rules) <= 10: |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1332 newrule = next((r for r in rules if r.origpos == int(ch))) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1333 movecursor(state, oldpos, newrule.pos) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1334 if selected is not None: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1335 swap(state, oldpos, newrule.pos) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1336 elif action.startswith(b'action-'): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1337 changeaction(state, oldpos, action[7:]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1338 elif action == b'showpatch': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1339 changemode(state, MODE_PATCH if curmode != MODE_PATCH else prevmode) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1340 elif action == b'help': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1341 changemode(state, MODE_HELP if curmode != MODE_HELP else prevmode) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1342 elif action == b'quit': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1343 return E_QUIT |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1344 elif action == b'histedit': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1345 return E_HISTEDIT |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1346 elif action == b'page-down': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1347 return E_PAGEDOWN |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1348 elif action == b'page-up': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1349 return E_PAGEUP |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1350 elif action == b'line-down': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1351 return E_LINEDOWN |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1352 elif action == b'line-up': |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1353 return E_LINEUP |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1354 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1355 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1356 def makecommands(rules): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1357 """Returns a list of commands consumable by histedit --commands based on |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1358 our list of rules""" |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1359 commands = [] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1360 for rules in rules: |
43371
85ab79bc7dab
py3: avoid another b''.format() in chistedit
Martin von Zweigbergk <martinvonz@google.com>
parents:
43370
diff
changeset
|
1361 commands.append(b'%s %s\n' % (rules.action, rules.ctx)) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1362 return commands |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1363 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1364 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1365 def addln(win, y, x, line, color=None): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1366 """Add a line to the given window left padding but 100% filled with |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1367 whitespace characters, so that the color appears on the whole line""" |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1368 maxy, maxx = win.getmaxyx() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1369 length = maxx - 1 - x |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1370 line = bytes(line).ljust(length)[:length] |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1371 if y < 0: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1372 y = maxy + y |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1373 if x < 0: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1374 x = maxx + x |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1375 if color: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1376 win.addstr(y, x, line, color) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1377 else: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1378 win.addstr(y, x, line) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1379 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1380 |
42262
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1381 def _trunc_head(line, n): |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1382 if len(line) <= n: |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1383 return line |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1384 return b'> ' + line[-(n - 2) :] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1385 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1386 |
42262
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1387 def _trunc_tail(line, n): |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1388 if len(line) <= n: |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1389 return line |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1390 return line[: n - 2] + b' >' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1391 |
42262
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1392 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1393 def patchcontents(state): |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1394 repo = state.repo |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1395 rule = state.rules[state.pos] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1396 displayer = logcmdutil.changesetdisplayer( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1397 repo.ui, repo, {b"patch": True, b"template": b"status"}, buffered=True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1398 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1399 overrides = {(b'ui', b'verbose'): True} |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1400 with repo.ui.configoverride(overrides, source=b'histedit'): |
42202
9e40c5892714
chistedit: use context manager to set verbose ui
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42089
diff
changeset
|
1401 displayer.show(rule.ctx) |
9e40c5892714
chistedit: use context manager to set verbose ui
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42089
diff
changeset
|
1402 displayer.close() |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1403 return displayer.hunk[rule.ctx.rev()].splitlines() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1404 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1405 |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1406 class _chistedit_state(object): |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1407 def __init__( |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1408 self, |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1409 repo, |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1410 rules, |
48214
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1411 stdscr, |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1412 ): |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1413 self.repo = repo |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1414 self.rules = rules |
48214
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1415 self.stdscr = stdscr |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1416 self.pos = 0 |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1417 self.selected = None |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1418 self.mode = (MODE_INIT, MODE_INIT) |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1419 self.page_height = None |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1420 self.modes = { |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1421 MODE_RULES: { |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1422 b'line_offset': 0, |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1423 }, |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1424 MODE_PATCH: { |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1425 b'line_offset': 0, |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1426 }, |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1427 } |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1428 |
48213
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1429 def render_commit(self, win): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1430 """Renders the commit window that shows the log of the current selected |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1431 commit""" |
48213
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1432 pos = self.pos |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1433 rules = self.rules |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1434 rule = rules[pos] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1435 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1436 ctx = rule.ctx |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1437 win.box() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1438 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1439 maxy, maxx = win.getmaxyx() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1440 length = maxx - 3 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1441 |
43376
b27cf9f52194
histedit: restore hex nodeids to be 12 digits long
Martin von Zweigbergk <martinvonz@google.com>
parents:
43373
diff
changeset
|
1442 line = b"changeset: %d:%s" % (ctx.rev(), ctx.hex()[:12]) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1443 win.addstr(1, 1, line[:length]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1444 |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1445 line = b"user: %s" % ctx.user() |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1446 win.addstr(2, 1, line[:length]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1447 |
48213
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1448 bms = self.repo.nodebookmarks(ctx.node()) |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1449 line = b"bookmark: %s" % b' '.join(bms) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1450 win.addstr(3, 1, line[:length]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1451 |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1452 line = b"summary: %s" % (ctx.description().splitlines()[0]) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1453 win.addstr(4, 1, line[:length]) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1454 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1455 line = b"files: " |
42262
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1456 win.addstr(5, 1, line) |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1457 fnx = 1 + len(line) |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1458 fnmaxx = length - fnx + 1 |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1459 y = 5 |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1460 fnmaxn = maxy - (1 + y) - 1 |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1461 files = ctx.files() |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1462 for i, line1 in enumerate(files): |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1463 if len(files) > fnmaxn and i == fnmaxn - 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1464 win.addstr(y, fnx, _trunc_tail(b','.join(files[i:]), fnmaxx)) |
42262
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1465 y = y + 1 |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1466 break |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1467 win.addstr(y, fnx, _trunc_head(line1, fnmaxx)) |
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1468 y = y + 1 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1469 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1470 conflicts = rule.conflicts |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1471 if len(conflicts) > 0: |
43376
b27cf9f52194
histedit: restore hex nodeids to be 12 digits long
Martin von Zweigbergk <martinvonz@google.com>
parents:
43373
diff
changeset
|
1472 conflictstr = b','.join(map(lambda r: r.ctx.hex()[:12], conflicts)) |
43368
d8215ff082da
py3: make chistedit render
Martin von Zweigbergk <martinvonz@google.com>
parents:
43228
diff
changeset
|
1473 conflictstr = b"changed files overlap with %s" % conflictstr |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1474 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1475 conflictstr = b'no overlap' |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1476 |
42262
4ad191041be2
histedit: Show file names in multiple line format
Yu Feng <rainwoodman@gmail.com>
parents:
42202
diff
changeset
|
1477 win.addstr(y, 1, conflictstr[:length]) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1478 win.noutrefresh() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1479 |
48214
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1480 def helplines(self): |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1481 if self.mode[0] == MODE_PATCH: |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1482 help = b"""\ |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1483 ?: help, k/up: line up, j/down: line down, v: stop viewing patch |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1484 pgup: prev page, space/pgdn: next page, c: commit, q: abort |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1485 """ |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1486 else: |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1487 help = b"""\ |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1488 ?: help, k/up: move up, j/down: move down, space: select, v: view patch |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1489 d: drop, e: edit, f: fold, m: mess, p: pick, r: roll |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1490 pgup/K: move patch up, pgdn/J: move patch down, c: commit, q: abort |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1491 """ |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1492 return help.splitlines() |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1493 |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1494 def render_help(self, win): |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1495 maxy, maxx = win.getmaxyx() |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1496 for y, line in enumerate(self.helplines()): |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1497 if y >= maxy: |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1498 break |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1499 addln(win, y, 0, line, curses.color_pair(COLOR_HELP)) |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1500 win.noutrefresh() |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1501 |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1502 def layout(self): |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1503 maxy, maxx = self.stdscr.getmaxyx() |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1504 helplen = len(self.helplines()) |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1505 mainlen = maxy - helplen - 12 |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1506 if mainlen < 1: |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1507 raise error.Abort( |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1508 _(b"terminal dimensions %d by %d too small for curses histedit") |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1509 % (maxy, maxx), |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1510 hint=_( |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1511 b"enlarge your terminal or use --config ui.interface=text" |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1512 ), |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1513 ) |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1514 return { |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1515 b'commit': (12, maxx), |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1516 b'help': (helplen, maxx), |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1517 b'main': (mainlen, maxx), |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1518 } |
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1519 |
48213
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1520 |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1521 def _chisteditmain(repo, rules, stdscr): |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1522 try: |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1523 curses.use_default_colors() |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1524 except curses.error: |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1525 pass |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1526 |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1527 # initialize color pattern |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1528 curses.init_pair(COLOR_HELP, curses.COLOR_WHITE, curses.COLOR_BLUE) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1529 curses.init_pair(COLOR_SELECTED, curses.COLOR_BLACK, curses.COLOR_WHITE) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1530 curses.init_pair(COLOR_WARN, curses.COLOR_BLACK, curses.COLOR_YELLOW) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1531 curses.init_pair(COLOR_OK, curses.COLOR_BLACK, curses.COLOR_GREEN) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1532 curses.init_pair(COLOR_CURRENT, curses.COLOR_WHITE, curses.COLOR_MAGENTA) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1533 curses.init_pair(COLOR_DIFF_ADD_LINE, curses.COLOR_GREEN, -1) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1534 curses.init_pair(COLOR_DIFF_DEL_LINE, curses.COLOR_RED, -1) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1535 curses.init_pair(COLOR_DIFF_OFFSET, curses.COLOR_MAGENTA, -1) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1536 curses.init_pair(COLOR_ROLL, curses.COLOR_RED, -1) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1537 curses.init_pair( |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1538 COLOR_ROLL_CURRENT, curses.COLOR_BLACK, curses.COLOR_MAGENTA |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1539 ) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1540 curses.init_pair(COLOR_ROLL_SELECTED, curses.COLOR_RED, curses.COLOR_WHITE) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1541 |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1542 # don't display the cursor |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1543 try: |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1544 curses.curs_set(0) |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1545 except curses.error: |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1546 pass |
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1547 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1548 def renderrules(rulesscr, state): |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1549 rules = state.rules |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1550 pos = state.pos |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1551 selected = state.selected |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1552 start = state.modes[MODE_RULES][b'line_offset'] |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1553 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1554 conflicts = [r.ctx for r in rules if r.conflicts] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1555 if len(conflicts) > 0: |
43370
7f56b0cbd245
py3: render message about conflicts in chistedit code
Martin von Zweigbergk <martinvonz@google.com>
parents:
43369
diff
changeset
|
1556 line = b"potential conflict in %s" % b','.join( |
7f56b0cbd245
py3: render message about conflicts in chistedit code
Martin von Zweigbergk <martinvonz@google.com>
parents:
43369
diff
changeset
|
1557 map(pycompat.bytestr, conflicts) |
7f56b0cbd245
py3: render message about conflicts in chistedit code
Martin von Zweigbergk <martinvonz@google.com>
parents:
43369
diff
changeset
|
1558 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1559 addln(rulesscr, -1, 0, line, curses.color_pair(COLOR_WARN)) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1560 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1561 for y, rule in enumerate(rules[start:]): |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1562 if y >= state.page_height: |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1563 break |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1564 if len(rule.conflicts) > 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1565 rulesscr.addstr(y, 0, b" ", curses.color_pair(COLOR_WARN)) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1566 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1567 rulesscr.addstr(y, 0, b" ", curses.COLOR_BLACK) |
43708
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1568 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1569 if y + start == selected: |
43708
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1570 rollcolor = COLOR_ROLL_SELECTED |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1571 addln(rulesscr, y, 2, rule, curses.color_pair(COLOR_SELECTED)) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1572 elif y + start == pos: |
43708
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1573 rollcolor = COLOR_ROLL_CURRENT |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1574 addln( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1575 rulesscr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1576 y, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1577 2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1578 rule, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1579 curses.color_pair(COLOR_CURRENT) | curses.A_BOLD, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1580 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1581 else: |
43708
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1582 rollcolor = COLOR_ROLL |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1583 addln(rulesscr, y, 2, rule) |
43708
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1584 |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1585 if rule.action == b'roll': |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1586 rulesscr.addstr( |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1587 y, |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1588 2 + len(rule.prefix), |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1589 rule.desc, |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1590 curses.color_pair(rollcolor), |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1591 ) |
bde66eb4051d
histedit: render a rolled up description using the proper roll colours
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
43707
diff
changeset
|
1592 |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1593 rulesscr.noutrefresh() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1594 |
42089
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1595 def renderstring(win, state, output, diffcolors=False): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1596 maxy, maxx = win.getmaxyx() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1597 length = min(maxy - 1, len(output)) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1598 for y in range(0, length): |
42089
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1599 line = output[y] |
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1600 if diffcolors: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1601 if line and line[0] == b'+': |
42089
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1602 win.addstr( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1603 y, 0, line, curses.color_pair(COLOR_DIFF_ADD_LINE) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1604 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1605 elif line and line[0] == b'-': |
42089
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1606 win.addstr( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1607 y, 0, line, curses.color_pair(COLOR_DIFF_DEL_LINE) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1608 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1609 elif line.startswith(b'@@ '): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1610 win.addstr(y, 0, line, curses.color_pair(COLOR_DIFF_OFFSET)) |
42089
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1611 else: |
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1612 win.addstr(y, 0, line) |
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1613 else: |
16692aa3472b
chistedit: add basic colours to diff view
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42088
diff
changeset
|
1614 win.addstr(y, 0, line) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1615 win.noutrefresh() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1616 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1617 def renderpatch(win, state): |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1618 start = state.modes[MODE_PATCH][b'line_offset'] |
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1619 content = state.modes[MODE_PATCH][b'patchcontents'] |
42263
c4a50e863ee2
histedit: Speed up scrolling in patch view mode
feyu@google.com
parents:
42262
diff
changeset
|
1620 renderstring(win, state, content[start:], diffcolors=True) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1621 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1622 def drawvertwin(size, y, x): |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1623 win = curses.newwin(size[0], size[1], y, x) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1624 y += size[0] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1625 return win, y, x |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1626 |
48214
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1627 state = _chistedit_state(repo, rules, stdscr) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1628 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1629 # eventloop |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1630 ch = None |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1631 stdscr.clear() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1632 stdscr.refresh() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1633 while True: |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1634 oldmode, unused = state.mode |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1635 if oldmode == MODE_INIT: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1636 changemode(state, MODE_RULES) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1637 e = event(state, ch) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1638 |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1639 if e == E_QUIT: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1640 return False |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1641 if e == E_HISTEDIT: |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1642 return state.rules |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1643 else: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1644 if e == E_RESIZE: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1645 size = screen_size() |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1646 if size != stdscr.getmaxyx(): |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1647 curses.resizeterm(*size) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1648 |
48214
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1649 sizes = state.layout() |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1650 curmode, unused = state.mode |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1651 if curmode != oldmode: |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1652 state.page_height = sizes[b'main'][0] |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1653 # Adjust the view to fit the current screen size. |
48212
b6fc7d188f68
chistedit: move view state from a dict to a custom class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48128
diff
changeset
|
1654 movecursor(state, state.pos, state.pos) |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1655 |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1656 # Pack the windows against the top, each pane spread across the |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1657 # full width of the screen. |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1658 y, x = (0, 0) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1659 helpwin, y, x = drawvertwin(sizes[b'help'], y, x) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1660 mainwin, y, x = drawvertwin(sizes[b'main'], y, x) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1661 commitwin, y, x = drawvertwin(sizes[b'commit'], y, x) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1662 |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1663 if e in (E_PAGEDOWN, E_PAGEUP, E_LINEDOWN, E_LINEUP): |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1664 if e == E_PAGEDOWN: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1665 changeview(state, +1, b'page') |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1666 elif e == E_PAGEUP: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1667 changeview(state, -1, b'page') |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1668 elif e == E_LINEDOWN: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1669 changeview(state, +1, b'line') |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1670 elif e == E_LINEUP: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1671 changeview(state, -1, b'line') |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1672 |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1673 # start rendering |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1674 commitwin.erase() |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1675 helpwin.erase() |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1676 mainwin.erase() |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1677 if curmode == MODE_PATCH: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1678 renderpatch(mainwin, state) |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1679 elif curmode == MODE_HELP: |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1680 renderstring(mainwin, state, __doc__.strip().splitlines()) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1681 else: |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1682 renderrules(mainwin, state) |
48213
8ac61257c807
chistedit: move rendercommit() onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48212
diff
changeset
|
1683 state.render_commit(commitwin) |
48214
9006eafa0942
chistedit: move layout() and dependencies onto state class
Martin von Zweigbergk <martinvonz@google.com>
parents:
48213
diff
changeset
|
1684 state.render_help(helpwin) |
46468
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1685 curses.doupdate() |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1686 # done rendering |
11ce2977572f
histedit: rip out mysterious catch-all ignore curses.error handler
Augie Fackler <augie@google.com>
parents:
46467
diff
changeset
|
1687 ch = encoding.strtolocal(stdscr.getkey()) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1688 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1689 |
44191
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1690 def _chistedit(ui, repo, freeargs, opts): |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1691 """interactively edit changeset history via a curses interface |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1692 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1693 Provides a ncurses interface to histedit. Press ? in chistedit mode |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1694 to see an extensive help. Requires python-curses to be installed.""" |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1695 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1696 if curses is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1697 raise error.Abort(_(b"Python curses library required")) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1698 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1699 # disable color |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1700 ui._colormode = None |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1701 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1702 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1703 keep = opts.get(b'keep') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1704 revs = opts.get(b'rev', [])[:] |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1705 cmdutil.checkunfinished(repo) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1706 cmdutil.bailifchanged(repo) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1707 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1708 revs.extend(freeargs) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1709 if not revs: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1710 defaultrev = destutil.desthistedit(ui, repo) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1711 if defaultrev is not None: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1712 revs.append(defaultrev) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1713 if len(revs) != 1: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1714 raise error.InputError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1715 _(b'histedit requires exactly one ancestor revision') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1716 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1717 |
48128
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48069
diff
changeset
|
1718 rr = list(repo.set(b'roots(%ld)', logcmdutil.revrange(repo, revs))) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1719 if len(rr) != 1: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1720 raise error.InputError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1721 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1722 b'The specified revisions must have ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1723 b'exactly one common root' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1724 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1725 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1726 root = rr[0].node() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1727 |
41421
5cb8158a61f7
cleanup: use p1() instead of parents() when we only need the first parent
Martin von Zweigbergk <martinvonz@google.com>
parents:
41419
diff
changeset
|
1728 topmost = repo.dirstate.p1() |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1729 revs = between(repo, root, topmost, keep) |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1730 if not revs: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1731 raise error.InputError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
1732 _(b'%s is not an ancestor of working directory') % short(root) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1733 ) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1734 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1735 ctxs = [] |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1736 for i, r in enumerate(revs): |
44576
ad5a10f49dfa
chistedit: support histedit.summary-template in curses histedit plan
Kyle Lippincott <spectral@google.com>
parents:
44470
diff
changeset
|
1737 ctxs.append(histeditrule(ui, repo[r], i)) |
44826
1bab6b61b62b
curses: do not initialize LC_ALL to user settings (issue6358)
Manuel Jacob <me@manueljacob.de>
parents:
44663
diff
changeset
|
1738 with util.with_lc_ctype(): |
1bab6b61b62b
curses: do not initialize LC_ALL to user settings (issue6358)
Manuel Jacob <me@manueljacob.de>
parents:
44663
diff
changeset
|
1739 rc = curses.wrapper(functools.partial(_chisteditmain, repo, ctxs)) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1740 curses.echo() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1741 curses.endwin() |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1742 if rc is False: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1743 ui.write(_(b"histedit aborted\n")) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1744 return 0 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1745 if type(rc) is list: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1746 ui.status(_(b"performing changes\n")) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1747 rules = makecommands(rc) |
43372
66a0c5faed1e
py3: open chistedit file in binary mode using vfs
Martin von Zweigbergk <martinvonz@google.com>
parents:
43371
diff
changeset
|
1748 with repo.vfs(b'chistedit', b'w+') as fp: |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1749 for r in rules: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1750 fp.write(r) |
44191
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1751 opts[b'commands'] = fp.name |
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1752 return _texthistedit(ui, repo, freeargs, opts) |
40649
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1753 except KeyboardInterrupt: |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1754 pass |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1755 return -1 |
c36175456350
histedit: import chistedit curses UI from hg-experimental
Augie Fackler <augie@google.com>
parents:
40366
diff
changeset
|
1756 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1757 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1758 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1759 b'histedit', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1760 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1761 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1762 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1763 b'commands', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1764 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1765 _(b'read history edits from the specified file'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1766 _(b'FILE'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1767 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1768 (b'c', b'continue', False, _(b'continue an edit already in progress')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1769 (b'', b'edit-plan', False, _(b'edit remaining actions list')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1770 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1771 b'k', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1772 b'keep', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1773 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1774 _(b"don't strip old nodes after edit is complete"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1775 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1776 (b'', b'abort', False, _(b'abort an edit in progress')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1777 (b'o', b'outgoing', False, _(b'changesets not found in destination')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1778 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1779 b'f', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1780 b'force', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1781 False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1782 _(b'force outgoing even for unrelated repositories'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1783 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1784 (b'r', b'rev', [], _(b'first revision to be edited'), _(b'REV')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1785 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1786 + cmdutil.formatteropts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1787 _(b"[OPTIONS] ([ANCESTOR] | --outgoing [URL])"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1788 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1789 ) |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1790 def histedit(ui, repo, *freeargs, **opts): |
17131
4fb2d3d16743
histedit: add extension docstring from external README
Augie Fackler <raf@durin42.com>
parents:
17130
diff
changeset
|
1791 """interactively edit changeset history |
19621
11de0651d3b6
histedit: add description about basic histedit function to command help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19519
diff
changeset
|
1792 |
27713
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1793 This command lets you edit a linear series of changesets (up to |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1794 and including the working directory, which should be clean). |
27956
f3eb98b8fe12
doc: prevent non-literal text block from being treated as literal one
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27955
diff
changeset
|
1795 You can: |
27713
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1796 |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1797 - `pick` to [re]order a changeset |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1798 |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1799 - `drop` to omit changeset |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1800 |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1801 - `mess` to reword the changeset commit message |
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1802 |
31075
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
1803 - `fold` to combine it with the preceding changeset (using the later date) |
27713
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1804 |
31076
37ab9e20991c
histedit: modify rollup to discard date from the rollup commit (issue4820)
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31075
diff
changeset
|
1805 - `roll` like fold, but discarding this commit's description and date |
27713
fb2c77ba577a
histedit: explain basics of histedit commands
timeless <timeless@mozdev.org>
parents:
27712
diff
changeset
|
1806 |
31075
f1b63ec4b987
histedit: improve documentation and behaviour of dates
Ben Schmidt <insightfuls@users.noreply.github.com>
parents:
31003
diff
changeset
|
1807 - `edit` to edit this changeset (preserving date) |
19622
3d0ece7523c8
histedit: add description about "histedit --outgoing" to command help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19621
diff
changeset
|
1808 |
34489
270e344a6c74
histedit: removing the experimental config 'histeditng'
Saurabh Singh <singhsrb@fb.com>
parents:
34476
diff
changeset
|
1809 - `base` to checkout changeset and apply further changesets from there |
270e344a6c74
histedit: removing the experimental config 'histeditng'
Saurabh Singh <singhsrb@fb.com>
parents:
34476
diff
changeset
|
1810 |
27972
92a61d7618ac
histedit: fix typo in documentation
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
27958
diff
changeset
|
1811 There are a number of ways to select the root changeset: |
27714 | 1812 |
1813 - Specify ANCESTOR directly | |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
1814 |
27714 | 1815 - Use --outgoing -- it will be the first linear changeset not |
28077
27ae22a4f9f9
doc: describe full help document hierarchy to create a valid link in HTML
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28004
diff
changeset
|
1816 included in destination. (See :hg:`help config.paths.default-push`) |
27714 | 1817 |
1818 - Otherwise, the value from the "histedit.defaultrev" config option | |
1819 is used as a revset to select the base revision when ANCESTOR is not | |
1820 specified. The first revision returned by the revset is used. By | |
1821 default, this selects the editable history that is unique to the | |
1822 ancestry of the working directory. | |
19842
1aaefba2a3a9
histedit: add more detailed help about "--outgoing"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19841
diff
changeset
|
1823 |
27630
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1824 .. container:: verbose |
19842
1aaefba2a3a9
histedit: add more detailed help about "--outgoing"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19841
diff
changeset
|
1825 |
27630
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1826 If you use --outgoing, this command will abort if there are ambiguous |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1827 outgoing revisions. For example, if there are multiple branches |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1828 containing outgoing revisions. |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1829 |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1830 Use "min(outgoing() and ::.)" or similar revset specification |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1831 instead of --outgoing to specify edit target revision exactly in |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1832 such ambiguous situation. See :hg:`help revsets` for detail about |
9358124b4a65
histedit: hide --outgoing warnings
timeless <timeless@mozdev.org>
parents:
27629
diff
changeset
|
1833 selecting revisions. |
19972
1e13a5a9c66e
histedit: add description about exit code
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19852
diff
changeset
|
1834 |
27145
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1835 .. container:: verbose |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1836 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1837 Examples: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1838 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1839 - A number of changes have been made. |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1840 Revision 3 is no longer needed. |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1841 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1842 Start history editing from revision 3:: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1843 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1844 hg histedit -r 3 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1845 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1846 An editor opens, containing the list of revisions, |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1847 with specific actions specified:: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1848 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1849 pick 5339bf82f0ca 3 Zworgle the foobar |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1850 pick 8ef592ce7cc4 4 Bedazzle the zerlog |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1851 pick 0a9639fcda9d 5 Morgify the cromulancy |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1852 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1853 Additional information about the possible actions |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1854 to take appears below the list of revisions. |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1855 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1856 To remove revision 3 from the history, |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1857 its action (at the beginning of the relevant line) |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1858 is changed to 'drop':: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1859 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1860 drop 5339bf82f0ca 3 Zworgle the foobar |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1861 pick 8ef592ce7cc4 4 Bedazzle the zerlog |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1862 pick 0a9639fcda9d 5 Morgify the cromulancy |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1863 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1864 - A number of changes have been made. |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1865 Revision 2 and 4 need to be swapped. |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1866 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1867 Start history editing from revision 2:: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1868 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1869 hg histedit -r 2 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1870 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1871 An editor opens, containing the list of revisions, |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1872 with specific actions specified:: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1873 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1874 pick 252a1af424ad 2 Blorb a morgwazzle |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1875 pick 5339bf82f0ca 3 Zworgle the foobar |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1876 pick 8ef592ce7cc4 4 Bedazzle the zerlog |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1877 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1878 To swap revision 2 and 4, its lines are swapped |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1879 in the editor:: |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1880 |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1881 pick 8ef592ce7cc4 4 Bedazzle the zerlog |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1882 pick 5339bf82f0ca 3 Zworgle the foobar |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1883 pick 252a1af424ad 2 Blorb a morgwazzle |
3a2fd83182fb
histedit: add examples
Mathias De Maré <mathias.demare@gmail.com>
parents:
27086
diff
changeset
|
1884 |
19972
1e13a5a9c66e
histedit: add description about exit code
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19852
diff
changeset
|
1885 Returns 0 on success, 1 if user intervention is required (not only |
1e13a5a9c66e
histedit: add description about exit code
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19852
diff
changeset
|
1886 for intentional "edit" command, but also for resolving unexpected |
1e13a5a9c66e
histedit: add description about exit code
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19852
diff
changeset
|
1887 conflicts). |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1888 """ |
44191
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1889 opts = pycompat.byteskwargs(opts) |
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1890 |
41175
9bc7ec924234
histedit: fix --continue and --abort when curses is enabled
Augie Fackler <augie@google.com>
parents:
41166
diff
changeset
|
1891 # kludge: _chistedit only works for starting an edit, not aborting |
9bc7ec924234
histedit: fix --continue and --abort when curses is enabled
Augie Fackler <augie@google.com>
parents:
41166
diff
changeset
|
1892 # or continuing, so fall back to regular _texthistedit for those |
9bc7ec924234
histedit: fix --continue and --abort when curses is enabled
Augie Fackler <augie@google.com>
parents:
41166
diff
changeset
|
1893 # operations. |
44197
24a3a9f7ea77
histedit: fix formatting after D8150
Martin von Zweigbergk <martinvonz@google.com>
parents:
44191
diff
changeset
|
1894 if ui.interface(b'histedit') == b'curses' and _getgoal(opts) == goalnew: |
44191
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1895 return _chistedit(ui, repo, freeargs, opts) |
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1896 return _texthistedit(ui, repo, freeargs, opts) |
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1897 |
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1898 |
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1899 def _texthistedit(ui, repo, freeargs, opts): |
22984
e0b5f5e3afe8
histedit: move locks into state
David Soria Parra <davidsp@fb.com>
parents:
22983
diff
changeset
|
1900 state = histeditstate(repo) |
41166
9365b8cb90e0
histedit: use context manager for locks
Martin von Zweigbergk <martinvonz@google.com>
parents:
41165
diff
changeset
|
1901 with repo.wlock() as wlock, repo.lock() as lock: |
9365b8cb90e0
histedit: use context manager for locks
Martin von Zweigbergk <martinvonz@google.com>
parents:
41165
diff
changeset
|
1902 state.wlock = wlock |
9365b8cb90e0
histedit: use context manager for locks
Martin von Zweigbergk <martinvonz@google.com>
parents:
41165
diff
changeset
|
1903 state.lock = lock |
44191
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1904 _histedit(ui, repo, state, freeargs, opts) |
20071
4778f398ec83
histedit: hold wlock and lock while in progress
Siddharth Agarwal <sid0@fb.com>
parents:
19972
diff
changeset
|
1905 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1906 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1907 goalcontinue = b'continue' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1908 goalabort = b'abort' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1909 goaleditplan = b'edit-plan' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1910 goalnew = b'new' |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
1911 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1912 |
28134
df206e030c59
histedit: break _histedit function into smaller pieces
Kostia Balytskyi <ikostia@fb.com>
parents:
28133
diff
changeset
|
1913 def _getgoal(opts): |
41223
32ef47b3c91c
histedit: fix call to _getgoal() by adding a byteskwargs() wrapper
Augie Fackler <augie@google.com>
parents:
41213
diff
changeset
|
1914 if opts.get(b'continue'): |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
1915 return goalcontinue |
41223
32ef47b3c91c
histedit: fix call to _getgoal() by adding a byteskwargs() wrapper
Augie Fackler <augie@google.com>
parents:
41213
diff
changeset
|
1916 if opts.get(b'abort'): |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
1917 return goalabort |
41223
32ef47b3c91c
histedit: fix call to _getgoal() by adding a byteskwargs() wrapper
Augie Fackler <augie@google.com>
parents:
41213
diff
changeset
|
1918 if opts.get(b'edit_plan'): |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
1919 return goaleditplan |
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
1920 return goalnew |
28134
df206e030c59
histedit: break _histedit function into smaller pieces
Kostia Balytskyi <ikostia@fb.com>
parents:
28133
diff
changeset
|
1921 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1922 |
30276
bc5d0e6fd9f3
histedit: use ui.fin to read commands from stdin
Yuya Nishihara <yuya@tcha.org>
parents:
30027
diff
changeset
|
1923 def _readfile(ui, path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1924 if path == b'-': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1925 with ui.timeblockedsection(b'histedit'): |
31003
d4825798818b
histedit: log the time taken to read in the commands list
Simon Farnsworth <simonfar@fb.com>
parents:
30848
diff
changeset
|
1926 return ui.fin.read() |
28550 | 1927 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1928 with open(path, b'rb') as f: |
28550 | 1929 return f.read() |
1930 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1931 |
48068
6256c7525222
histedit: remove redundant checks for unfinished histedit state
Martin von Zweigbergk <martinvonz@google.com>
parents:
47443
diff
changeset
|
1932 def _validateargs(ui, repo, freeargs, opts, goal, rules, revs): |
27169
dd214130a4f6
histedit: improve grammar for _histedit comment
timeless <timeless@mozdev.org>
parents:
27154
diff
changeset
|
1933 # TODO only abort if we try to histedit mq patches, not just |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1934 # blanket if mq patches are applied somewhere |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1935 mq = getattr(repo, 'mq', None) |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1936 if mq and mq.applied: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1937 raise error.StateError(_(b'source has mq patches applied')) |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1938 |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1939 # basic argument incompatibility processing |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1940 outg = opts.get(b'outgoing') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1941 editplan = opts.get(b'edit_plan') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1942 abort = opts.get(b'abort') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1943 force = opts.get(b'force') |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1944 if force and not outg: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1945 raise error.InputError(_(b'--force only allowed with --outgoing')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1946 if goal == b'continue': |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
24959
diff
changeset
|
1947 if any((outg, abort, revs, freeargs, rules, editplan)): |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1948 raise error.InputError(_(b'no arguments allowed with --continue')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1949 elif goal == b'abort': |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
24959
diff
changeset
|
1950 if any((outg, revs, freeargs, rules, editplan)): |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1951 raise error.InputError(_(b'no arguments allowed with --abort')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1952 elif goal == b'edit-plan': |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
24959
diff
changeset
|
1953 if any((outg, revs, freeargs)): |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1954 raise error.InputError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
1955 _(b'only --commands argument allowed with --edit-plan') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1956 ) |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1957 else: |
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1958 if outg: |
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1959 if revs: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1960 raise error.InputError( |
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1961 _(b'no revisions allowed with --outgoing') |
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1962 ) |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1963 if len(freeargs) > 1: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1964 raise error.InputError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1965 _(b'only one repo argument allowed with --outgoing') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1966 ) |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1967 else: |
19021
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1968 revs.extend(freeargs) |
24009
00d331763442
histedit: allow configuring default behavior
Durham Goode <durham@fb.com>
parents:
24002
diff
changeset
|
1969 if len(revs) == 0: |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
1970 defaultrev = destutil.desthistedit(ui, repo) |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
1971 if defaultrev is not None: |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
1972 revs.append(defaultrev) |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27217
diff
changeset
|
1973 |
19021
26b41a902195
histedit: move outgoing processing to its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19020
diff
changeset
|
1974 if len(revs) != 1: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
1975 raise error.InputError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1976 _(b'histedit requires exactly one ancestor revision') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1977 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
1978 |
19020
12c06686d371
histedit: move all arguments checks to the beginning of the command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19018
diff
changeset
|
1979 |
44191
9b8e13a038db
histedit: py3 fixes for curses mode
Steve Fink <sfink@mozilla.com>
parents:
44000
diff
changeset
|
1980 def _histedit(ui, repo, state, freeargs, opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1981 fm = ui.formatter(b'histedit', opts) |
35147
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
1982 fm.startitem() |
28134
df206e030c59
histedit: break _histedit function into smaller pieces
Kostia Balytskyi <ikostia@fb.com>
parents:
28133
diff
changeset
|
1983 goal = _getgoal(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1984 revs = opts.get(b'rev', []) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1985 nobackup = not ui.configbool(b'rewrite', b'backup-bundle') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1986 rules = opts.get(b'commands', b'') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1987 state.keep = opts.get(b'keep', False) |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1988 |
48068
6256c7525222
histedit: remove redundant checks for unfinished histedit state
Martin von Zweigbergk <martinvonz@google.com>
parents:
47443
diff
changeset
|
1989 _validateargs(ui, repo, freeargs, opts, goal, rules, revs) |
22977
29ae3b190ec5
histedit: use state object where necessary
David Soria Parra <davidsp@fb.com>
parents:
22976
diff
changeset
|
1990 |
41106
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1991 hastags = False |
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1992 if revs: |
48128
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48069
diff
changeset
|
1993 revs = logcmdutil.revrange(repo, revs) |
41106
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1994 ctxs = [repo[rev] for rev in revs] |
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1995 for ctx in ctxs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1996 tags = [tag for tag in ctx.tags() if tag != b'tip'] |
41106
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1997 if not hastags: |
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1998 hastags = len(tags) |
86f0ed7ac688
histedit: add warning message on editing tagged commits (issue4017)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
40695
diff
changeset
|
1999 if hastags: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2000 if ui.promptchoice( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2001 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2002 b'warning: tags associated with the given' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2003 b' changeset will be lost after histedit.\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2004 b'do you want to continue (yN)? $$ &Yes $$ &No' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2005 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2006 default=1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2007 ): |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2008 raise error.CanceledError(_(b'histedit cancelled\n')) |
22977
29ae3b190ec5
histedit: use state object where necessary
David Soria Parra <davidsp@fb.com>
parents:
22976
diff
changeset
|
2009 # rebuild state |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
2010 if goal == goalcontinue: |
22983
a3a981563ce8
histedit: read state from histeditstate
David Soria Parra <davidsp@fb.com>
parents:
22982
diff
changeset
|
2011 state.read() |
22980
b3483bc1ec8c
histedit: pass state to boostrapcontinue
David Soria Parra <davidsp@fb.com>
parents:
22979
diff
changeset
|
2012 state = bootstrapcontinue(ui, state, opts) |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
2013 elif goal == goaleditplan: |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2014 _edithisteditplan(ui, repo, state, rules) |
24142
be7cb25186be
histedit: add --edit-plan option to histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24141
diff
changeset
|
2015 return |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
2016 elif goal == goalabort: |
38549
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2017 _aborthistedit(ui, repo, state, nobackup=nobackup) |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2018 return |
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2019 else: |
28144
ed6d650b7cb7
histedit: change string literals to constants in goal naming
Kostia Balytskyi <ikostia@fb.com>
parents:
28134
diff
changeset
|
2020 # goal == goalnew |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2021 _newhistedit(ui, repo, state, revs, freeargs, opts) |
24757
7b59f16174c5
histedit: store backup file before histedit
Durham Goode <durham@fb.com>
parents:
24756
diff
changeset
|
2022 |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2023 _continuehistedit(ui, repo, state) |
35147
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2024 _finishhistedit(ui, repo, state, fm) |
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2025 fm.end() |
28133
8fc55388ece5
histedit: break _histedit function into smaller pieces (add _continueaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28132
diff
changeset
|
2026 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2027 |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2028 def _continuehistedit(ui, repo, state): |
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2029 """This function runs after either: |
28133
8fc55388ece5
histedit: break _histedit function into smaller pieces (add _continueaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28132
diff
changeset
|
2030 - bootstrapcontinue (if the goal is 'continue') |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2031 - _newhistedit (if the goal is 'new') |
28133
8fc55388ece5
histedit: break _histedit function into smaller pieces (add _continueaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28132
diff
changeset
|
2032 """ |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
2033 # preprocess rules so that we can hide inner folds from the user |
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
2034 # and only show one editor |
27207
2d8dbeb2462c
histedit: change state.rules uses to state.actions
Mateusz Kwapich <mitrandir@fb.com>
parents:
27206
diff
changeset
|
2035 actions = state.actions[:] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2036 for idx, (action, nextact) in enumerate(zip(actions, actions[1:] + [None])): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2037 if action.verb == b'fold' and nextact and nextact.verb == b'fold': |
27207
2d8dbeb2462c
histedit: change state.rules uses to state.actions
Mateusz Kwapich <mitrandir@fb.com>
parents:
27206
diff
changeset
|
2038 state.actions[idx].__class__ = _multifold |
26246
bf81b696b8f4
histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
Augie Fackler <augie@google.com>
parents:
26203
diff
changeset
|
2039 |
31520
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2040 # Force an initial state file write, so the user can run --abort/continue |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2041 # even if there's an exception before the first transaction serialize. |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2042 state.write() |
33445
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2043 |
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2044 tr = None |
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2045 # Don't use singletransaction by default since it rolls the entire |
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2046 # transaction back if an unexpected exception happens (like a |
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2047 # pretxncommit hook throws, or the user aborts the commit msg editor). |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2048 if ui.configbool(b"histedit", b"singletransaction"): |
33445
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2049 # Don't use a 'with' for the transaction, since actions may close |
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2050 # and reopen a transaction. For example, if the action executes an |
0491004e2233
histedit: create transaction outside of try
Martin von Zweigbergk <martinvonz@google.com>
parents:
33444
diff
changeset
|
2051 # external process it may choose to commit the transaction first. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2052 tr = repo.transaction(b'histedit') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2053 progress = ui.makeprogress( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2054 _(b"editing"), unit=_(b'changes'), total=len(state.actions) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2055 ) |
38384
e5d87c69bbcb
histedit: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
37678
diff
changeset
|
2056 with progress, util.acceptintervention(tr): |
31520
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2057 while state.actions: |
33444
c4e39512a661
histedit: remove transaction from state object
Martin von Zweigbergk <martinvonz@google.com>
parents:
33351
diff
changeset
|
2058 state.write(tr=tr) |
31520
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2059 actobj = state.actions[0] |
38384
e5d87c69bbcb
histedit: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
37678
diff
changeset
|
2060 progress.increment(item=actobj.torule()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2061 ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2062 b'histedit: processing %s %s\n' % (actobj.verb, actobj.torule()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2063 ) |
31520
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2064 parentctx, replacement_ = actobj.run() |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2065 state.parentctxnode = parentctx.node() |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2066 state.replacements.extend(replacement_) |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2067 state.actions.pop(0) |
68474b72ea63
histedit: add histedit.singletransaction config option
Durham Goode <durham@fb.com>
parents:
31519
diff
changeset
|
2068 |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2069 state.write() |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2070 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2071 |
35147
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2072 def _finishhistedit(ui, repo, state, fm): |
28153
17c474fdb225
histedit: break _histedit into smaller pieces (add _finishaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28144
diff
changeset
|
2073 """This action runs when histedit is finishing its session""" |
45580
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45461
diff
changeset
|
2074 mergemod.update(repo[state.parentctxnode]) |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2075 |
22985
0c14b9166da6
histedit: remove now-superfluous repo argument from processreplacement
Augie Fackler <raf@durin42.com>
parents:
22984
diff
changeset
|
2076 mapping, tmpnodes, created, ntm = processreplacement(state) |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2077 if mapping: |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
2078 for prec, succs in pycompat.iteritems(mapping): |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2079 if not succs: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2080 ui.debug(b'histedit: %s is dropped\n' % short(prec)) |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2081 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2082 ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2083 b'histedit: %s is replaced by %s\n' |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2084 % (short(prec), short(succs[0])) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2085 ) |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2086 if len(succs) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2087 m = b'histedit: %s' |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2088 for n in succs[1:]: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2089 ui.debug(m % short(n)) |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2090 |
25330
8594d0b3018e
histedit: fix keep during --continue
Durham Goode <durham@fb.com>
parents:
24959
diff
changeset
|
2091 if not state.keep: |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2092 if mapping: |
33351
154298576d44
histedit: use scmutil.cleanupnodes (BC)
Jun Wu <quark@fb.com>
parents:
33350
diff
changeset
|
2093 movetopmostbookmarks(repo, state.topmost, ntm) |
17663
c6de8c696644
histedit: extract bookmark logic in a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17662
diff
changeset
|
2094 # TODO update mq state |
33350
b320ff822c7e
histedit: unify strip backup files on success (BC)
Jun Wu <quark@fb.com>
parents:
33349
diff
changeset
|
2095 else: |
b320ff822c7e
histedit: unify strip backup files on success (BC)
Jun Wu <quark@fb.com>
parents:
33349
diff
changeset
|
2096 mapping = {} |
b320ff822c7e
histedit: unify strip backup files on success (BC)
Jun Wu <quark@fb.com>
parents:
33349
diff
changeset
|
2097 |
b320ff822c7e
histedit: unify strip backup files on success (BC)
Jun Wu <quark@fb.com>
parents:
33349
diff
changeset
|
2098 for n in tmpnodes: |
39919
b153ca77a52b
histedit: don't cleanup nodes already disposed of
Boris Feld <boris.feld@octobus.net>
parents:
38826
diff
changeset
|
2099 if n in repo: |
b153ca77a52b
histedit: don't cleanup nodes already disposed of
Boris Feld <boris.feld@octobus.net>
parents:
38826
diff
changeset
|
2100 mapping[n] = () |
33350
b320ff822c7e
histedit: unify strip backup files on success (BC)
Jun Wu <quark@fb.com>
parents:
33349
diff
changeset
|
2101 |
33351
154298576d44
histedit: use scmutil.cleanupnodes (BC)
Jun Wu <quark@fb.com>
parents:
33350
diff
changeset
|
2102 # remove entries about unknown nodes |
43595
2b5d07702f94
index: use `index.has_node` in `histedit._finishhistedit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43554
diff
changeset
|
2103 has_node = repo.unfiltered().changelog.index.has_node |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2104 mapping = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2105 k: v |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2106 for k, v in mapping.items() |
43595
2b5d07702f94
index: use `index.has_node` in `histedit._finishhistedit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43554
diff
changeset
|
2107 if has_node(k) and all(has_node(n) for n in v) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2108 } |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2109 scmutil.cleanupnodes(repo, mapping, b'histedit') |
35147
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2110 hf = fm.hexfunc |
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2111 fl = fm.formatlist |
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2112 fd = fm.formatdict |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2113 nodechanges = fd( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2114 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2115 hf(oldn): fl([hf(n) for n in newn], name=b'node') |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
2116 for oldn, newn in pycompat.iteritems(mapping) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2117 }, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2118 key=b"oldnode", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2119 value=b"newnodes", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2120 ) |
35147
a9cc233de513
histedit: add support to output nodechanges using formatter
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35040
diff
changeset
|
2121 fm.data(nodechanges=nodechanges) |
25894
54f9561088c7
histedit: backout ebb5bb9bc32e
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25824
diff
changeset
|
2122 |
22978
d4e764521249
histedit: add clear method to remove state
David Soria Parra <davidsp@fb.com>
parents:
22977
diff
changeset
|
2123 state.clear() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2124 if os.path.exists(repo.sjoin(b'undo')): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2125 os.unlink(repo.sjoin(b'undo')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2126 if repo.vfs.exists(b'histedit-last-edit.txt'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2127 repo.vfs.unlink(b'histedit-last-edit.txt') |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2128 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2129 |
38549
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2130 def _aborthistedit(ui, repo, state, nobackup=False): |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2131 try: |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2132 state.read() |
28179
2e11f6756d9c
histedit: unifying the way replacements are computed for abort and success
Kostia Balytskyi <ikostia@fb.com>
parents:
28154
diff
changeset
|
2133 __, leafs, tmpnodes, __ = processreplacement(state) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2134 ui.debug(b'restore wc to old parent %s\n' % short(state.topmost)) |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2135 |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2136 # Recover our old commits if necessary |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2137 if not state.topmost in repo and state.backupfile: |
31338
6ce67d3941fc
histedit: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31076
diff
changeset
|
2138 backupfile = repo.vfs.join(state.backupfile) |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2139 f = hg.openpath(ui, backupfile) |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2140 gen = exchange.readbundle(ui, f, backupfile) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2141 with repo.transaction(b'histedit.abort') as tr: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2142 bundle2.applybundle( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2143 repo, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2144 gen, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2145 tr, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2146 source=b'histedit', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2147 url=b'bundle:' + backupfile, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2148 ) |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2149 |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2150 os.remove(backupfile) |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2151 |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2152 # check whether we should update away |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2153 if repo.unfiltered().revs( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2154 b'parents() and (%n or %ln::)', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2155 state.parentctxnode, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2156 leafs | tmpnodes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2157 ): |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2158 hg.clean(repo, state.topmost, show_stats=True, quietempty=True) |
38549
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2159 cleanupnode(ui, repo, tmpnodes, nobackup=nobackup) |
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2160 cleanupnode(ui, repo, leafs, nobackup=nobackup) |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2161 except Exception: |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2162 if state.inprogress(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2163 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2164 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2165 b'warning: encountered an exception during histedit ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2166 b'--abort; the repository may not have been completely ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2167 b'cleaned up\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2168 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2169 ) |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2170 raise |
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2171 finally: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2172 state.clear() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2173 |
28130
47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28123
diff
changeset
|
2174 |
42584
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2175 def hgaborthistedit(ui, repo): |
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2176 state = histeditstate(repo) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2177 nobackup = not ui.configbool(b'rewrite', b'backup-bundle') |
42584
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2178 with repo.wlock() as wlock, repo.lock() as lock: |
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2179 state.wlock = wlock |
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2180 state.lock = lock |
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2181 _aborthistedit(ui, repo, state, nobackup=nobackup) |
db5560c07a28
abort: added support for histedit
Taapas Agrawal <taapas2897@gmail.com>
parents:
42540
diff
changeset
|
2182 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2183 |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2184 def _edithisteditplan(ui, repo, state, rules): |
28131
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2185 state.read() |
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2186 if not rules: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2187 comment = geteditcomment( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2188 ui, short(state.parentctxnode), short(state.topmost) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2189 ) |
28131
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2190 rules = ruleeditor(repo, ui, state.actions, comment) |
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2191 else: |
30276
bc5d0e6fd9f3
histedit: use ui.fin to read commands from stdin
Yuya Nishihara <yuya@tcha.org>
parents:
30027
diff
changeset
|
2192 rules = _readfile(ui, rules) |
28131
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2193 actions = parserules(rules, state) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2194 ctxs = [repo[act.node] for act in state.actions if act.node] |
28131
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2195 warnverifyactions(ui, repo, actions, state, ctxs) |
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2196 state.actions = actions |
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2197 state.write() |
5a2fb2680a39
histedit: break _histedit function into smaller pieces (add _editplanaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28130
diff
changeset
|
2198 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2199 |
28154
47f56b6bfed1
histedit: renaming parts to which _histedit was split
Kostia Balytskyi <ikostia@fb.com>
parents:
28153
diff
changeset
|
2200 def _newhistedit(ui, repo, state, revs, freeargs, opts): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2201 outg = opts.get(b'outgoing') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2202 rules = opts.get(b'commands', b'') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2203 force = opts.get(b'force') |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2204 |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2205 cmdutil.checkunfinished(repo) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2206 cmdutil.bailifchanged(repo) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2207 |
41421
5cb8158a61f7
cleanup: use p1() instead of parents() when we only need the first parent
Martin von Zweigbergk <martinvonz@google.com>
parents:
41419
diff
changeset
|
2208 topmost = repo.dirstate.p1() |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2209 if outg: |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2210 if freeargs: |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2211 remote = freeargs[0] |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2212 else: |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2213 remote = None |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2214 root = findoutgoing(ui, repo, remote, force, opts) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2215 else: |
48128
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48069
diff
changeset
|
2216 rr = list(repo.set(b'roots(%ld)', logcmdutil.revrange(repo, revs))) |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2217 if len(rr) != 1: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2218 raise error.InputError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2219 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2220 b'The specified revisions must have ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2221 b'exactly one common root' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2222 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2223 ) |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2224 root = rr[0].node() |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2225 |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2226 revs = between(repo, root, topmost, state.keep) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2227 if not revs: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2228 raise error.InputError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2229 _(b'%s is not an ancestor of working directory') % short(root) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2230 ) |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2231 |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2232 ctxs = [repo[r] for r in revs] |
42979
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2233 |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2234 wctx = repo[None] |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2235 # Please don't ask me why `ancestors` is this value. I figured it |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2236 # out with print-debugging, not by actually understanding what the |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2237 # merge code is doing. :( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2238 ancs = [repo[b'.']] |
42979
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2239 # Sniff-test to make sure we won't collide with untracked files in |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2240 # the working directory. If we don't do this, we can get a |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2241 # collision after we've started histedit and backing out gets ugly |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2242 # for everyone, especially the user. |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2243 for c in [ctxs[0].p1()] + ctxs: |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2244 try: |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2245 mergemod.calculateupdates( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2246 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2247 wctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2248 c, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2249 ancs, |
42979
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2250 # These parameters were determined by print-debugging |
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2251 # what happens later on inside histedit. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2252 branchmerge=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2253 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2254 acceptremote=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2255 followcopies=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2256 ) |
42979
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2257 except error.Abort: |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2258 raise error.StateError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2259 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2260 b"untracked files in working directory conflict with files in %s" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2261 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2262 % c |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2263 ) |
42979
699102b10530
histedit: sniff-test for untracked file conflicts before prompting for rules
Augie Fackler <augie@google.com>
parents:
42650
diff
changeset
|
2264 |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2265 if not rules: |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2266 comment = geteditcomment(ui, short(root), short(topmost)) |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2267 actions = [pick(state, r) for r in revs] |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2268 rules = ruleeditor(repo, ui, actions, comment) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2269 else: |
30276
bc5d0e6fd9f3
histedit: use ui.fin to read commands from stdin
Yuya Nishihara <yuya@tcha.org>
parents:
30027
diff
changeset
|
2270 rules = _readfile(ui, rules) |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2271 actions = parserules(rules, state) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2272 warnverifyactions(ui, repo, actions, state, ctxs) |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2273 |
41419
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41223
diff
changeset
|
2274 parentctxnode = repo[root].p1().node() |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2275 |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2276 state.parentctxnode = parentctxnode |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2277 state.actions = actions |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2278 state.topmost = topmost |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2279 state.replacements = [] |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2280 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2281 ui.log( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2282 b"histedit", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2283 b"%d actions to histedit\n", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2284 len(actions), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2285 histedit_num_actions=len(actions), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2286 ) |
35494
784a85c87c22
histedit: add ui.log for action count
Phil Cohen <phillco@fb.com>
parents:
35421
diff
changeset
|
2287 |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2288 # Create a backup so we can always abort completely. |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2289 backupfile = None |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2290 if not obsolete.isenabled(repo, obsolete.createmarkersopt): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2291 backupfile = repair.backupbundle( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2292 repo, [parentctxnode], [topmost], root, b'histedit' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2293 ) |
28132
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2294 state.backupfile = backupfile |
2d09a400b495
histedit: break _histedit function into smaller pieces (add _newaction)
Kostia Balytskyi <ikostia@fb.com>
parents:
28131
diff
changeset
|
2295 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2296 |
29467
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2297 def _getsummary(ctx): |
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2298 # a common pattern is to extract the summary but default to the empty |
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2299 # string |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2300 summary = ctx.description() or b'' |
29467
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2301 if summary: |
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2302 summary = summary.splitlines()[0] |
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2303 return summary |
4c4232e51167
histedit: extract common summary code into method
Sean Farley <sean@farley.io>
parents:
29466
diff
changeset
|
2304 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2305 |
24774
a9d63d87b837
histedit: delete all non-actionclass related code
Durham Goode <durham@fb.com>
parents:
24773
diff
changeset
|
2306 def bootstrapcontinue(ui, state, opts): |
a9d63d87b837
histedit: delete all non-actionclass related code
Durham Goode <durham@fb.com>
parents:
24773
diff
changeset
|
2307 repo = state.repo |
32057
e5ffc91a2276
histedit: make check for unresolved conflicts explicit (issue5545)
Siddharth Agarwal <sid0@fb.com>
parents:
31643
diff
changeset
|
2308 |
44915
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44663
diff
changeset
|
2309 ms = mergestatemod.mergestate.read(repo) |
32057
e5ffc91a2276
histedit: make check for unresolved conflicts explicit (issue5545)
Siddharth Agarwal <sid0@fb.com>
parents:
31643
diff
changeset
|
2310 mergeutil.checkunresolved(ms) |
e5ffc91a2276
histedit: make check for unresolved conflicts explicit (issue5545)
Siddharth Agarwal <sid0@fb.com>
parents:
31643
diff
changeset
|
2311 |
27207
2d8dbeb2462c
histedit: change state.rules uses to state.actions
Mateusz Kwapich <mitrandir@fb.com>
parents:
27206
diff
changeset
|
2312 if state.actions: |
2d8dbeb2462c
histedit: change state.rules uses to state.actions
Mateusz Kwapich <mitrandir@fb.com>
parents:
27206
diff
changeset
|
2313 actobj = state.actions.pop(0) |
24959
3c762cceedde
histedit: fix --continue when rules are finished
Durham Goode <durham@fb.com>
parents:
24958
diff
changeset
|
2314 |
26981
cda2e980281e
histedit: extracts _isdirtywc function
liscju <piotr.listkiewicz@gmail.com>
parents:
26798
diff
changeset
|
2315 if _isdirtywc(repo): |
24959
3c762cceedde
histedit: fix --continue when rules are finished
Durham Goode <durham@fb.com>
parents:
24958
diff
changeset
|
2316 actobj.continuedirty() |
26981
cda2e980281e
histedit: extracts _isdirtywc function
liscju <piotr.listkiewicz@gmail.com>
parents:
26798
diff
changeset
|
2317 if _isdirtywc(repo): |
27084
383f10b67fd6
histedit: add abortdirty function
Mateusz Kwapich <mitrandir@fb.com>
parents:
27083
diff
changeset
|
2318 abortdirty() |
24766
cfb8f5e3ca49
histedit: integrate action class into flow
Durham Goode <durham@fb.com>
parents:
24765
diff
changeset
|
2319 |
24959
3c762cceedde
histedit: fix --continue when rules are finished
Durham Goode <durham@fb.com>
parents:
24958
diff
changeset
|
2320 parentctx, replacements = actobj.continueclean() |
17666
5b6c8f2fbda5
histedit: move `continue` logic into a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17665
diff
changeset
|
2321 |
24959
3c762cceedde
histedit: fix --continue when rules are finished
Durham Goode <durham@fb.com>
parents:
24958
diff
changeset
|
2322 state.parentctxnode = parentctx.node() |
3c762cceedde
histedit: fix --continue when rules are finished
Durham Goode <durham@fb.com>
parents:
24958
diff
changeset
|
2323 state.replacements.extend(replacements) |
22980
b3483bc1ec8c
histedit: pass state to boostrapcontinue
David Soria Parra <davidsp@fb.com>
parents:
22979
diff
changeset
|
2324 |
b3483bc1ec8c
histedit: pass state to boostrapcontinue
David Soria Parra <davidsp@fb.com>
parents:
22979
diff
changeset
|
2325 return state |
17666
5b6c8f2fbda5
histedit: move `continue` logic into a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17665
diff
changeset
|
2326 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2327 |
17642
bea381c16809
histedit: move `between function` outside the action logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17641
diff
changeset
|
2328 def between(repo, old, new, keep): |
bea381c16809
histedit: move `between function` outside the action logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17641
diff
changeset
|
2329 """select and validate the set of revision to edit |
bea381c16809
histedit: move `between function` outside the action logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17641
diff
changeset
|
2330 |
bea381c16809
histedit: move `between function` outside the action logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17641
diff
changeset
|
2331 When keep is false, the specified set can't have children.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2332 revs = repo.revs(b'%n::%n', old, new) |
36443
f493829b74dd
histedit: use repo.revs() instead of repo.set() where revisions are needed
Yuya Nishihara <yuya@tcha.org>
parents:
36439
diff
changeset
|
2333 if revs and not keep: |
43939
bde97bee321f
histedit: use rewriteutil.precheck() instead of reimplementing it
Martin von Zweigbergk <martinvonz@google.com>
parents:
43811
diff
changeset
|
2334 rewriteutil.precheck(repo, revs, b'edit') |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2335 if repo.revs(b'(%ld) and merge()', revs): |
48069
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2336 raise error.StateError( |
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2337 _(b'cannot edit history that contains merges') |
f27a83399abb
histedit: use more specific exceptions for more detailed exit codes
Martin von Zweigbergk <martinvonz@google.com>
parents:
48068
diff
changeset
|
2338 ) |
36443
f493829b74dd
histedit: use repo.revs() instead of repo.set() where revisions are needed
Yuya Nishihara <yuya@tcha.org>
parents:
36439
diff
changeset
|
2339 return pycompat.maplist(repo.changelog.node, revs) |
17642
bea381c16809
histedit: move `between function` outside the action logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17641
diff
changeset
|
2340 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2341 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2342 def ruleeditor(repo, ui, actions, editcomment=b""): |
24140
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2343 """open an editor to edit rules |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2344 |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2345 rules are in the format [ [act, ctx], ...] like in state.rules |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2346 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2347 if repo.ui.configbool(b"experimental", b"histedit.autoverb"): |
29470
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2348 newact = util.sortdict() |
29465
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2349 for act in actions: |
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2350 ctx = repo[act.node] |
29469
ffa194c3a83c
histedit: use _getsummary in ruleeditor
Sean Farley <sean@farley.io>
parents:
29468
diff
changeset
|
2351 summary = _getsummary(ctx) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2352 fword = summary.split(b' ', 1)[0].lower() |
29470
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2353 added = False |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2354 |
29465
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2355 # if it doesn't end with the special character '!' just skip this |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2356 if fword.endswith(b'!'): |
29465
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2357 fword = fword[:-1] |
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2358 if fword in primaryactions | secondaryactions | tertiaryactions: |
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2359 act.verb = fword |
29470
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2360 # get the target summary |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2361 tsum = summary[len(fword) + 1 :].lstrip() |
29470
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2362 # safe but slow: reverse iterate over the actions so we |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2363 # don't clash on two commits having the same summary |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
2364 for na, l in reversed(list(pycompat.iteritems(newact))): |
29470
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2365 actx = repo[na.node] |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2366 asum = _getsummary(actx) |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2367 if asum == tsum: |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2368 added = True |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2369 l.append(act) |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2370 break |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2371 |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2372 if not added: |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2373 newact[act] = [] |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2374 |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2375 # copy over and flatten the new list |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2376 actions = [] |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
2377 for na, l in pycompat.iteritems(newact): |
29470
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2378 actions.append(na) |
2ff243c415b4
histedit: move autoverb rule to the commit it matches
Sean Farley <sean@farley.io>
parents:
29469
diff
changeset
|
2379 actions += l |
29465
00d2bf4137e6
histedit: move autoverb logic from torule to ruleeditor
Sean Farley <sean@farley.io>
parents:
29324
diff
changeset
|
2380 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2381 rules = b'\n'.join([act.torule() for act in actions]) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2382 rules += b'\n\n' |
24140
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2383 rules += editcomment |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2384 rules = ui.edit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2385 rules, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2386 ui.username(), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2387 {b'prefix': b'histedit'}, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2388 repopath=repo.path, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2389 action=b'histedit', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2390 ) |
24140
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2391 |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2392 # Save edit rules in .hg/histedit-last-edit.txt in case |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2393 # the user needs to ask for help after something |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2394 # surprising happens. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2395 with repo.vfs(b'histedit-last-edit.txt', b'wb') as f: |
36206
be73fa5b42d3
histedit: modernize write of histedit-last-edit file
Augie Fackler <augie@google.com>
parents:
36205
diff
changeset
|
2396 f.write(rules) |
24140
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2397 |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2398 return rules |
5a64b676c5d3
histedit: extract method ruleeditor
Mateusz Kwapich <mitrandir@fb.com>
parents:
24131
diff
changeset
|
2399 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2400 |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2401 def parserules(rules, state): |
47031
f38bf44e077f
black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents:
46941
diff
changeset
|
2402 """Read the histedit rules string and return list of action objects""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2403 rules = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2404 l |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2405 for l in (r.strip() for r in rules.splitlines()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2406 if l and not l.startswith(b'#') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2407 ] |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2408 actions = [] |
17064
168cc52ad7c2
histedit: new extension for interactive history editing
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2409 for r in rules: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2410 if b' ' not in r: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2411 raise error.ParseError(_(b'malformed line "%s"') % r) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2412 verb, rest = r.split(b' ', 1) |
27082
4898e442f392
histedit: make verification configurable
Mateusz Kwapich <mitrandir@fb.com>
parents:
27051
diff
changeset
|
2413 |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2414 if verb not in actiontable: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2415 raise error.ParseError(_(b'unknown action "%s"') % verb) |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2416 |
27082
4898e442f392
histedit: make verification configurable
Mateusz Kwapich <mitrandir@fb.com>
parents:
27051
diff
changeset
|
2417 action = actiontable[verb].fromrule(state, rest) |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2418 actions.append(action) |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2419 return actions |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2420 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2421 |
27543
ff0e4c8e642d
histedit: limit mentioning histedit-last-edit.txt
timeless <timeless@mozdev.org>
parents:
27542
diff
changeset
|
2422 def warnverifyactions(ui, repo, actions, state, ctxs): |
ff0e4c8e642d
histedit: limit mentioning histedit-last-edit.txt
timeless <timeless@mozdev.org>
parents:
27542
diff
changeset
|
2423 try: |
ff0e4c8e642d
histedit: limit mentioning histedit-last-edit.txt
timeless <timeless@mozdev.org>
parents:
27542
diff
changeset
|
2424 verifyactions(actions, state, ctxs) |
27545
a67d2e059a51
histedit: use parse-error exception for parsing
timeless <timeless@mozdev.org>
parents:
27543
diff
changeset
|
2425 except error.ParseError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2426 if repo.vfs.exists(b'histedit-last-edit.txt'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2427 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2428 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2429 b'warning: histedit rules saved ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2430 b'to: .hg/histedit-last-edit.txt\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2431 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2432 ) |
27543
ff0e4c8e642d
histedit: limit mentioning histedit-last-edit.txt
timeless <timeless@mozdev.org>
parents:
27542
diff
changeset
|
2433 raise |
ff0e4c8e642d
histedit: limit mentioning histedit-last-edit.txt
timeless <timeless@mozdev.org>
parents:
27542
diff
changeset
|
2434 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2435 |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2436 def verifyactions(actions, state, ctxs): |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2437 """Verify that there exists exactly one action per given changeset and |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2438 other constraints. |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2439 |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2440 Will abort if there are to many or too few rules, a malformed rule, |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2441 or a rule on a changeset outside of the user-given range. |
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2442 """ |
44470
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44461
diff
changeset
|
2443 expected = {c.node() for c in ctxs} |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2444 seen = set() |
27541
69df2081aeb5
histedit: pass previous action to verify
timeless <timeless@mozdev.org>
parents:
27534
diff
changeset
|
2445 prev = None |
33783
c26a76e1af36
histedit: check first changeset for verb "roll" or "fold" (issue5498)
André Klitzing <aklitzing@gmail.com>
parents:
33486
diff
changeset
|
2446 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2447 if actions and actions[0].verb in [b'roll', b'fold']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2448 raise error.ParseError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2449 _(b'first changeset cannot use verb "%s"') % actions[0].verb |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2450 ) |
33783
c26a76e1af36
histedit: check first changeset for verb "roll" or "fold" (issue5498)
André Klitzing <aklitzing@gmail.com>
parents:
33486
diff
changeset
|
2451 |
27208
994d8dced775
histedit: get rid of state.rules
Mateusz Kwapich <mitrandir@fb.com>
parents:
27207
diff
changeset
|
2452 for action in actions: |
29883
b566c5992e07
histedit: move constraint verification to the 'action.verify' method
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29882
diff
changeset
|
2453 action.verify(prev, expected, seen) |
27541
69df2081aeb5
histedit: pass previous action to verify
timeless <timeless@mozdev.org>
parents:
27534
diff
changeset
|
2454 prev = action |
29880
034d38b5f6fb
histedit: drop the 'nodetoverify' local variable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29879
diff
changeset
|
2455 if action.node is not None: |
29882
d7de02efa47e
histedit: directly use node in 'verifyactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29881
diff
changeset
|
2456 seen.add(action.node) |
19048
1163ff06ce89
histedit: more precise user message when changeset is missing
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19047
diff
changeset
|
2457 missing = sorted(expected - seen) # sort to stabilize output |
27414
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
2458 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2459 if state.repo.ui.configbool(b'histedit', b'dropmissing'): |
28519
518a5030acba
histedit: have dropmissing abort on empty plan
Mateusz Kwapich <mitrandir@fb.com>
parents:
28396
diff
changeset
|
2460 if len(actions) == 0: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2461 raise error.ParseError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2462 _(b'no rules provided'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2463 hint=_(b'use strip extension to remove commits'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2464 ) |
28519
518a5030acba
histedit: have dropmissing abort on empty plan
Mateusz Kwapich <mitrandir@fb.com>
parents:
28396
diff
changeset
|
2465 |
29882
d7de02efa47e
histedit: directly use node in 'verifyactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29881
diff
changeset
|
2466 drops = [drop(state, n) for n in missing] |
27414
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
2467 # put the in the beginning so they execute immediately and |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
2468 # don't show in the edit-plan in the future |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
2469 actions[:0] = drops |
6602a7b9deec
histedit: delete to drop
Mateusz Kwapich <mitrandir@fb.com>
parents:
27407
diff
changeset
|
2470 elif missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2471 raise error.ParseError( |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2472 _(b'missing rules for changeset %s') % short(missing[0]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2473 hint=_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2474 b'use "drop %s" to discard, see also: ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2475 b"'hg help -e histedit.config'" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2476 ) |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2477 % short(missing[0]), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2478 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2479 |
17663
c6de8c696644
histedit: extract bookmark logic in a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17662
diff
changeset
|
2480 |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2481 def adjustreplacementsfrommarkers(repo, oldreplacements): |
30342
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30276
diff
changeset
|
2482 """Adjust replacements from obsolescence markers |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2483 |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2484 Replacements structure is originally generated based on |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2485 histedit's state and does not account for changes that are |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2486 not recorded there. This function fixes that by adding |
30342
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30276
diff
changeset
|
2487 data read from obsolescence markers""" |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2488 if not obsolete.isenabled(repo, obsolete.createmarkersopt): |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2489 return oldreplacements |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2490 |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2491 unfi = repo.unfiltered() |
43616
418ca164d44c
index: use `index.get_rev` in `histedit.adjustreplacementsfrommarkers`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43596
diff
changeset
|
2492 get_rev = unfi.changelog.index.get_rev |
28224
8ec5478aa0d6
histedit: also handle locally missing nodes when reading obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28216
diff
changeset
|
2493 obsstore = repo.obsstore |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2494 newreplacements = list(oldreplacements) |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2495 oldsuccs = [r[1] for r in oldreplacements] |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2496 # successors that have already been added to succstocheck once |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2497 seensuccs = set().union( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2498 *oldsuccs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2499 ) # create a set from an iterable of tuples |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2500 succstocheck = list(seensuccs) |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2501 while succstocheck: |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2502 n = succstocheck.pop() |
43616
418ca164d44c
index: use `index.get_rev` in `histedit.adjustreplacementsfrommarkers`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43596
diff
changeset
|
2503 missing = get_rev(n) is None |
28224
8ec5478aa0d6
histedit: also handle locally missing nodes when reading obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28216
diff
changeset
|
2504 markers = obsstore.successors.get(n, ()) |
8ec5478aa0d6
histedit: also handle locally missing nodes when reading obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28216
diff
changeset
|
2505 if missing and not markers: |
8ec5478aa0d6
histedit: also handle locally missing nodes when reading obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28216
diff
changeset
|
2506 # dead end, mark it as such |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2507 newreplacements.append((n, ())) |
28224
8ec5478aa0d6
histedit: also handle locally missing nodes when reading obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28216
diff
changeset
|
2508 for marker in markers: |
8ec5478aa0d6
histedit: also handle locally missing nodes when reading obsolescence
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28216
diff
changeset
|
2509 nsuccs = marker[1] |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2510 newreplacements.append((n, nsuccs)) |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2511 for nsucc in nsuccs: |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2512 if nsucc not in seensuccs: |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2513 seensuccs.add(nsucc) |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2514 succstocheck.append(nsucc) |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2515 |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2516 return newreplacements |
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2517 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2518 |
22985
0c14b9166da6
histedit: remove now-superfluous repo argument from processreplacement
Augie Fackler <raf@durin42.com>
parents:
22984
diff
changeset
|
2519 def processreplacement(state): |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2520 """process the list of replacements to return |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2521 |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2522 1) the final mapping between original and created nodes |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2523 2) the list of temporary node created by histedit |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2524 3) the list of new commit created by histedit""" |
28216
eed7d8c07c20
histedit: make histedit aware of obsolescense not stored in state (issue4800)
Kostia Balytskyi <ikostia@fb.com>
parents:
28179
diff
changeset
|
2525 replacements = adjustreplacementsfrommarkers(state.repo, state.replacements) |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2526 allsuccs = set() |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2527 replaced = set() |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2528 fullmapping = {} |
26039
84dcc37b1272
histedit: correct spelling etc in more comments
Augie Fackler <augie@google.com>
parents:
26038
diff
changeset
|
2529 # initialize basic set |
84dcc37b1272
histedit: correct spelling etc in more comments
Augie Fackler <augie@google.com>
parents:
26038
diff
changeset
|
2530 # fullmapping records all operations recorded in replacement |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2531 for rep in replacements: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2532 allsuccs.update(rep[1]) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2533 replaced.add(rep[0]) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2534 fullmapping.setdefault(rep[0], set()).update(rep[1]) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2535 new = allsuccs - replaced |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2536 tmpnodes = allsuccs & replaced |
26039
84dcc37b1272
histedit: correct spelling etc in more comments
Augie Fackler <augie@google.com>
parents:
26038
diff
changeset
|
2537 # Reduce content fullmapping into direct relation between original nodes |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2538 # and final node created during history edition |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2539 # Dropped changeset are replaced by an empty list |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2540 toproceed = set(fullmapping) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2541 final = {} |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2542 while toproceed: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2543 for x in list(toproceed): |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2544 succs = fullmapping[x] |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2545 for s in list(succs): |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2546 if s in toproceed: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2547 # non final node with unknown closure |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2548 # We can't process this now |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2549 break |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2550 elif s in final: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2551 # non final node, replace with closure |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2552 succs.remove(s) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2553 succs.update(final[s]) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2554 else: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2555 final[x] = succs |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2556 toproceed.remove(x) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2557 # remove tmpnodes from final mapping |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2558 for n in tmpnodes: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2559 del final[n] |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2560 # we expect all changes involved in final to exist in the repo |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2561 # turn `final` into list (topologically sorted) |
43617
43e722fc2909
index: use `index.get_rev` in `histedit.processreplacement`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43616
diff
changeset
|
2562 get_rev = state.repo.changelog.index.get_rev |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2563 for prec, succs in final.items(): |
43617
43e722fc2909
index: use `index.get_rev` in `histedit.processreplacement`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43616
diff
changeset
|
2564 final[prec] = sorted(succs, key=get_rev) |
17663
c6de8c696644
histedit: extract bookmark logic in a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17662
diff
changeset
|
2565 |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2566 # computed topmost element (necessary for bookmark) |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2567 if new: |
22985
0c14b9166da6
histedit: remove now-superfluous repo argument from processreplacement
Augie Fackler <raf@durin42.com>
parents:
22984
diff
changeset
|
2568 newtopmost = sorted(new, key=state.repo.changelog.rev)[-1] |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2569 elif not final: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2570 # Nothing rewritten at all. we won't need `newtopmost` |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2571 # It is the same as `oldtopmost` and `processreplacement` know it |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2572 newtopmost = None |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2573 else: |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2574 # every body died. The newtopmost is the parent of the root. |
22985
0c14b9166da6
histedit: remove now-superfluous repo argument from processreplacement
Augie Fackler <raf@durin42.com>
parents:
22984
diff
changeset
|
2575 r = state.repo.changelog.rev |
0c14b9166da6
histedit: remove now-superfluous repo argument from processreplacement
Augie Fackler <raf@durin42.com>
parents:
22984
diff
changeset
|
2576 newtopmost = state.repo[sorted(final, key=r)[0]].p1().node() |
17758
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2577 |
5863f0e4cd3a
histedit: replace various nodes lists with replacement graph (and issue3582)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17757
diff
changeset
|
2578 return final, tmpnodes, new, newtopmost |
17663
c6de8c696644
histedit: extract bookmark logic in a dedicated function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17662
diff
changeset
|
2579 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2580 |
33346
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2581 def movetopmostbookmarks(repo, oldtopmost, newtopmost): |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2582 """Move bookmark from oldtopmost to newly created topmost |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2583 |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2584 This is arguably a feature and we may only want that for the active |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2585 bookmark. But the behavior is kept compatible with the old version for now. |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2586 """ |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2587 if not oldtopmost or not newtopmost: |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2588 return |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2589 oldbmarks = repo.nodebookmarks(oldtopmost) |
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2590 if oldbmarks: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2591 with repo.lock(), repo.transaction(b'histedit') as tr: |
33346
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2592 marks = repo._bookmarks |
33486
af402f11cb9d
bookmark: use 'applychanges' when updating bookmark in histedit
Boris Feld <boris.feld@octobus.net>
parents:
33446
diff
changeset
|
2593 changes = [] |
33346
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2594 for name in oldbmarks: |
33486
af402f11cb9d
bookmark: use 'applychanges' when updating bookmark in histedit
Boris Feld <boris.feld@octobus.net>
parents:
33446
diff
changeset
|
2595 changes.append((name, newtopmost)) |
af402f11cb9d
bookmark: use 'applychanges' when updating bookmark in histedit
Boris Feld <boris.feld@octobus.net>
parents:
33446
diff
changeset
|
2596 marks.applychanges(repo, tr, changes) |
33346
7aa5160bdbf5
histedit: move topmost bookmark movement to a separate function
Jun Wu <quark@fb.com>
parents:
33345
diff
changeset
|
2597 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2598 |
38549
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2599 def cleanupnode(ui, repo, nodes, nobackup=False): |
31642
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2600 """strip a group of nodes from the repository |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2601 |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2602 The set of node to strip may contains unknown nodes.""" |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2603 with repo.lock(): |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2604 # do not let filtering get in the way of the cleanse |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2605 # we should probably get rid of obsolescence marker created during the |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2606 # histedit, but we currently do not have such information. |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2607 repo = repo.unfiltered() |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2608 # Find all nodes that need to be stripped |
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2609 # (we use %lr instead of %ln to silently ignore unknown items) |
43596
ccda03f6abcb
index: use `index.has_node` in `histedit.cleanupnode`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43595
diff
changeset
|
2610 has_node = repo.changelog.index.has_node |
ccda03f6abcb
index: use `index.has_node` in `histedit.cleanupnode`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43595
diff
changeset
|
2611 nodes = sorted(n for n in nodes if has_node(n)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2612 roots = [c.node() for c in repo.set(b"roots(%ln)", nodes)] |
33349
28f75a1695fb
histedit: pass multiple nodes to strip (BC)
Jun Wu <quark@fb.com>
parents:
33348
diff
changeset
|
2613 if roots: |
38549
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2614 backup = not nobackup |
7b57b1ed5c0f
histedit: add --no-backup option (issue5825)
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38512
diff
changeset
|
2615 repair.strip(ui, repo, roots, backup=backup) |
31642
c4dd1e7c1dab
histedit: backout changeset 2b599f5468a4
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31534
diff
changeset
|
2616 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2617 |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2618 def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): |
43449
40db695040eb
histedit: fix an `isinstance(nodelist, str)` check for py3
Matt Harbison <matt_harbison@yahoo.com>
parents:
43376
diff
changeset
|
2619 if isinstance(nodelist, bytes): |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2620 nodelist = [nodelist] |
38826
28d8b5f49b4d
histedit: avoid repeating name of state file in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
38823
diff
changeset
|
2621 state = histeditstate(repo) |
28d8b5f49b4d
histedit: avoid repeating name of state file in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
38823
diff
changeset
|
2622 if state.inprogress(): |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2623 state.read() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2624 histedit_nodes = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2625 action.node for action in state.actions if action.node |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2626 } |
30027
4d9999e43ff7
histedit: avoid converting nodeid to context and back again
Martin von Zweigbergk <martinvonz@google.com>
parents:
29974
diff
changeset
|
2627 common_nodes = histedit_nodes & set(nodelist) |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2628 if common_nodes: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2629 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2630 _(b"histedit in progress, can't strip %s") |
46114
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
46105
diff
changeset
|
2631 % b', '.join(short(x) for x in common_nodes) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2632 ) |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2633 return orig(ui, repo, nodelist, *args, **kwargs) |
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2634 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2635 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2636 extensions.wrapfunction(repair, b'strip', stripwrapper) |
24111
11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
Mateusz Kwapich <mitrandir@fb.com>
parents:
24009
diff
changeset
|
2637 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2638 |
19215
f184fe1e2ac5
summary: add a histedit hook
Bryan O'Sullivan <bryano@fb.com>
parents:
19048
diff
changeset
|
2639 def summaryhook(ui, repo): |
38826
28d8b5f49b4d
histedit: avoid repeating name of state file in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
38823
diff
changeset
|
2640 state = histeditstate(repo) |
28d8b5f49b4d
histedit: avoid repeating name of state file in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
38823
diff
changeset
|
2641 if not state.inprogress(): |
19215
f184fe1e2ac5
summary: add a histedit hook
Bryan O'Sullivan <bryano@fb.com>
parents:
19048
diff
changeset
|
2642 return |
22983
a3a981563ce8
histedit: read state from histeditstate
David Soria Parra <davidsp@fb.com>
parents:
22982
diff
changeset
|
2643 state.read() |
27207
2d8dbeb2462c
histedit: change state.rules uses to state.actions
Mateusz Kwapich <mitrandir@fb.com>
parents:
27206
diff
changeset
|
2644 if state.actions: |
19215
f184fe1e2ac5
summary: add a histedit hook
Bryan O'Sullivan <bryano@fb.com>
parents:
19048
diff
changeset
|
2645 # i18n: column positioning for "hg summary" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2646 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2647 _(b'hist: %s (histedit --continue)\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2648 % ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2649 ui.label(_(b'%d remaining'), b'histedit.remaining') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2650 % len(state.actions) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2651 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2652 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2653 |
19215
f184fe1e2ac5
summary: add a histedit hook
Bryan O'Sullivan <bryano@fb.com>
parents:
19048
diff
changeset
|
2654 |
f184fe1e2ac5
summary: add a histedit hook
Bryan O'Sullivan <bryano@fb.com>
parents:
19048
diff
changeset
|
2655 def extsetup(ui): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2656 cmdutil.summaryhooks.add(b'histedit', summaryhook) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2657 statemod.addunfinished( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2658 b'histedit', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2659 fname=b'histedit-state', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2660 allowcommit=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2661 continueflag=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2662 abortfunc=hgaborthistedit, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42981
diff
changeset
|
2663 ) |