configure mercurial .hgingore to ignore all files and folder in a directory except 'repositories.config'

I have a multi-project solution with directory structure given below

What i want is to ignore all files and folder with path library-management-system\packages. But the packages folder has a file named repositories.config which i don't want to be ignored by Mercurial.

How can i do that ?

Folder PATH listing for volume PARIMAL
Volume serial number is 00650067 DD35:25E5
R:\LIBRARY-MANAGEMENT-SYSTEM
|   LibraryManagementSystem.sln
|   LibraryManagementSystem.sln.DotSettings.user
|   .hgignore
|   
+---CybotechDomain
|   |   App.config
|   |   CybotechDomain.csproj
|   |   CybotechDomain.csproj.user
|   |   
|   +---Entity
|   |       Batch.cs
|   |       Book.cs
|   |       BookIssue.cs
|   |       Course.cs
|   |       Faculty.cs
|   |       Manager.cs
|   |       Person.cs
|   |       Semester.cs
|   |       Student.cs
|   |       
|   +---Properties
|   |       AssemblyInfo.cs
|   |       
|   +---bin
|   |   \---Debug
|   |           CybotechDomain.dll.config
|   |           CybotechDomain.dll
|   |           CybotechDomain.pdb
|   |           
|   \---obj
|       \---Debug
|           |   DesignTimeResolveAssemblyReferencesInput.cache
|           |   CybotechDomain.pdb
|           |   CybotechDomain.dll
|           |   CybotechDomain.csproj.FileListAbsolute.txt
|           |   
|           \---TempPE
+---LibraryData
|   |   App.config
|   |   LibraryData.csproj
|   |   packages.config
|   |   
|   +---Data
|   |       BookRepository.cs
|   |       CourseRepository.cs
|   |       FacultyRepository.cs
|   |       IRepository.cs
|   |       IUnitOfWork.cs
|   |       LibraryContext.cs
|   |       LibraryInitializer.cs
|   |       LibraryUnitOfWork.cs
|   |       StudentRepository.cs
|   |       
|   +---Properties
|   |       AssemblyInfo.cs
|   |       
|   +---bin
|   |   \---Debug
|   |           CybotechDomain.dll
|   |           EntityFramework.dll
|   |           CybotechDomain.pdb
|   |           EntityFramework.xml
|   |           LibraryData.dll.config
|   |           LibraryData.dll
|   |           LibraryData.pdb
|   |           
|   \---obj
|       \---Debug
|           |   DesignTimeResolveAssemblyReferencesInput.cache
|           |   LibraryData.csprojResolveAssemblyReference.cache
|           |   LibraryData.pdb
|           |   LibraryData.dll
|           |   LibraryData.csproj.FileListAbsolute.txt
|           |   
|           \---TempPE
+---LibraryManager
|   |   LibraryManager.csproj
|   |   LibraryManager.csproj.DotSettings
|   |   Program.cs
|   |   app.config
|   |   packages.config
|   |   
|   +---Application
|   |       ApplicationModule.cs
|   |       Composition.cs
|   |       
|   +---Icons
|   |       books.ico
|   |       course.ico
|   |       
|   +---Images
|   |       add-16.png
|   |       add-24.png
|   |       book-32.png
|   |       book-48.png
|   |       book-issue.png
|   |       book-read.png
|   |       books.png
|   |       course.png
|   |       delete-16.png
|   |       delete-24.png
|   |       header.jpg
|   |       issue_book.png
|   |       lock-32.png
|   |       logo.PNG
|   |       orb.jpg
|   |       student-32.png
|   |       teacher-32.png
|   |       
|   +---Properties
|   |       AssemblyInfo.cs
|   |       Resources.Designer.cs
|   |       Resources.resx
|   |       Settings.Designer.cs
|   |       Settings.settings
|   |       
|   +---View
|   |       BookForm.Designer.cs
|   |       BookForm.cs
|   |       BookForm.resx
|   |       BookIssueForm.Designer.cs
|   |       BookIssueForm.cs
|   |       BookIssueForm.resx
|   |       BookListForm.Designer.cs
|   |       BookListForm.cs
|   |       BookListForm.resx
|   |       CourseForm.Designer.cs
|   |       CourseForm.cs
|   |       CourseForm.resx
|   |       Extensions.cs
|   |       FacultyAddForm.Designer.cs
|   |       FacultyAddForm.cs
|   |       FacultyAddForm.resx
|   |       InputBox.cs
|   |       InputForm.Designer.cs
|   |       InputForm.cs
|   |       InputForm.resx
|   |       LoginForm.Designer.cs
|   |       LoginForm.cs
|   |       LoginForm.resx
|   |       MainForm.Designer.cs
|   |       MainForm.cs
|   |       MainForm.resx
|   |       OfficeFormWithStatus.cs
|   |       StudentAddForm.Designer.cs
|   |       StudentAddForm.cs
|   |       StudentAddForm.resx
|   |       
|   +---bin
|   |   \---Debug
|   |       |   LibraryManager.vshost.exe.config
|   |       |   LibraryManager.vshost.exe.manifest
|   |       |   LibraryManager.vshost.exe
|   |       |   CybotechDomain.dll
|   |       |   EntityFramework.dll
|   |       |   Equin.ApplicationFramework.BindingListView.dll
|   |       |   LibraryData.dll
|   |       |   Ninject.dll
|   |       |   System.Data.SqlServerCe.dll
|   |       |   CybotechDomain.pdb
|   |       |   LibraryData.pdb
|   |       |   EntityFramework.xml
|   |       |   Equin.ApplicationFramework.BindingListView.pdb
|   |       |   Ninject.pdb
|   |       |   Ninject.xml
|   |       |   LibraryManager.exe.config
|   |       |   LibraryManager.exe
|   |       |   LibraryManager.pdb
|   |       |   
|   |       +---x86
|   |       |   |   sqlceca40.dll
|   |       |   |   sqlcecompact40.dll
|   |       |   |   sqlceer40EN.dll
|   |       |   |   sqlceme40.dll
|   |       |   |   sqlceqp40.dll
|   |       |   |   sqlcese40.dll
|   |       |   |   
|   |       |   \---Microsoft.VC90.CRT
|   |       |           Microsoft.VC90.CRT.manifest
|   |       |           msvcr90.dll
|   |       |           README_ENU.txt
|   |       |           
|   |       \---amd64
|   |           |   sqlceca40.dll
|   |           |   sqlcecompact40.dll
|   |           |   sqlceer40EN.dll
|   |           |   sqlceme40.dll
|   |           |   sqlceqp40.dll
|   |           |   sqlcese40.dll
|   |           |   
|   |           \---Microsoft.VC90.CRT
|   |                   Microsoft.VC90.CRT.manifest
|   |                   msvcr90.dll
|   |                   README_ENU.txt
|   |                   
|   \---obj
|       \---x86
|           \---Debug
|               |   DesignTimeResolveAssemblyReferencesInput.cache
|               |   LibraryManager.csproj.FileListAbsolute.txt
|               |   DesignTimeResolveAssemblyReferences.cache
|               |   LibraryManager.csprojResolveAssemblyReference.cache
|               |   Cybotech.Properties.Resources.resources
|               |   Cybotech.View.BookForm.resources
|               |   Cybotech.View.BookIssueForm.resources
|               |   Cybotech.View.BookListForm.resources
|               |   Cybotech.View.CourseForm.resources
|               |   Cybotech.View.FacultyAddForm.resources
|               |   Cybotech.View.InputForm.resources
|               |   Cybotech.View.LoginForm.resources
|               |   Cybotech.View.MainForm.resources
|               |   Cybotech.View.StudentAddForm.resources
|               |   LibraryManager.csproj.GenerateResource.Cache
|               |   LibraryManager.pdb
|               |   LibraryManager.exe
|               |   
|               \---TempPE
|                       Properties.Resources.Designer.cs.dll
|                       
+---LibraryTest
|   |   App.config
|   |   LibraryTest.csproj
|   |   LibraryTester.cs
|   |   packages.config
|   |   
|   +---Properties
|   |       AssemblyInfo.cs
|   |       
|   +---bin
|   |   \---Debug
|   |           CybotechDomain.dll
|   |           EntityFramework.dll
|   |           LibraryData.dll
|   |           CybotechDomain.pdb
|   |           LibraryData.pdb
|   |           EntityFramework.xml
|   |           LibraryTest.dll.config
|   |           LibraryTest.dll
|   |           LibraryTest.pdb
|   |           
|   \---obj
|       \---Debug
|           |   DesignTimeResolveAssemblyReferencesInput.cache
|           |   LibraryTest.csprojResolveAssemblyReference.cache
|           |   LibraryTest.pdb
|           |   LibraryTest.dll
|           |   LibraryTest.csproj.FileListAbsolute.txt
|           |   
|           \---TempPE
+---packages
|   |   repositories.config
|   |   
|   +---EntityFramework.4.3.1
|   |   |   EntityFramework.4.3.1.nuspec
|   |   |   EntityFramework.4.3.1.nupkg
|   |   |   
|   |   +---Content
|   |   |       App.config.transform
|   |   |       Web.config.transform
|   |   |       
|   |   +---lib
|   |   |   \---net40
|   |   |           EntityFramework.dll
|   |   |           EntityFramework.xml
|   |   |           
|   |   \---tools
|   |           EF4.3on.NET4.5Readme.txt
|   |           EntityFramework.PowerShell.dll
|   |           EntityFramework.psd1
|   |           EntityFramework.psm1
|   |           init.ps1
|   |           install.ps1
|   |           migrate.exe
|   |           
|   +---Ninject.3.0.1.10
|   |   |   Ninject.3.0.1.10.nuspec
|   |   |   Ninject.3.0.1.10.nupkg
|   |   |   
|   |   \---lib
|   |       +---net35
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---net40
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---net45-full
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---sl2
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---sl3-wp
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---sl3
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---sl4-windowsphone71
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       +---sl4
|   |       |       Ninject.dll
|   |       |       Ninject.pdb
|   |       |       Ninject.xml
|   |       |       
|   |       \---sl5
|   |               Ninject.dll
|   |               Ninject.pdb
|   |               Ninject.xml
|   |               
|   +---Microsoft.SqlServer.Compact.4.0.8876.1
|   |   |   SQLCE_EULA_ENU.rtf
|   |   |   Microsoft.SqlServer.Compact.4.0.8876.1.nuspec
|   |   |   Microsoft.SqlServer.Compact.4.0.8876.1.nupkg
|   |   |   
|   |   +---Content
|   |   |       web.config.transform
|   |   |       
|   |   +---lib
|   |   |   \---net40
|   |   |           System.Data.SqlServerCe.dll
|   |   |           
|   |   +---NativeBinaries
|   |   |   +---amd64
|   |   |   |   |   sqlceca40.dll
|   |   |   |   |   sqlcecompact40.dll
|   |   |   |   |   sqlceer40EN.dll
|   |   |   |   |   sqlceme40.dll
|   |   |   |   |   sqlceqp40.dll
|   |   |   |   |   sqlcese40.dll
|   |   |   |   |   
|   |   |   |   \---Microsoft.VC90.CRT
|   |   |   |           Microsoft.VC90.CRT.manifest
|   |   |   |           msvcr90.dll
|   |   |   |           README_ENU.txt
|   |   |   |           
|   |   |   \---x86
|   |   |       |   sqlceca40.dll
|   |   |       |   sqlcecompact40.dll
|   |   |       |   sqlceer40EN.dll
|   |   |       |   sqlceme40.dll
|   |   |       |   sqlceqp40.dll
|   |   |       |   sqlcese40.dll
|   |   |       |   
|   |   |       \---Microsoft.VC90.CRT
|   |   |               Microsoft.VC90.CRT.manifest
|   |   |               msvcr90.dll
|   |   |               README_ENU.txt
|   |   |               
|   |   \---tools
|   |           Install.ps1
|   |           Uninstall.ps1
|   |           VS.psd1
|   |           VS.psm1
|   |           
|   \---Unofficial.BindingListView.1.2.0.0
|       |   Unofficial.BindingListView.1.2.0.0.nuspec
|       |   Unofficial.BindingListView.1.2.0.0.nupkg
|       |   
|       \---lib
|           \---net20
|                   Equin.ApplicationFramework.BindingListView.dll
|                   Equin.ApplicationFramework.BindingListView.pdb
|                   
+---.hg
|   |   00changelog.i
|   |   requires
|   |   hgrc
|   |   cur-message.txt
|   |   
|   \---store
\---.nuget
        NuGet.targets
        NuGet.exe
        NuGet.Config

Answers


.hgignore doesn't affect files that have been added to the repository so the easiest way to do what you want is to ignore the packages folder and manually add the packages\repositories.config file.


Use a look ahead regexp entry in .hgignore

syntax: regexp
^library-management-system/packages/(?!repositories\.config).+$

Does that folder happen to be a NuGet package folder? In that case you can tell NuGet itself to ignore that folder, except for the config file: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

Of course this only applies if you are using your version control system integrated into Visual Studio.


Need Your Help

Print LinkedHashMap in table format

java iterator hashmap

I am looking for better algorithm to print a LinkedHashMap in table format by its key.

Printing on Silverlight

silverlight printing

I am trying to print a report where we have several different components within the xaml.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.