changeset 25270:61b3529e2377

merge with stable
author Matt Mackall <mpm@selenic.com>
date Tue, 26 May 2015 07:44:37 -0500
parents 46bf4983cf31 (current diff) a973b050621d (diff)
children 1b1eaf1885df
files mercurial/localrepo.py mercurial/revset.py tests/test-glog.t tests/test-revset.t
diffstat 6 files changed, 70 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Mon May 25 11:06:49 2015 -0700
+++ b/mercurial/branchmap.py	Tue May 26 07:44:37 2015 -0500
@@ -341,6 +341,10 @@
         changelog = self._repo.changelog
         rbcrevidx = rev * _rbcrecsize
 
+        # avoid negative index, changelog.read(nullrev) is fast without cache
+        if rev == nullrev:
+            return changelog.branchinfo(rev)
+
         # if requested rev is missing, add and populate all missing revs
         if len(self._rbcrevs) < rbcrevidx + _rbcrecsize:
             self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize -
--- a/mercurial/localrepo.py	Mon May 25 11:06:49 2015 -0700
+++ b/mercurial/localrepo.py	Tue May 26 07:44:37 2015 -0500
@@ -16,7 +16,7 @@
 import merge as mergemod
 import tags as tagsmod
 from lock import release
-import weakref, errno, os, time, inspect
+import weakref, errno, os, time, inspect, random
 import branchmap, pathutil
 import namespaces
 propertycache = util.propertycache
@@ -959,7 +959,9 @@
                 _("abandoned transaction found"),
                 hint=_("run 'hg recover' to clean up transaction"))
 
-        self.hook('pretxnopen', throw=True, txnname=desc)
+        idbase = "%.40f#%f" % (random.random(), time.time())
+        txnid = 'TXN:' + util.sha1(idbase).hexdigest()
+        self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
 
         self._writejournal(desc)
         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
@@ -983,8 +985,7 @@
                                      self.store.createmode,
                                      validator=validate)
 
-        trid = 'TXN:' + util.sha1("%s#%f" % (id(tr), time.time())).hexdigest()
-        tr.hookargs['txnid'] = trid
+        tr.hookargs['txnid'] = txnid
         # note: writing the fncache only during finalize mean that the file is
         # outdated when running hooks. As fncache is used for streaming clone,
         # this is not expected to break anything that happen during the hooks.
--- a/mercurial/revset.py	Mon May 25 11:06:49 2015 -0700
+++ b/mercurial/revset.py	Tue May 26 07:44:37 2015 -0500
@@ -329,7 +329,8 @@
 
 def stringset(repo, subset, x):
     x = repo[x].rev()
-    if x in subset:
+    if (x in subset
+        or x == node.nullrev and isinstance(subset, fullreposet)):
         return baseset([x])
     return baseset()
 
@@ -1911,7 +1912,7 @@
 def wdir(repo, subset, x):
     # i18n: "wdir" is a keyword
     getargs(x, 0, 0, _("wdir takes no arguments"))
-    if None in subset:
+    if None in subset or isinstance(subset, fullreposet):
         return baseset([None])
     return baseset()
 
@@ -3470,11 +3471,6 @@
     def __init__(self, repo):
         super(fullreposet, self).__init__(repo)
 
-    def __contains__(self, rev):
-        # assumes the given rev is valid
-        hidden = self._hiddenrevs
-        return not (hidden and rev in hidden)
-
     def __and__(self, other):
         """As self contains the whole repo, all of the other set should also be
         in self. Therefore `self & other = other`.
--- a/tests/test-glog.t	Mon May 25 11:06:49 2015 -0700
+++ b/tests/test-glog.t	Tue May 26 07:44:37 2015 -0500
@@ -2375,4 +2375,12 @@
      summary:     add a
   
 
+  $ hg log -G -r 'branch(default)' | tail -6
+  |
+  o  changeset:   0:f8035bb17114
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     add a
+  
+
   $ cd ..
--- a/tests/test-hook.t	Mon May 25 11:06:49 2015 -0700
+++ b/tests/test-hook.t	Tue May 26 07:44:37 2015 -0500
@@ -29,7 +29,7 @@
   $ hg add a
   $ hg commit -m a
   precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
-  pretxnopen hook: HG_TXNNAME=commit
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
   0:cb9a9f314b8b
   pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
@@ -57,7 +57,7 @@
   $ echo b >> a
   $ hg commit -m a1 -d "1 0"
   precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
-  pretxnopen hook: HG_TXNNAME=commit
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
   1:ab228980c14d
   pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
@@ -70,7 +70,7 @@
   $ hg add b
   $ hg commit -m b -d '1 0'
   precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
-  pretxnopen hook: HG_TXNNAME=commit
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
   2:ee9deb46ab31
   pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
@@ -83,7 +83,7 @@
   (branch merge, don't forget to commit)
   $ hg commit -m merge -d '2 0'
   precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
-  pretxnopen hook: HG_TXNNAME=commit
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
   3:07f3376c1e65
   pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
@@ -127,7 +127,7 @@
   $ hg tag -d '3 0' a
   pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
   precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
-  pretxnopen hook: HG_TXNNAME=commit
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
   4:539e4b31b6dc
   pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
@@ -164,7 +164,7 @@
   4:539e4b31b6dc
   $ hg commit -m 'fail' -d '4 0'
   precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
-  pretxnopen hook: HG_TXNNAME=commit
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
   5:6f611f8018c1
   5:6f611f8018c1
@@ -228,7 +228,7 @@
   pushing to ../a
   searching for changes
   no changes found
-  pretxnopen hook: HG_TXNNAME=bookmarks
+  pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
   pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
   txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
   pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
--- a/tests/test-revset.t	Mon May 25 11:06:49 2015 -0700
+++ b/tests/test-revset.t	Tue May 26 07:44:37 2015 -0500
@@ -697,10 +697,10 @@
   $ log 'reverse(null:)' | tail -2
   0
   -1
+BROKEN: should be '-1'
   $ log 'first(null:)'
-  -1
+BROKEN: should be '-1'
   $ log 'min(null:)'
-  -1
   $ log 'tip:null and all()' | tail -2
   1
   0
@@ -708,9 +708,9 @@
 Test working-directory revision
   $ hg debugrevspec 'wdir()'
   None
+BROKEN: should include 'None'
   $ hg debugrevspec 'tip or wdir()'
   9
-  None
   $ hg debugrevspec '0:tip and wdir()'
 
   $ log 'outgoing()'
@@ -1702,6 +1702,46 @@
 
   $ cd ..
 
+prepare repository that has "default" branches of multiple roots
+
+  $ hg init namedbranch
+  $ cd namedbranch
+
+  $ echo default0 >> a
+  $ hg ci -Aqm0
+  $ echo default1 >> a
+  $ hg ci -m1
+
+  $ hg branch -q stable
+  $ echo stable2 >> a
+  $ hg ci -m2
+  $ echo stable3 >> a
+  $ hg ci -m3
+
+  $ hg update -q null
+  $ echo default4 >> a
+  $ hg ci -Aqm4
+  $ echo default5 >> a
+  $ hg ci -m5
+
+"null" revision belongs to "default" branch (issue4683)
+
+  $ log 'branch(null)'
+  0
+  1
+  4
+  5
+
+"null" revision belongs to "default" branch, but it shouldn't appear in set
+unless explicitly specified (issue4682)
+
+  $ log 'children(branch(default))'
+  1
+  2
+  5
+
+  $ cd ..
+
 test author/desc/keyword in problematic encoding
 # unicode: cp932:
 # u30A2    0x83 0x41(= 'A')