changeset 707:5e74edb7a62d

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.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 04 Mar 2014 23:20:50 -0800
parents 4e0e9e25b03b
children d5facc1be5f8
files hggit/__init__.py tests/test-pull.t
diffstat 2 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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):
--- 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