<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Case Insensitive File Systems — Bazaar v2.2.4 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '2.2.4', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="shortcut icon" href="_static/bzr.ico"/> <link rel="top" title="Bazaar v2.2.4 documentation" href="index.html" /> <link rel="up" title="Specifications" href="specifications.html" /> <link rel="next" title="Development repository formats" href="development-repo.html" /> <link rel="prev" title="Repository Streams" href="repository-stream.html" /> <link rel="stylesheet" href="_static/bzr-doc.css" type="text/css" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="development-repo.html" title="Development repository formats" accesskey="N">next</a></li> <li class="right" > <a href="repository-stream.html" title="Repository Streams" accesskey="P">previous</a> |</li> <li><a href="http://bazaar.canonical.com/"> <img src="_static/bzr icon 16.png" /> Home</a> | </li> <a href="http://doc.bazaar.canonical.com/en/">Documentation</a> | </li> <li><a href="index.html">Developer Document Catalog (2.2.4)</a> »</li> <li><a href="specifications.html" accesskey="U">Specifications</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="case-insensitive-file-systems"> <h1>Case Insensitive File Systems<a class="headerlink" href="#case-insensitive-file-systems" title="Permalink to this headline">¶</a></h1> <p>Bazaar must be portable across operating-systems and file-systems. While the primary file-system for an operating-system might have some particular characteristics, it’s not necessary that <em>all</em> file-systems for that operating-system will have the same characteristics.</p> <p>For example, the FAT32 file-system is most commonly found on Windows operating systems, and has the characteristics usually associated with a Windows file-system. However, USB devices means FAT32 file-systems are often used with GNU/Linux systems, so the current operating system doesn’t necessarily reflect the capabilities of the file-system.</p> <p>Bazaar supports 3 kinds of file-systems, each to different degrees.</p> <ul class="simple"> <li>Case-sensitive file-systems: This is the file-system generally used on GNU/Linux: 2 files can differ only by case, and the exact case must be used when opening a file.</li> <li>Case-insensitive, case-preserving (cicp) file-systems: This is the file-system generally used on Windows; FAT32 is an example of such a file-system. Although existing files can be opened using any case, the exact case used to create the file is preserved and available for programs to query. Two files that differ only by case is not allowed.</li> <li>Case-insensitive: This is the file-system used by very old Windows versions and is rarely encountered “in the wild”. Two files that differ only by case is not allowed and the case used to create a file is not preserved.</li> </ul> <p>As can be implied by the above descriptions, only the first two are considered relevant to a modern Bazaar.</p> <p>For more details, including use cases, please see <a class="reference external" href="http://wiki.bazaar.canonical.com/CasePreservingWorkingTreeUseCases">http://wiki.bazaar.canonical.com/CasePreservingWorkingTreeUseCases</a></p> <div class="section" id="handling-these-file-systems"> <h2>Handling these file-systems<a class="headerlink" href="#handling-these-file-systems" title="Permalink to this headline">¶</a></h2> <p>The fundamental problem handling these file-systems is that the user may specify a file name or inventory item with an “incorrect” case - where “incorrect” simply means different than what is stored - from the user’s point-of-view, the filename is still correct, as it can be used to open, edit delete etc the item.</p> <p>The approach Bazaar takes is to “fixup” each of the command-line arguments which refer to a filename or an inventory item - where “fixup” means to adjust the case specified by the user so it exactly matches an existing item.</p> <p>There are two places this match can be performed against - the file-system and the Bazaar inventory. When looking at a case-insensitive file-system, it is impossible to have 2 names that differ only by case, so there is no ambiguity. The inventory doesn’t have the same rules, but it is expected that projects which wish to work with Windows would, by convention, avoid filenames that differ only by case.</p> <p>The rules for such fixups turn out to be quite simple:</p> <ul class="simple"> <li>If an argument refers to an existing inventory item, we fixup the argument using the inventory. This is, basically, all commands that take a filename or directory argument <em>other</em> than ‘add’ and in some cases ‘mv’</li> <li>If an argument refers to an existing filename for the creation of an inventory item (eg, add), then the case of the existing file on the disk will be used. However, Bazaar must still check the inventory to prevent accidentally creating 2 inventory items that differ only by case.</li> <li>If an argument results in the creation of a <em>new</em> filename (eg, a move destination), the argument will be used as specified. Bzr will create a file and inventory item that exactly matches the case specified (although as above, care must be taken to avoid creating two inventory items that differ only by case.)</li> </ul> </div> <div class="section" id="implementation-of-support-for-these-file-systems"> <h2>Implementation of support for these file-systems<a class="headerlink" href="#implementation-of-support-for-these-file-systems" title="Permalink to this headline">¶</a></h2> <p>From the description above, it can be seen the implementation is fairly simple and need not intrude on the internals of Bazaar too much; most of the time it is simply converting a string specified by the user to the “canonical” form as stored in either the inventory or filesystem. These boil down to the following new API functions:</p> <ul class="simple"> <li>osutils.canonical_relpath() - like osutils.relpath() but adjust the case of the result to match any existing items.</li> <li>Tree.get_canonical_inventory_path - somewhat like Tree.get_symlink_target(), Tree.get_file_by_path() etc; returns a name with the case adjusted to match existing inventory items.</li> <li>osutils.canonical_relpaths() and Tree.get_canonical_inventory_paths() - like the ‘singular’ versions above, but accept and return sequences and therefore offer more optimization opportunities when working with multiple names.</li> </ul> <p>The only complication is the requirement that Bazaar not allow the creation of items that differ only by case on such file-systems. For this requirement, case-insensitive and cicp file-systems can be treated the same. The ‘case_sensitive’ attribute on a MutableTree is used to control this behaviour.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Case Insensitive File Systems</a><ul> <li><a class="reference internal" href="#handling-these-file-systems">Handling these file-systems</a></li> <li><a class="reference internal" href="#implementation-of-support-for-these-file-systems">Implementation of support for these file-systems</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="repository-stream.html" title="previous chapter">Repository Streams</a></p> <h4>Next topic</h4> <p class="topless"><a href="development-repo.html" title="next chapter">Development repository formats</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/case-insensitive-file-systems.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="development-repo.html" title="Development repository formats" >next</a></li> <li class="right" > <a href="repository-stream.html" title="Repository Streams" >previous</a> |</li> <li><a href="http://bazaar.canonical.com/"> <img src="_static/bzr icon 16.png" /> Home</a> | </li> <a href="http://doc.bazaar.canonical.com/en/">Documentation</a> | </li> <li><a href="index.html">Developer Document Catalog (2.2.4)</a> »</li> <li><a href="specifications.html" >Specifications</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009, Canonical Ltd. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>