merge with stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 12 Aug 2015 20:38:39 -0700
changeset 1491 8f469f81129c
parent 1488 3dec62fc266e (current diff)
parent 1490 bc7eec65dfcf (diff)
child 1492 f869033391b9
merge with stable
hgext/inhibit.py
tests/test-inhibit.t
--- a/hgext/directaccess.py	Mon Aug 10 00:44:53 2015 -0700
+++ b/hgext/directaccess.py	Wed Aug 12 20:38:39 2015 -0700
@@ -13,6 +13,7 @@
 from mercurial import error
 from mercurial import commands
 from mercurial import hg
+from mercurial import util
 from mercurial.i18n import _
 
 cmdtable = {}
@@ -126,6 +127,8 @@
     extensions.wrapfunction(hg, 'repository', _repository)
     setupdirectaccess()
 
+hashre = util.re.compile('[0-9a-fA-F]{1,40}')
+
 def gethashsymbols(tree):
     # Returns the list of symbols of the tree that look like hashes
     # for example for the revset 3::abe3ff it will return ('abe3ff')
@@ -137,7 +140,9 @@
             int(tree[1])
             return []
         except ValueError as e:
-            return [tree[1]]
+            if hashre.match(tree[1]):
+                return [tree[1]]
+            return []
     elif len(tree) == 3:
         return gethashsymbols(tree[1]) + gethashsymbols(tree[2])
     else:
--- a/hgext/inhibit.py	Mon Aug 10 00:44:53 2015 -0700
+++ b/hgext/inhibit.py	Wed Aug 12 20:38:39 2015 -0700
@@ -23,11 +23,15 @@
 from mercurial import commands
 from mercurial import lock as lockmod
 from mercurial import bookmarks
+from mercurial import util
 from mercurial.i18n import _
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 
+def _inhibitenabled(repo):
+    return util.safehasattr(repo, '_obsinhibit')
+
 def reposetup(ui, repo):
 
     class obsinhibitedrepo(repo.__class__):
@@ -122,6 +126,9 @@
     Content of <nodes> and all mutable ancestors are considered. Marker for
     obsolete revision only are created.
     """
+    if not _inhibitenabled(repo):
+        return
+
     newinhibit = repo.set('::%ln and obsolete()', nodes)
     if newinhibit:
         lock = tr = None
@@ -141,6 +148,9 @@
     This will be triggered when inhibited nodes received new obsolescence
     markers. Otherwise the new obsolescence markers would also be inhibited.
     """
+    if not _inhibitenabled(repo):
+        return
+
     deinhibited = repo._obsinhibit & set(nodes)
     if deinhibited:
         tr = repo.transaction('obsinhibit')
@@ -177,7 +187,7 @@
         if visibleobsolete:
             _inhibitmarkers(repo, [repo[r].node() for r in visibleobsolete])
     transaction = orig(repo, desc, *args, **kwargs)
-    if desc != 'strip':
+    if desc != 'strip' and _inhibitenabled(repo):
         transaction.addpostclose('inhibitposttransaction', inhibitposttransaction)
     return transaction
 
@@ -190,9 +200,10 @@
 
         This will trickle down to other part of mercurial (hidden, log, etc)"""
         obs = obsfunc(repo)
-        getrev = repo.changelog.nodemap.get
-        for n in repo._obsinhibit:
-            obs.discard(getrev(n))
+        if _inhibitenabled(repo):
+            getrev = repo.changelog.nodemap.get
+            for n in repo._obsinhibit:
+                obs.discard(getrev(n))
         return obs
     try:
         extensions.find('directaccess')
--- a/tests/test-inhibit.t	Mon Aug 10 00:44:53 2015 -0700
+++ b/tests/test-inhibit.t	Wed Aug 12 20:38:39 2015 -0700
@@ -763,3 +763,21 @@
   adding file changes
   added 1 changesets with 1 changes to 1 files
   2 new obsolescence markers
+
+Pulling from a inhibit repo to a non-inhibit repo should work
+
+  $ cd ..
+  $ hg clone -q inhibit not-inhibit
+  $ cat >> not-inhibit/.hg/hgrc <<EOF
+  > [extensions]
+  > inhibit=!
+  > directaccess=!
+  > evolve=!
+  > EOF
+  $ cd not-inhibit
+  $ hg book -d foo
+  $ hg pull
+  pulling from $TESTTMP/inhibit
+  searching for changes
+  no changes found
+  adding remote bookmark foo