# HG changeset patch # User Augie Fackler # Date 1269566580 18000 # Node ID a90fe3e8a8c355dce44eae246e1df3f0c471c7de # Parent 32456f9cb7a48de80a1d94ee22bf6f4ca9aa84dd hggit: defend against exceptions when pulling with -r diff --git a/hggit/__init__.py b/hggit/__init__.py --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -55,6 +55,14 @@ return hgdefaultdest(source) hg.defaultdest = defaultdest +# defend against tracebacks if we specify -r in 'hg pull' +def safebranchrevs(orig, lrepo, repo, branches, revs): + revs, co = orig(lrepo, repo, branches, revs) + if getattr(lrepo, 'changelog', False) and co not in lrepo.changelog: + co = None + return revs, co +extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) + def reposetup(ui, repo): if not isinstance(repo, gitrepo.gitrepo): klass = hgrepo.generate_repo_subclass(repo.__class__)