keyword expansion collapses non-keywords

Bug #505038 reported by Matthew Fuller
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar Keywords Plugin
Fix Committed
High
Andrew Johnson

Bug Description

When expansion is enabled, non-keywords are in danger of getting collapsed.

This is visible several places in the bzr source, for instance. To reproduce, add a rules file like

[name *.txt]
keywords = on

and then cd bzr.dev ; rm doc/en/admin-guide/hooks-plugins.txt ; bzr revert ; bzr diff

Related branches

Revision history for this message
Tom_OConnor (tom-twinhelix) wrote :

I have a test case:
file "test.php" contains :

// Simplest case that breaks things:
$a-b::c
$d

// Why we'd do this:
echo "There are ".$thispage-SearchResults::NumPages()." more pages of results";
$nextpage = $thispage + 1;

[tom@turmeric test]$ bzr ci test.php
then becomes

[tom@turmeric test]$ bzr cat test.php
// Simplest case that breaks things:
$a-b$d

// Why we'd do this:
echo "There are ".$thispage-SearchResults$nextpage = $thispage + 1;

Using latest bzr-keywords as produced with `bzr co lp:bzr-keywords`

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

This is a bad bug. Branch specific rules will help this by isolating the working trees the expansion is applied to. Even without that though, I think we need to err on the conservative side here and be stricter about what's considered a keyword vs otherwise.

Changed in bzr-keywords:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Matthew Fuller (fullermd) wrote : Re: [Bug 505038] Re: keyword expansion collapses non-keywords

Yeah. It's bad in general, but in languages with sigils, it's a
showstopper :|

Revision history for this message
Tom_OConnor (tom-twinhelix) wrote :

I created a local branch, and was trying to experiment with only matching known keywords thusly:

known_tag_list = ['Date','Committer','Authors','Revision-Id','Path','Directory','Filename','File-Id','Now','User','Comm
itter-Name','Committer-Email','Author1-Name','Author1-Email','Author2-Name','Author2-Email','Author3-Name','Author3-Ema
il','User-Name','User-Email']

_KW_COOKED_RE_DICT = {}
_KW_RAW_RE_DICT= {}

for known_tag in known_tag_list:
        _KW_COOKED_RE_DICT[known_tag] = re.compile(r"\$(%s)(:[^$]*)?\$" % known_tag)
        _KW_RAW_RE_DICT[known_tag] = re.compile(r"\$(%s)(:[^$]*)?\$" % known_tag)

...
for regex in _KW_RAW_RE_DICT.keys():
                match = _KW_RAW_RE_DICT[regex].search(rest)

But didn't manage to get it working.

Andrew Johnson (anj)
Changed in bzr-keywords:
assignee: nobody → Andrew Johnson (anj)
Revision history for this message
Andrew Johnson (anj) wrote :

I've just pushed a branch that fixes this by not compressing keywords that are not registered (I'll attach the patch here too for completeness). However if the keyword compression has already happened then your repository has lost the original cooked value and you'll have to fix and commit any instances manually.

Revision history for this message
Andrew Johnson (anj) wrote :

See my previous comment...

Changed in bzr-keywords:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.