Am 05.05.10 09:02, schrieb Stephen Leake: > 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? > > Not a very important question, but it bothers me.
I think this works because of the .* before and after the search pattern. I tried this locally before as well, but couldn't get it to work. Thomas. -- GPG-Key 0x160D1092 | tommyd3...@jabber.ccc.de | http://thomaskeller.biz Please note that according to the EU law on data retention, information on every electronic information exchange might be retained for a period of six months or longer: http://www.vorratsdatenspeicherung.de/?lang=en
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Monotone-devel mailing list Monotone-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/monotone-devel