[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] get rev_id of merge
From: |
Stephen Leake |
Subject: |
Re: [Monotone-devel] get rev_id of merge |
Date: |
Wed, 05 May 2010 19:02:30 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) |
Stephen Leake <address@hidden> writes:
> Thomas Keller <address@hidden> 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