# HG changeset patch # User Siddharth Agarwal <sid0@fb.com> # Date 1394004050 28800 # Tue Mar 04 23:20:50 2014 -0800 # Node ID 5e74edb7a62d726e9314d09a8ae48b0e3515d8f3 # Parent 4e0e9e25b03b2e4c2056f133d799eea90c649174 safebranchrevs: handle changelog having no commits The usage of getattr was unsafe. Use hgutil.safehasattr instead. util.safehasattr has been around since Mercurial 2.0. This also fixes the formerly disabled test in test-pull.t. diff --git a/hggit/__init__.py b/hggit/__init__.py --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -94,7 +94,7 @@ # 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: + if hgutil.safehasattr(lrepo, 'changelog') and co not in lrepo.changelog: co = None return revs, co if getattr(hg, 'addbranchrevs', False): diff --git a/tests/test-pull.t b/tests/test-pull.t --- a/tests/test-pull.t +++ b/tests/test-pull.t @@ -18,14 +18,15 @@ $ fn_git_commit -m 'add delta' $ cd .. -clone a tag (ideally we'd want to pull it, but that seems broken for now) -# $ hg init hgrepo -# $ echo "[paths]" >> hgrepo/.hg/hgrc -# $ echo "default=$TESTTMP/gitrepo" >> hgrepo/.hg/hgrc -# $ hg -R hgrepo pull -r t_alpha - $ hg clone -r t_alpha gitrepo hgrepo +pull a tag + $ hg init hgrepo + $ echo "[paths]" >> hgrepo/.hg/hgrc + $ echo "default=$TESTTMP/gitrepo" >> hgrepo/.hg/hgrc + $ hg -R hgrepo pull -r t_alpha + pulling from $TESTTMP/gitrepo importing git objects into hg - updating to branch default + (run 'hg update' to get a working copy) + $ hg -R hgrepo update t_alpha 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg -R hgrepo log --graph @ changeset: 0:3442585be8a6