# HG changeset patch # User Matt Mackall # Date 2015-05-26 12:44:37 # Node ID 61b3529e23778f542044d24bb1ccd5688516a7f0 # Parent 46bf4983cf31a651815a0599f012b5fe1b7f6db9 # Parent a973b050621d7489287856a125d1a706924447a1 merge with stable diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -341,6 +341,10 @@ class revbranchcache(object): 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 - diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -16,7 +16,7 @@ import match as matchmod 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 @@ class localrepository(object): _("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 @@ class localrepository(object): 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. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -329,7 +329,8 @@ def _getrevsource(repo, r): 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 user(repo, subset, x): 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 @@ class fullreposet(spanset): 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`. diff --git a/tests/test-glog.t b/tests/test-glog.t --- a/tests/test-glog.t +++ b/tests/test-glog.t @@ -2375,4 +2375,12 @@ should not draw line down to null due to 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 .. diff --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -29,7 +29,7 @@ commit hooks can see env vars $ 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 @@ pretxncommit and commit hooks can see bo $ 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 @@ pretxncommit and commit hooks can see bo $ 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 @@ pretxncommit and commit hooks can see bo (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 @@ tag hooks can see env vars $ 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 @@ more there after 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 @@ pushkey hook 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 diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -697,10 +697,10 @@ Test null revision $ 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 null revision 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 @@ tests for concatenation of strings/symbo $ 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')