Stephen Leake <stephen_le...@stephe-leake.org> writes: > Thomas Keller <m...@thomaskeller.biz> writes: > >> Am 04.05.10 16:18, schrieb Stephen Leake: >>> I'm trying to get the rev_id of a merge, in a Lua test. Can anyone tell >>> me why this doesn't work? I based it on base_revision(). >>> >>> function merged_revision() >>> local workrev = readfile("stderr") >>> local extract = string.gsub(workrev, "^mtn: %[merged%] (%x*)$", "%1") >> >> This will not work with multi-line string input, because ^ marks the >> very beginning and $ the very end of the string, not the line. But even >> if you remove these, you'll only process the replacement of the matched >> line, while you actually want to extract something. This should work better: >> >> local extract = string.match(workrev, "mtn: %[merged%] (%x*)") > > That does work, and is clearer, but I don't understand the explanation. > Why does base_revision work?
I figured it out; there's a ".*" which matches everthing from the start of the string, and the desired string happens to be at the end of the file. -- -- Stephe _______________________________________________ Monotone-devel mailing list Monotone-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/monotone-devel