Commit Graph

85 Commits

Author SHA1 Message Date
Allan Odgaard
db13d4c1f9 Use std::string::back() instead of operator[] with size()-1 2014-03-31 08:27:18 +07:00
Allan Odgaard
4f4fe38aec Use path::escape instead of local code 2014-03-29 18:58:53 +07:00
Allan Odgaard
a404daecce Use io::exec() instead of system()
The motivation for this change is that we may enable MallocDebug when running tests, which is done via environment variables that we do not want to be passed on to the shell tools we execute.
2014-03-29 18:58:52 +07:00
Allan Odgaard
b4afdd818a Always ignore SCM info from root/home folder
Previously we would only pass the repository’s root to scm::info, and thus the check on the path passed in was enough, but today we are passing in paths for which we do not yet know the repository root, so the check should (also) be done for the path that ends up containing version control meta data.

We still do the initial check since it also rejects non-local paths, thus avoiding stat’ing paths on network file systems.
2014-03-16 18:06:02 +07:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Gerd Knops
78f3584bad Show git conflicts with priority 2014-01-09 14:19:58 +07:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
ed7d457e65 Use text::tokenize instead of text::split
This avoids duplicating the memory used.
2013-08-30 12:30:32 +02:00
Allan Odgaard
e0ad0ba510 Use dispatch_time_t instead of std::chrono::time_point
Building with clang 3.2 (binary distribution) results in “illegal instruction” when adding 3 seconds to the steady clock, so I just replaced the code.

The reason the code was using std::chrono was to be able to provide better debug output, as dispatch_time_t is an abstracted time representation (according to the documentation).
2013-08-16 22:40:08 +02:00
Allan Odgaard
c69112dbe3 fixup! Account for svn returning relative paths
Turns out the paths are relative to the current working directory, not the working copy.
2013-07-29 15:50:31 +02:00
Allan Odgaard
866057f31d Better error reporting when copying git index
Also avoid a (sort of) race condition (related to meaningful error) by using fcopyfile().
2013-07-26 16:21:33 +02:00
Allan Odgaard
d17fb1ad7c Account for svn returning relative paths
Starting with subversion 1.8 we get back relative paths from ‘svn status’ so we need to prepend the working directory path.

I also made a few minor stylistic changes while touching the relevant function.
2013-07-24 15:56:19 +02:00
Allan Odgaard
491fc8a3e3 Add missing semi-colons after assertion 2013-07-21 13:25:28 +02:00
Allan Odgaard
ce4ae62547 Change ‘variables_for_path’ API
We now accept the a directory in addition to the path. If a directory is provided, the path is only used to filter variables rooted at the directory.
2013-05-12 11:09:18 +07:00
Allan Odgaard
5fd188531a Change naming of functions for obtaining variables
These are now all prefixed with what they are obtaining variables for (scope, document, bundle, …) which makes it easier to analyze/refactor the code.

