[PREVIEW] line-endings support

Talden talden at gmail.com
Thu Apr 17 05:57:18 BST 2008


>  Doing it based on rules means that they're dependent on filename, which
>  means that renames can change a file's EOL behavior.  I don't see that
>  as a good thing.  Maybe it would be okay if there was a warning about
>  the change in behavior when commit or status was invoked.

An excellent point. Certainly the suggested mechanism depends upon
users specifying patterns that encompass all names in use for the
life-time of the content.

Luckily most patterns will be extension focused and most renames won't
change extensions.

For the exceptions it may be important to have a warning and possibly
even fork off absolute-path entries in the EOL rules to follow files
that step outside their patterns.
This would affect move/rename and remove behaviours at the least.
These absolute-path rules _should_ be exceptions.

There's a strong need for this facility to be versioned and I'm sure
there'll be some pain idetifying all of the interesting cases in that
feature. (merge conflicts, commit ordering, etc).

Here's a quick run over the idea of mixing absolute paths and patterns
and the maintenance of them -- apologies now for a hasty brain-dump...

  * The patterns file is stored in a canonical order and formatting (and the UI
    provide a means to canonicalise it and the commit mechanism does
so before commits) -
    This should reduce conflict cases using the usual line-based
merging and may aid
    searches for absolute path matching.
  * Provide a custom merger - if the file is in a canonical order then the
    conventional line-based merging approach can be used with a fall-back to
    auto-resolve certain conflicts such as "same-line, different pattern".
  * Have the UI provide a way of reapplying the EOL rules to the
working tree and that
    true conflicts in the EOL config result in LF behaviour (the
format in the repo itself)
    until EOL conflicts are resolved.
  * Changing EOL rules should apply those changes to the working-tree.

Here's a trivial example to illustrate mixing absolute and pattern rules.

With the rule...
    *.sh = LF

Doing this to a file in the working-tree root...
    mv blah.sh blah.sh.old

Produces...
    *.sh = LF
    ./blah.sh.old = LF

Then doing this to that file...
    mv blah.sh.old blah.sh.new

Produces...
    *.sh = LF
    ./blah.sh.new = LF

And lastly...
    rm blah.sh.new

Produces...
    *.sh = LF

--
Talden



More information about the bazaar mailing list