Commit Graph

68 Commits

Author SHA1 Message Date
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
Allan Odgaard
b54f28af95 Improve encapsulation 2013-02-02 08:50:35 +01:00
Allan Odgaard
4b87e3cafe Fallback on main bundle for svn_status.xslt
Ideally we would use something like “inSameBundleAsClass:’, but as we don’t have any classes in the SCM framework, that is not possible.
2013-01-25 11:01:57 +01:00
Allan Odgaard
340782dbc9 Update SCM variables with status 2013-01-20 12:49:33 +01:00
Allan Odgaard
beb7417400 Introduce API for getting “scm variables”
This is both convenience, since we setup the TM_SCM variables in several places, but will also allow to register for changed variables (and thus, fetch branch name in a thread).
2013-01-20 12:49:33 +01:00
Allan Odgaard
546b55a407 Only fingerprint file system for hg
The problem with hg is that running ‘hg status’ may trigger fsevents, which would normally have us call ‘hg status’ again. To avoid this, we check if there actually are changes compared to the last time we ran the SCM driver. This has some overhead, as we need to scan the disk to produce the fingerprint.
2013-01-12 13:09:16 +01:00
Allan Odgaard
a222dfd805 Use libdispatch for SCM status
Additionally the throttling has been improved. Previously we would delay a status fetch if it had been less than 3 seconds since the last request, but during this “penalty wait” more requests could still be submitted (in case of disk activity) and would be queued for later execution — now such requests are dropped.
2013-01-12 13:09:16 +01:00
Allan Odgaard
45763d4afc Don’t require file to get SCM info
We didn’t actually use the file itself, only its parent directory, and there are several places we want SCM info for an untitled file’s project directory, so removing the need for a file simplifies things.
2012-09-18 17:33:02 +02:00
Allan Odgaard
170785dd52 Fix typo 2012-09-14 17:14:55 +02:00
Allan Odgaard
460185724d fixup! If path no longer have SCM info, include it in change set
The iterator checks were wrong.
2012-09-03 15:28:59 +02:00
Allan Odgaard
2b3e0bd7dc Fix excessive SCM status updates for clean repositories
The problem is that we used to treat an empty status map as meaning we hadn’t yet requested status for this repository, however, now that we no longer need status for all files, we would have an empty status map for clean (svn) repositories, leading to needlessly requesting status updates all the time (and on main thread).
2012-09-03 15:28:59 +02:00
Allan Odgaard
3a47ad6c03 SCM driver reports if system tracks directories
This can be used to make decisions about whether or not we should assign a virtual status to directories, prune them from a status display, or similar.
2012-09-03 15:28:58 +02:00
Allan Odgaard
c332ae69e6 Allow disabling SCM status from .tm_properties
This is done by adding the following (which can be limited to a folder):

    scmStatus = false
2012-09-02 17:53:50 +02:00
Allan Odgaard
92e31ec8d1 Exclude clean files from svn status
Subversion itself is roughly 30% faster if we do not ask for status of all files, the XML processing though is magnitudes faster, since it will only have to deal with a few records (in the general case) rather than a record per file (xsltproc seems to do around ~10,000 files per second on my Mac Pro, though I have no idea if it scales linearly).
2012-09-02 17:53:50 +02:00
Allan Odgaard
2d2dd62351 Change scm::status::versioned → none
The scm::status::versioned status has now been removed.

The upshot of this is that SCM drivers can leave out files that are “clean” from their status map, and TextMate will assume they have status “none” (clean). This cuts down on the amount of data that needs to be sent (and/or processed) by the SCM drivers.
2012-09-02 17:53:50 +02:00
Allan Odgaard
02b2ef3982 Change scm::status::note → unknown where applicable 2012-09-02 17:53:50 +02:00
Allan Odgaard
f3429d8aad Remove code duplication
The SCM status enumeration is now only declared once.

I also introduced an ‘unknown’ status which should be used instead of ‘none’.
2012-09-02 17:53:50 +02:00
Allan Odgaard
01e7f6df75 Use xsltproc to parse svn (XML) status output
For a repository with 7,767 files it takes 3.5 seconds for Python to convert a full file listing from XML to the simpler line-based format. Using xsltproc the same takes 0.74 seconds.

According to issue #340 TextMate “freeze for up to about 5 - 10 minutes” when doing svn status. Not sure how much this change helps on that, no doubt it’s an improvement.
2012-09-02 17:53:49 +02:00