~ubuntu-branches/debian/jessie/bzr-git/jessie

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2011-08-07 15:43:09 UTC
  • mfrom: (1.1.20 upstream)
  • Revision ID: james.westby@ubuntu.com-20110807154309-3jroa5x6mehtf87h
Tags: 0.6.2-1
* New upstream release.
 + Depends on Dulwich 0.8.0.
 + Implements per_file_graph. LP: #677363

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
diff_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
325
325
    'GitDiffTree', 'Git am-style diff format')
326
326
 
 
327
 
 
328
def update_git_cache(repository, revid):
 
329
    """Update the git cache after a local commit."""
 
330
    if getattr(repository, "_git", None) is not None:
 
331
        return # No need to update cache for git repositories
 
332
 
 
333
    from bzrlib.plugins.git.object_store import BazaarObjectStore
 
334
    if not repository.control_transport.has("git"):
 
335
        return # No existing cache, don't bother updating
 
336
    store = BazaarObjectStore(repository)
 
337
    store.lock_write()
 
338
    try:
 
339
        store._update_sha_map_revision(revid)
 
340
    finally:
 
341
        store.unlock()
 
342
 
 
343
 
 
344
def post_commit_update_cache(local_branch, master_branch, old_revno, old_revid,
 
345
        new_revno, new_revid):
 
346
    if local_branch is not None:
 
347
        update_git_cache(local_branch.repository, new_revid)
 
348
    update_git_cache(master_branch.repository, new_revid)
 
349
 
 
350
 
 
351
try:
 
352
    from bzrlib.hooks import install_lazy_named_hook
 
353
except ImportError: # Compatibility with bzr < 2.4
 
354
    pass
 
355
else:
 
356
    install_lazy_named_hook("bzrlib.branch",
 
357
        "Branch.hooks", "post_commit", post_commit_update_cache,
 
358
        "git cache")
 
359
 
 
360
 
327
361
def test_suite():
328
362
    from bzrlib.plugins.git import tests
329
363
    return tests.test_suite()