monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] converting arbitrary paths to workspace or bookkeeping


From: Stephen Leake
Subject: [Monotone-devel] converting arbitrary paths to workspace or bookkeeping
Date: Wed, 03 Sep 2008 22:06:24 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (windows-nt)

As part of the conflict resolution work, I've implemented this
function:

  // Return a file_path, bookkeeping_path, or system_path, as appropriate.
  // This keeps the file names in the conflict file relative if possible.
  boost::shared_ptr<any_path> new_optimal_path(std::string path);

I'ts used to generate an object to represent an arbitrary file in a conflict
resolution:

  enum resolution_t {none, content_user, content_internal, rename, drop};

  typedef std::pair<resolve_conflicts::resolution_t, 
                    boost::shared_ptr<any_path> > file_resolution_t;

The body of new_optimal_path is simple:

  boost::shared_ptr<any_path>
  new_optimal_path(std::string path)
  {
    if (bookkeeping_path::external_string_is_bookkeeping_path(utf8(path)))
      return boost::shared_ptr<any_path>(new bookkeeping_path(path));
    else
      try
        {
          return new_file_path(path);
        }
      catch (informative_failure &)
        {
          return boost::shared_ptr<any_path>(new system_path(path));
        }
  };

'new_file_path' is similar:

  boost::shared_ptr<any_path>
  new_file_path(std::string path)
  {
    return boost::shared_ptr<any_path>
        (new file_path(file_path_external(utf8(path))));
  };

However, this doesn't quite do what I want.

First, bookkeeping_path::external_string_is_bookkeeping_path throws an
informative_error exception with message "invalid" if the path is
absolute. That's easy to fix; I added a similar exception handler in
that body so it just returns false.

However, neither bookkeeping_path::external_string_is_bookkeeping_path
nor file_path_external convert an absolute path into a relative one,
even when that would be appropriate.

An external tool, such as Emacs DVC, will most likely specify absolute
paths for files. While it is certainly possible to fix Emacs DVC to do
the file conversion, it would be more convenient to have mtn fix it;
that way other tools (and the mtn command line interface) will benefit
as well.

I don't see any function in paths.cc that will do this.

Have other people run across a need for this?

Is there some rationale for not doing this?

-- 
-- Stephe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]