Don't generate unique locks for file editing.

Using a pointer in a lock is not a good idea, because the lock database
will grow unbound. To make a lock that's unique to the promise in policy
code, use the line number in policy.

Make insert_lines promises that are generated by temlate code unique.

Otherwise, locks will kick in when a second identical line is
supposted to be generated.

Redmine #5637
(cherry picked from commit eb829195c4bdd56f631884f29dce5b4a57a0658c)
(cherry picked from commit f689bd36fe14d341d9e7b7b815a35b245f650888)
(cherry picked from commit ebd9539d886570cd660ef21484c28c13bce1918a)