##// END OF EJS Templates
debugbuilddag: build a changelog dag from a concise description...
Peter Arrenbrecht -
r11337:0f3c8a47 default
parent child Browse files
Show More
@@ -0,0 +1,70 b''
1 #! /bin/sh
2
3 echo "[extensions]" >> $HGRCPATH
4 echo "graphlog=" >> $HGRCPATH
5
6
7
8 echo ---- overwritten and appended files
9
10 rm -rf repo
11 hg init repo
12 cd repo
13 hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -oa
14 echo -- dag
15 hg debugdag -t -b
16 echo -- glog
17 hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
18 echo -- glog of
19 hg glog --template '{rev}: {desc} [{branches}]\n' of
20 echo -- glog af
21 hg glog --template '{rev}: {desc} [{branches}]\n' af
22 echo -- tags
23 hg tags -v
24 echo -- cat of
25 hg cat of
26 echo -- cat af
27 hg cat af
28 cd ..
29
30 echo ---- new and mergeable files
31
32 rm -rf repo
33 hg init repo
34 cd repo
35 hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -mn
36 echo -- dag
37 hg debugdag -t -b
38 echo -- glog
39 hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
40 echo -- glog mf
41 hg glog --template '{rev}: {desc} [{branches}]\n' mf
42
43 echo -- man r4
44 hg manifest -r4
45 echo -- cat r4 mf
46 hg cat -r4 mf
47 echo -- man r8
48 hg manifest -r8
49 echo -- cat r8 mf
50 hg cat -r8 mf
51 echo -- man
52 hg manifest
53 echo -- cat mf
54 hg cat mf
55 cd ..
56
57 echo ---- command
58
59 rm -rf repo
60 hg init repo
61 cd repo
62 hg debugbuilddag '+2 !"touch X" +2' -q -o
63 echo -- dag
64 hg debugdag -t -b
65 echo -- glog
66 hg glog --template '{rev}: {desc} [{branches}]\n'
67 echo -- glog X
68 hg glog --template '{rev}: {desc} [{branches}]\n' X
69 cd ..
70
@@ -0,0 +1,272 b''
1 ---- overwritten and appended files
2 -- dag
3 +2:f
4 +3:p2
5 @temp*f+3
6 @default*/p2+2:tip
7 -- glog
8 @ 11: r11 [] @ 11.00
9 |
10 o 10: r10 [] @ 10.00
11 |
12 o 9: r9 [] @ 9.00
13 |\
14 | o 8: r8 [temp] @ 8.00
15 | |
16 | o 7: r7 [temp] @ 7.00
17 | |
18 | o 6: r6 [temp] @ 6.00
19 | |
20 | o 5: r5 [temp] @ 5.00
21 | |
22 o | 4: r4 [] @ 4.00
23 | |
24 o | 3: r3 [] @ 3.00
25 | |
26 o | 2: r2 [] @ 2.00
27 |/
28 o 1: r1 [] @ 1.00
29 |
30 o 0: r0 [] @ 0.00
31
32 -- glog of
33 @ 11: r11 []
34 |
35 o 10: r10 []
36 |
37 o 9: r9 []
38 |\
39 | o 8: r8 [temp]
40 | |
41 | o 7: r7 [temp]
42 | |
43 | o 6: r6 [temp]
44 | |
45 | o 5: r5 [temp]
46 | |
47 o | 4: r4 []
48 | |
49 o | 3: r3 []
50 | |
51 o | 2: r2 []
52 |/
53 o 1: r1 []
54 |
55 o 0: r0 []
56
57 -- glog af
58 @ 11: r11 []
59 |
60 o 10: r10 []
61 |
62 o 9: r9 []
63 |\
64 | o 8: r8 [temp]
65 | |
66 | o 7: r7 [temp]
67 | |
68 | o 6: r6 [temp]
69 | |
70 | o 5: r5 [temp]
71 | |
72 o | 4: r4 []
73 | |
74 o | 3: r3 []
75 | |
76 o | 2: r2 []
77 |/
78 o 1: r1 []
79 |
80 o 0: r0 []
81
82 -- tags
83 tip 11:f96e381c614c
84 p2 4:d9d6db981b55 local
85 f 1:73253def624e local
86 -- cat of
87 r11
88 -- cat af
89 r0
90 r1
91 r5
92 r6
93 r7
94 r8
95 r9
96 r10
97 r11
98 ---- new and mergeable files
99 -- dag
100 +2:f
101 +3:p2
102 @temp*f+3
103 @default*/p2+2:tip
104 -- glog
105 @ 11: r11 [] @ 11.00
106 |
107 o 10: r10 [] @ 10.00
108 |
109 o 9: r9 [] @ 9.00
110 |\
111 | o 8: r8 [temp] @ 8.00
112 | |
113 | o 7: r7 [temp] @ 7.00
114 | |
115 | o 6: r6 [temp] @ 6.00
116 | |
117 | o 5: r5 [temp] @ 5.00
118 | |
119 o | 4: r4 [] @ 4.00
120 | |
121 o | 3: r3 [] @ 3.00
122 | |
123 o | 2: r2 [] @ 2.00
124 |/
125 o 1: r1 [] @ 1.00
126 |
127 o 0: r0 [] @ 0.00
128
129 -- glog mf
130 @ 11: r11 []
131 |
132 o 10: r10 []
133 |
134 o 9: r9 []
135 |\
136 | o 8: r8 [temp]
137 | |
138 | o 7: r7 [temp]
139 | |
140 | o 6: r6 [temp]
141 | |
142 | o 5: r5 [temp]
143 | |
144 o | 4: r4 []
145 | |
146 o | 3: r3 []
147 | |
148 o | 2: r2 []
149 |/
150 o 1: r1 []
151 |
152 o 0: r0 []
153
154 -- man r4
155 mf
156 nf0
157 nf1
158 nf2
159 nf3
160 nf4
161 -- cat r4 mf
162 0 r0
163 1
164 2 r1
165 3
166 4 r2
167 5
168 6 r3
169 7
170 8 r4
171 9
172 10
173 11
174 12
175 13
176 14
177 15
178 16
179 17
180 18
181 19
182 20
183 21
184 22
185 23
186 -- man r8
187 mf
188 nf0
189 nf1
190 nf5
191 nf6
192 nf7
193 nf8
194 -- cat r8 mf
195 0 r0
196 1
197 2 r1
198 3
199 4
200 5
201 6
202 7
203 8
204 9
205 10 r5
206 11
207 12 r6
208 13
209 14 r7
210 15
211 16 r8
212 17
213 18
214 19
215 20
216 21
217 22
218 23
219 -- man
220 mf
221 nf0
222 nf1
223 nf10
224 nf11
225 nf2
226 nf3
227 nf4
228 nf5
229 nf6
230 nf7
231 nf8
232 nf9
233 -- cat mf
234 0 r0
235 1
236 2 r1
237 3
238 4 r2
239 5
240 6 r3
241 7
242 8 r4
243 9
244 10 r5
245 11
246 12 r6
247 13
248 14 r7
249 15
250 16 r8
251 17
252 18 r9
253 19
254 20 r10
255 21
256 22 r11
257 23
258 ---- command
259 -- dag
260 +4:tip
261 -- glog
262 @ 3: r3 []
263 |
264 o 2: r2 []
265 |
266 o 1: r1 []
267 |
268 o 0: r0 []
269
270 -- glog X
271 o 2: r2 []
272
@@ -849,6 +849,123 b' def debugancestor(ui, repo, *args):'
849 a = r.ancestor(lookup(rev1), lookup(rev2))
849 a = r.ancestor(lookup(rev1), lookup(rev2))
850 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
850 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
851
851
852 def debugbuilddag(ui, repo, text,
853 mergeable_file=False,
854 appended_file=False,
855 overwritten_file=False,
856 new_file=False):
857 """builds a repo with a given dag from scratch in the current empty repo
858
859 Elements:
860
861 - "+n" is a linear run of n nodes based on the current default parent
862 - "." is a single node based on the current default parent
863 - "$" resets the default parent to null (implied at the start);
864 otherwise the default parent is always the last node created
865 - "<p" sets the default parent to the backref p
866 - "*p" is a fork at parent p, which is a backref
867 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
868 - "/p2" is a merge of the preceding node and p2
869 - ":tag" defines a local tag for the preceding node
870 - "@branch" sets the named branch for subsequent nodes
871 - "!command" runs the command using your shell
872 - "!!my command\\n" is like "!", but to the end of the line
873 - "#...\\n" is a comment up to the end of the line
874
875 Whitespace between the above elements is ignored.
876
877 A backref is either
878
879 - a number n, which references the node curr-n, where curr is the current
880 node, or
881 - the name of a local tag you placed earlier using ":tag", or
882 - empty to denote the default parent.
883
884 All string valued-elements are either strictly alphanumeric, or must
885 be enclosed in double quotes ("..."), with "\" as escape character.
886
887 Note that the --overwritten-file and --appended-file options imply the
888 use of "HGMERGE=internal:local" during DAG buildup.
889 """
890
891 if not (mergeable_file or appended_file or overwritten_file or new_file):
892 raise Exception(_('need at least one of -m, -a, -o, -n'))
893
894 if len(repo.changelog) > 0:
895 raise Exception(_('repository is not empty'))
896
897 if overwritten_file or appended_file:
898 # we don't want to fail in merges during buildup
899 os.environ['HGMERGE'] = 'internal:local'
900
901 def writefile(fname, text, fmode="w"):
902 f = open(fname, fmode)
903 try:
904 f.write(text)
905 finally:
906 f.close()
907
908 if mergeable_file:
909 linesperrev = 2
910 # determine number of revs in DAG
911 n = 0
912 for type, data in dagparser.parsedag(text):
913 if type == 'n':
914 n += 1
915 # make a file with k lines per rev
916 writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev))
917 + "\n")
918
919 at = -1
920 atbranch = 'default'
921 for type, data in dagparser.parsedag(text):
922 if type == 'n':
923 ui.status('node %s\n' % format(data))
924 id, ps = data
925 p1 = ps[0]
926 if p1 != at:
927 update(ui, repo, node=p1, clean=True)
928 at = p1
929 if repo.dirstate.branch() != atbranch:
930 branch(ui, repo, atbranch, force=True)
931 if len(ps) > 1:
932 p2 = ps[1]
933 merge(ui, repo, node=p2)
934
935 if mergeable_file:
936 f = open("mf", "r+")
937 try:
938 lines = f.read().split("\n")
939 lines[id * linesperrev] += " r%i" % id
940 f.seek(0)
941 f.write("\n".join(lines))
942 finally:
943 f.close()
944
945 if appended_file:
946 writefile("af", "r%i\n" % id, "a")
947
948 if overwritten_file:
949 writefile("of", "r%i\n" % id)
950
951 if new_file:
952 writefile("nf%i" % id, "r%i\n" % id)
953
954 commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0))
955 at = id
956 elif type == 'l':
957 id, name = data
958 ui.status('tag %s\n' % name)
959 tag(ui, repo, name, local=True)
960 elif type == 'a':
961 ui.status('branch %s\n' % data)
962 atbranch = data
963 elif type in 'cC':
964 r = util.system(data, cwd=repo.root)
965 if r:
966 desc, r = util.explain_exit(r)
967 raise util.Abort(_('%s command %s') % (data, desc))
968
852 def debugcommands(ui, cmd='', *args):
969 def debugcommands(ui, cmd='', *args):
853 """list all available commands and options"""
970 """list all available commands and options"""
854 for cmd, vals in sorted(table.iteritems()):
971 for cmd, vals in sorted(table.iteritems()):
@@ -3923,6 +4040,14 b' table = {'
3923 ] + walkopts + dryrunopts,
4040 ] + walkopts + dryrunopts,
3924 _('[OPTION]... [SOURCE]... DEST')),
4041 _('[OPTION]... [SOURCE]... DEST')),
3925 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
4042 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
4043 "debugbuilddag":
4044 (debugbuilddag,
4045 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
4046 ('a', 'appended-file', None, _('add single file all revs append to')),
4047 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
4048 ('n', 'new-file', None, _('add new file at each rev')),
4049 ],
4050 _('[OPTION]... TEXT')),
3926 "debugcheckstate": (debugcheckstate, [], ''),
4051 "debugcheckstate": (debugcheckstate, [], ''),
3927 "debugcommands": (debugcommands, [], _('[COMMAND]')),
4052 "debugcommands": (debugcommands, [], _('[COMMAND]')),
3928 "debugcomplete":
4053 "debugcomplete":
@@ -61,6 +61,7 b' diff'
61
61
62 % Show debug commands if there are no other candidates
62 % Show debug commands if there are no other candidates
63 debugancestor
63 debugancestor
64 debugbuilddag
64 debugcheckstate
65 debugcheckstate
65 debugcommands
66 debugcommands
66 debugcomplete
67 debugcomplete
@@ -192,6 +193,7 b' bundle: force, rev, branch, base, all, t'
192 cat: output, rev, decode, include, exclude
193 cat: output, rev, decode, include, exclude
193 copy: after, force, include, exclude, dry-run
194 copy: after, force, include, exclude, dry-run
194 debugancestor:
195 debugancestor:
196 debugbuilddag: mergeable-file, appended-file, overwritten-file, new-file
195 debugcheckstate:
197 debugcheckstate:
196 debugcommands:
198 debugcommands:
197 debugcomplete: options
199 debugcomplete: options
@@ -16,7 +16,7 b' import mercurial.util'
16 doctest.testmod(mercurial.util)
16 doctest.testmod(mercurial.util)
17
17
18 import mercurial.dagparser
18 import mercurial.dagparser
19 doctest.testmod(mercurial.dagparser)
19 doctest.testmod(mercurial.dagparser, optionflags=doctest.NORMALIZE_WHITESPACE)
20
20
21 import hgext.convert.cvsps
21 import hgext.convert.cvsps
22 doctest.testmod(hgext.convert.cvsps)
22 doctest.testmod(hgext.convert.cvsps)
General Comments 0
You need to be logged in to leave comments. Login now