Let DocumentController provide SCM scopes

This commit is contained in:
Allan Odgaard
2013-01-19 15:22:11 +01:00
parent 340782dbc9
commit 46d870c5ca
2 changed files with 18 additions and 19 deletions

View File

@@ -921,7 +921,24 @@ namespace
- (NSString*)scopeAttributes
{
return self.pathAttributes;
if(!_scmInfo)
return self.pathAttributes;
NSMutableString* res = [self.pathAttributes mutableCopy];
auto vars = _scmInfo->variables();
auto iter = vars.find("TM_SCM_BRANCH");
if(iter != vars.end())
[res appendFormat:@" attr.scm.branch.%s", iter->second.c_str()];
if(self.representedFile)
{
scm::status::type status = _scmInfo->status(to_s(self.representedFile));
if(status != scm::status::unknown)
[res appendFormat:@" attr.scm.status.%s", to_s(status).c_str()];
}
return res;
}
// ==============

View File

@@ -92,23 +92,6 @@ namespace
}
}
}
static void scm_attributes (std::string const& path, std::string const& dir, std::vector<std::string>& res)
{
if(scm::info_ptr info = scm::info(dir))
{
auto scmVariables = info->variables();
if(scmVariables.find("TM_SCM_BRANCH") != scmVariables.end())
res.push_back("attr.scm.branch." + scmVariables["TM_SCM_BRANCH"]);
if(path != NULL_STR)
{
scm::status::type status = info->status(path);
if(status != scm::status::unknown)
res.push_back("attr.scm.status." + to_s(status));
}
}
}
}
namespace file
@@ -148,7 +131,6 @@ namespace file
std::string const parentDir = dir == NULL_STR ? path::parent(path) : dir;
directory_attributes(parentDir, res);
scm_attributes(path, parentDir, res);
res.push_back(settings_for_path(path, text::join(res, " "), parentDir).get(kSettingsScopeAttributesKey, ""));
res.erase(std::remove(res.begin(), res.end(), ""), res.end());