Also change document_t’s settings function to document_settings.
2013-05-09 15:16:32 +07:00
Allan Odgaard
a6fca57d6a Don’t set TM_SCM_BRANCH when there is no branch 2013-03-21 11:45:08 +01:00
Allan Odgaard
00d381ec5f SCM drivers can return arbitrary variables
These variables are mainly for use in the window title. Not all variables make sense across SCM drivers, hence why it is now completely up to the driver, what variables it provides.
2013-03-11 16:14:44 +01:00
Allan Odgaard
ce537a4ef9 Prefix error message with result from getprogname() 2013-03-11 16:11:39 +01:00
Allan Odgaard
94e7624224 Setup git-dir and work-tree for git 2013-03-10 16:07:10 +01:00
Allan Odgaard
742192bf01 Provide svn with path to repository 2013-03-10 16:07:10 +01:00
Allan Odgaard
6b3dcc415f Use --cwd when calling hg
This way we avoid changing the process’ working directory.
2013-03-10 16:07:10 +01:00
Allan Odgaard
ea5d7d3af9 Use weak pointers in most async dispatch blocks
This is mainly to expedite potential destruction of the objects referenced.
2013-02-25 15:27:29 +01:00
Allan Odgaard
3859e25429 Disallow copying scm::info_t
Presently not supported.
2013-02-25 15:27:29 +01:00
Allan Odgaard
e091bdb2f0 Use const for member data initialized by constructor 2013-02-25 15:26:45 +01:00
Allan Odgaard
38be7f56db Add scm::info_t::pop_callback
Ideally we would be able to remove arbitrary callbacks rather than the last one added, but for this we would need to introduce some sort of handle (the callback itself is a block so not suitable as handle). The push/pop API for callbacks is sufficient for our use-case though.
2013-02-25 15:25:17 +01:00
Allan Odgaard
6d6c3e4de6 Use path::is_absolute instead of custom code 2013-02-25 15:25:17 +01:00
Allan Odgaard
10ebd31ad9 Let SCM tests use same executable as driver
The was previously only done for the svn tests and the code had some flaws, like modifying the PATH environment variable.
2013-02-23 11:24:57 +01:00
Allan Odgaard
b4ee927fdf Expose scm::find_executable (for testing)
This is so that tests can use the exact same executable to create the repository, as is used to obtain status (svn repositories created with newer executables are often not backwards compatible).
2013-02-23 11:24:56 +01:00
Allan Odgaard
b718106ff8 Make semi-internal API private
This was previously public so that we could write tests for it, but since the test runner is linked with the object files, it can access symbols that has visibility set to hidden.
2013-02-23 11:24:56 +01:00
Allan Odgaard
e033b7031f Avoid non-POD static data in thread
The issue here is that the thread can outlive the data.
2013-02-22 16:07:35 +01:00
Allan Odgaard
cbb0a7864d Drop ‘ng’ namespace for scm 2013-02-21 17:39:55 +01:00
Allan Odgaard
af4f1e16a1 Remove old SCM API 2013-02-21 17:01:24 +01:00
Allan Odgaard
c3e9fafb2d Include scm.h instead of scm_ng.h
Since scm.h includes scm_ng.h this is effectively the same.
2013-02-21 16:58:22 +01:00
Allan Odgaard
3f4f09dcd8 Update SCM tests to new API
This is both the new test system and the new (non-blocking) SCM API.
2013-02-21 16:54:00 +01:00
Allan Odgaard
15f922a148 Let to_s(fs::snapshot_t) return std::string
Previously it would dump the datatype to stderr.
2013-02-21 16:52:22 +01:00
Allan Odgaard
8e0e35bf3b Add API to wait for SCM status
This is only meant for tests where we wish to block execution until SCM status has been collected.
2013-02-21 16:43:43 +01:00
Allan Odgaard
e2ee734fd6 SCM background workers enabled by default
Normally we enable these on application launch when we receive an ‘application did become active’ notification, for tests though, this notification is lacking, but we do want it enabled for tests, and while we could do a constructor in the tests to enable it, it seems better to just enable it by default.

One issue is that if TextMate is launched “in the background” then it will still do SCM status gathering. Though long-term I may actually want to always have it enabled, even when TextMate is not active.
2013-02-21 16:39:26 +01:00
Allan Odgaard
d0e0835e82 Better hiding of scm::ng::info_t implementation 2013-02-15 15:27:54 +01:00
Allan Odgaard
e7ed62c305 Don’t unnecessarily retain scm::ng::info_ptr
This ensures that when an scm::ng::info_ptr object has been disposed by the user, the associated callback will not be called (as no-one else will keep it retained).
2013-02-15 15:27:53 +01:00
Allan Odgaard
3ef473b1be Use std::chrono::steady_clock instead of oak::date_t
This is a better choice for durations, as it’s clearly defined as independent of wall clock time.
2013-02-08 11:20:34 +01:00
Allan Odgaard
20641c50c3 Disable SCM badges for non-local paths
Also disable it for user’s home folder and root of file system — having to monitor these folders is too expensive.
2013-02-05 08:51:59 +01:00
Allan Odgaard
ae5a7738f6 Retain shared info during async SCM update
Fixes #752.
2013-02-05 08:36:04 +01:00
Allan Odgaard
a7a4699643 Improve caching of SCM shared info
When requesting SCM info for a path, we now always return the cached info for the first parent of the path, but if the first parent of the path is not the direct parent, we do a more thorough search (which involve disk access) in a background thread.

The latter is required because we may have nested repositories. E.g. asking for SCM info for /path/to/project/submodule/file will initially return the root project’s cached SCM info (if the submodule info hasn’t yet been added to the cache) but will then later invoke the callback with the submodule’s SCM info.
2013-02-04 19:38:31 +01:00
Allan Odgaard
0fdd04b6d3 Add SCM API for disabling updates
This is to be used when the application is in the background. Rather than completely disable updates, it might perhaps be better simply to increase the delay used to throttle updates.
2013-02-03 10:48:39 +01:00
Allan Odgaard
e599bb7379 Introduce scm::ng::root_for_path
Also change SCM implementation so that it doesn’t use objects with automatic storage, as the objects may be accessed from threads, which may run after objects with automatic storage has been destroyed.
2013-02-03 10:48:38 +01:00
Allan Odgaard
ef8e1a7597 Only set TM_SCM_BRANCH when there is a branch 2013-02-03 10:48:37 +01:00
Allan Odgaard
f1ff38f929 Add new SCM API
This won’t perform any disk access on main thread. The previous API would check for the SCM-metadata directories on the main thread and also obtain the initial status and branch during creation.
2013-02-02 10:51:59 +01:00
Allan Odgaard
e6c6fc74aa Decouple fs-events code from info_t 2013-02-02 08:52:12 +01:00
Allan Odgaard
97eb13f4c9 Move fs-events code to own file 2013-02-02 08:52:12 +01:00