Show More
@@ -4,10 +4,142 b'' | |||||
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
""" |
|
7 | """interactive history editing | |
|
8 | ||||
|
9 | With this extension installed, Mercurial gains one new command: histedit. Usage | |||
|
10 | is as follows, assuming the following history:: | |||
|
11 | ||||
|
12 | @ 3[tip] 7c2fd3b9020c 2009-04-27 18:04 -0500 durin42 | |||
|
13 | | Add delta | |||
|
14 | | | |||
|
15 | o 2 030b686bedc4 2009-04-27 18:04 -0500 durin42 | |||
|
16 | | Add gamma | |||
|
17 | | | |||
|
18 | o 1 c561b4e977df 2009-04-27 18:04 -0500 durin42 | |||
|
19 | | Add beta | |||
|
20 | | | |||
|
21 | o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 | |||
|
22 | Add alpha | |||
|
23 | ||||
|
24 | If you were to run ``hg histedit c561b4e977df``, you would see the following | |||
|
25 | file open in your editor:: | |||
|
26 | ||||
|
27 | pick c561b4e977df Add beta | |||
|
28 | pick 030b686bedc4 Add gamma | |||
|
29 | pick 7c2fd3b9020c Add delta | |||
|
30 | ||||
|
31 | # Edit history between 633536316234 and 7c2fd3b9020c | |||
|
32 | # | |||
|
33 | # Commands: | |||
|
34 | # p, pick = use commit | |||
|
35 | # e, edit = use commit, but stop for amending | |||
|
36 | # f, fold = use commit, but fold into previous commit | |||
|
37 | # d, drop = remove commit from history | |||
|
38 | # m, mess = edit message without changing commit content | |||
|
39 | # | |||
|
40 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
41 | ||||
|
42 | In this file, lines beginning with ``#`` are ignored. You must specify a rule | |||
|
43 | for each revision in your history. For example, if you had meant to add gamma | |||
|
44 | before beta, and then wanted to add delta in the same revision as beta, you | |||
|
45 | would reorganize the file to look like this:: | |||
|
46 | ||||
|
47 | pick 030b686bedc4 Add gamma | |||
|
48 | pick c561b4e977df Add beta | |||
|
49 | fold 7c2fd3b9020c Add delta | |||
|
50 | ||||
|
51 | # Edit history between 633536316234 and 7c2fd3b9020c | |||
|
52 | # | |||
|
53 | # Commands: | |||
|
54 | # p, pick = use commit | |||
|
55 | # e, edit = use commit, but stop for amending | |||
|
56 | # f, fold = use commit, but fold into previous commit | |||
|
57 | # d, drop = remove commit from history | |||
|
58 | # m, mess = edit message without changing commit content | |||
|
59 | # | |||
|
60 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
61 | ||||
|
62 | At which point you close the editor and ``histedit`` starts working. When you | |||
|
63 | specify a ``fold`` operation, ``histedit`` will open an editor when it folds | |||
|
64 | those revisions together, offering you a chance to clean up the commit message:: | |||
|
65 | ||||
|
66 | Add beta | |||
|
67 | *** | |||
|
68 | Add delta | |||
8 |
|
69 | |||
9 | Inspired by git rebase --interactive. |
|
70 | Edit the commit message to your liking, then close the editor. For | |
|
71 | this example, let's assume that the commit message was changed to | |||
|
72 | ``Add beta and delta.`` After histedit has run and had a chance to | |||
|
73 | remove any old or temporary revisions it needed, the history looks | |||
|
74 | like this:: | |||
|
75 | ||||
|
76 | @ 2[tip] 989b4d060121 2009-04-27 18:04 -0500 durin42 | |||
|
77 | | Add beta and delta. | |||
|
78 | | | |||
|
79 | o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 | |||
|
80 | | Add gamma | |||
|
81 | | | |||
|
82 | o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 | |||
|
83 | Add alpha | |||
|
84 | ||||
|
85 | Note that ``histedit`` does *not* remove any revisions (even its own temporary | |||
|
86 | ones) until after it has completed all the editing operations, so it will | |||
|
87 | probably perform several strip operations when it's done. For the above example, | |||
|
88 | it had to run strip twice. Strip can be slow depending on a variety of factors, | |||
|
89 | so you might need to be a little patient. You can choose to keep the original | |||
|
90 | revisions by passing the ``--keep`` flag. | |||
|
91 | ||||
|
92 | The ``edit`` operation will drop you back to a command prompt, | |||
|
93 | allowing you to edit files freely, or even use ``hg record`` to commit | |||
|
94 | some changes as a separate commit. When you're done, any remaining | |||
|
95 | uncommitted changes will be committed as well. When done, run ``hg | |||
|
96 | histedit --continue`` to finish this step. You'll be prompted for a | |||
|
97 | new commit message, but the default commit message will be the | |||
|
98 | original message for the ``edit`` ed revision. | |||
|
99 | ||||
|
100 | The ``message`` operation will give you a chance to revise a commit | |||
|
101 | message without changing the contents. It's a shortcut for doing | |||
|
102 | ``edit`` immediately followed by `hg histedit --continue``. | |||
|
103 | ||||
|
104 | If ``histedit`` encounters a conflict when moving a revision (while | |||
|
105 | handling ``pick`` or ``fold``), it'll stop in a similar manner to | |||
|
106 | ``edit`` with the difference that it won't prompt you for a commit | |||
|
107 | message when done. If you decide at this point that you don't like how | |||
|
108 | much work it will be to rearrange history, or that you made a mistake, | |||
|
109 | you can use ``hg histedit --abort`` to abandon the new changes you | |||
|
110 | have made and return to the state before you attempted to edit your | |||
|
111 | history. | |||
|
112 | ||||
|
113 | If we clone the example repository above and add three more changes, such that | |||
|
114 | we have the following history:: | |||
|
115 | ||||
|
116 | @ 6[tip] 038383181893 2009-04-27 18:04 -0500 stefan | |||
|
117 | | Add theta | |||
|
118 | | | |||
|
119 | o 5 140988835471 2009-04-27 18:04 -0500 stefan | |||
|
120 | | Add eta | |||
|
121 | | | |||
|
122 | o 4 122930637314 2009-04-27 18:04 -0500 stefan | |||
|
123 | | Add zeta | |||
|
124 | | | |||
|
125 | o 3 836302820282 2009-04-27 18:04 -0500 stefan | |||
|
126 | | Add epsilon | |||
|
127 | | | |||
|
128 | o 2 989b4d060121 2009-04-27 18:04 -0500 durin42 | |||
|
129 | | Add beta and delta. | |||
|
130 | | | |||
|
131 | o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 | |||
|
132 | | Add gamma | |||
|
133 | | | |||
|
134 | o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 | |||
|
135 | Add alpha | |||
|
136 | ||||
|
137 | If you run ``hg histedit --outgoing`` on the clone then it is the same | |||
|
138 | as running ``hg histedit 836302820282``. If you need plan to push to a | |||
|
139 | repository that Mercurial does not detect to be related to the source | |||
|
140 | repo, you can add a ``--force`` option. | |||
10 | """ |
|
141 | """ | |
|
142 | ||||
11 | try: |
|
143 | try: | |
12 | import cPickle as pickle |
|
144 | import cPickle as pickle | |
13 | except ImportError: |
|
145 | except ImportError: | |
@@ -243,7 +375,7 b" actiontable = {'p': pick," | |||||
243 | 'mess': message, |
|
375 | 'mess': message, | |
244 | } |
|
376 | } | |
245 | def histedit(ui, repo, *parent, **opts): |
|
377 | def histedit(ui, repo, *parent, **opts): | |
246 | """hg histedit <parent> |
|
378 | """interactively edit changeset history | |
247 | """ |
|
379 | """ | |
248 | # TODO only abort if we try and histedit mq patches, not just |
|
380 | # TODO only abort if we try and histedit mq patches, not just | |
249 | # blanket if mq patches are applied somewhere |
|
381 | # blanket if mq patches are applied somewhere | |
@@ -561,6 +693,6 b' cmdtable = {' | |||||
561 | 'force outgoing even for unrelated repositories')), |
|
693 | 'force outgoing even for unrelated repositories')), | |
562 | ('r', 'rev', [], _('first revision to be edited')), |
|
694 | ('r', 'rev', [], _('first revision to be edited')), | |
563 | ], |
|
695 | ], | |
564 | __doc__, |
|
696 | _("[PARENT]"), | |
565 | ), |
|
697 | ), | |
566 | } |
|
698 | } |
General Comments 0
You need to be logged in to leave comments.
Login now