diff --git a/lib/hg-utils.coffee b/lib/hg-utils.coffee index 1484e86..48b8d8a 100644 --- a/lib/hg-utils.coffee +++ b/lib/hg-utils.coffee @@ -30,7 +30,8 @@ suppressHgWarnings = [ ] class Repository - + isWindows = process.platform == 'win32' + windowsMaxPathLength = 260 username: null password: null @@ -291,7 +292,10 @@ class Repository if err reject err if stderr?.length > 0 - reject stderr + if isWindows and stderr.length > windowsMaxPathLength + resolve(stdout) + else + reject new Error(stderr) resolve stdout handleHgError: (error) -> diff --git a/test/long_windows_paths.coffee b/test/long_windows_paths.coffee new file mode 100644 index 0000000..d5d5bd0 --- /dev/null +++ b/test/long_windows_paths.coffee @@ -0,0 +1,31 @@ +require 'coffee-script/register' +require './fakeWindow' +HgRepository = require '../lib/hg-repository' +TestRepository = require './testRepository' +assert = require('chai').assert +path = require 'path' +exec = require('child_process').execSync + +isWindows = process.platform == 'win32' +unless isWindows + return + +describe 'In a repository with a really long path', -> + testRepo = new TestRepository path.parse(__filename).name + repo = null + before -> + testRepo.init() + + beforeEach -> + repo = new HgRepository (testRepo.fullPath()) + + it 'should still return isPathIgnored true', -> + ignored_file = path.join testRepo.fullPath(), 'ignored_file' + repo.refreshStatus().then -> + assert.equal(repo.isPathIgnored(ignored_file), true) + + after -> + command = 'dir \'' + testRepo.fullPath() + '\\subDir*\' | rename-item -NewName a' + command = 'powershell -command "' + command + '"' + exec command + testRepo.destroy() diff --git a/test/long_windows_paths.ps1 b/test/long_windows_paths.ps1 new file mode 100644 index 0000000..d75366f --- /dev/null +++ b/test/long_windows_paths.ps1 @@ -0,0 +1,18 @@ +hg init $args[0] +set-location $args[0] + +Set-Content -Path ".hgignore" -Value @" +syntax:glob +ignored_file +"@ +hg add ".hgignore" + +new-item -type File "ignored_file" +new-item -type Directory "subdir" +new-item -type File "subdir/some_file" + +$subDir = get-item "subdir" +$path = $subDir.FullName +$path = $path.PadRight(259, "A") + +rename-item "subdir" (Split-Path $path -Leaf)