Dispose() public method

public Dispose ( ) : void
return void
        private void registerRepository(Key location, Repository db)
        {
            db.IncrementOpen();
            WeakReference<Repository> newRef = new WeakReference<Repository>(db);
            WeakReference<Repository> oldRef = cacheMap.put(location, newRef);
            Repository oldDb = oldRef != null ? oldRef.get() : null;
            if (oldDb != null)
                oldDb.Dispose();

        }
Example #2
0
        private void unregisterRepository(Key location)
        {
            WeakReferenceCustom <Repository> oldRef = cacheMap.GetValue(location);

            cacheMap.Remove(location);
            Repository oldDb = oldRef != null?oldRef.get() : null;

            if (oldDb != null)
            {
                oldDb.Dispose();
            }
        }
        private void clearAll()
        {
            for (int stage = 0; stage < 2; stage++)
            {
                var keysToRemove = new List<Key>();

                foreach (KeyValuePair<Key, WeakReference<Repository>> e in cacheMap)
                {
                    Repository db = e.Value.get();
                    if (db != null)
                        db.Dispose();

                    keysToRemove.Add(e.Key);
                }

                foreach (Key key in keysToRemove)
                {
                    cacheMap.Remove(key);
                }
            }
        }
Example #4
0
 public override void closeSelf()
 {
     _repository.Dispose();
 }
Example #5
0
        /// <summary>
        /// Do it.
        /// </summary>
        public override void Execute()
        {
            if (Source.Length <= 0)
            {
                throw new ArgumentException("fatal: You must specify a repository to clone.");
            }

            if (Directory != null && GitDirectory != null)
            {
                throw new ArgumentException("conflicting usage of --git-dir and arguments");
            }

            var source = new URIish(Source);

            if (Directory == null)
            {
                try
                {
                    Directory = source.getHumanishName();
                }
                catch (InvalidOperationException e)
                {
                    throw new ArgumentException("cannot guess local name from " + source, e);
                }
            }

            if (GitDirectory == null)
            {
                GitDirectory = Path.Combine(Directory, Constants.DOT_GIT);
            }

            if (Mirror)
                Bare = true;
            if (Bare)
            {
                if (OriginName != null)
                    throw new ArgumentException("Bare+Origin", "--bare and --origin " + OriginName + " options are incompatible.");
                NoCheckout = true;
            }
            if (OriginName == null)
                OriginName = Constants.DEFAULT_REMOTE_NAME;

            if (System.IO.Directory.Exists(Directory) && System.IO.Directory.GetFileSystemEntries(Directory).Length != 0)
            {
                throw new InvalidOperationException(string.Format("destination path '{0}' already exists and is not an empty directory.", new DirectoryInfo(Directory).FullName));
            }

            var repo = new Core.Repository(new DirectoryInfo(GitDirectory));
            repo.Create(Bare);
            repo.Config.setBoolean("core", null, "bare", Bare);
            repo.Config.save();
            Repository = new Repository(repo);
            if (!Quiet)
            {
                OutputStream.WriteLine("Initialized empty Git repository in " + repo.Directory.FullName);
                OutputStream.Flush();
            }

            saveRemote(source);

            FetchResult r;
            try
            {
                r = runFetch();
            }
            catch (NoRemoteRepositoryException)
            {
                Repository.Dispose();
                throw;
            }
            GitSharp.Core.Ref branch = guessHEAD(r);
            if (!NoCheckout)
                doCheckout(branch);
        }
Example #6
0
 public void Close()
 {
     _internal_repo.Dispose();
 }
Example #7
0
        /// <summary>
        /// Do it.
        /// </summary>
        public override void Execute()
        {
            if (Source.Length <= 0)
                throw new ArgumentNullException("Repository", "fatal: You must specify a repository to clone.");

            URIish source = new URIish(Source);

            if (Mirror)
                Bare = true;
            if (Bare)
            {
                if (OriginName != null)
                    throw new ArgumentException("Bare+Origin", "--bare and --origin " + OriginName + " options are incompatible.");
                NoCheckout = true;
            }
            if (OriginName == null)
                OriginName = Constants.DEFAULT_REMOTE_NAME;

            var repo = new GitSharp.Core.Repository(new DirectoryInfo(ActualDirectory));
            repo.Create(Bare);
            repo.Config.setBoolean("core", null, "bare", Bare);
            repo.Config.save();
            Repository = new Repository(repo);
            if (!Quiet)
            {
                OutputStream.WriteLine("Initialized empty Git repository in " + repo.Directory.FullName);
                OutputStream.Flush();
            }

            saveRemote(source);

            FetchResult r;
            try
            {
                r = runFetch();
            }
            catch (NoRemoteRepositoryException)
            {
                Repository.Dispose();
                throw;
            }
            GitSharp.Core.Ref branch = guessHEAD(r);
            if (!NoCheckout)
                doCheckout(branch);
        }