Mercurial > hg
changeset 4209:dbc3846c09a1
Merge with -stable, fix small test failure
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 14 Mar 2007 01:26:09 -0500 |
parents | bd9b84b9a84b (current diff) f80cf8b7bbd9 (diff) |
children | 5ccbc0be6cdb 6cb5be6bd70f |
files | hgext/mq.py mercurial/changelog.py mercurial/cmdutil.py mercurial/commands.py mercurial/context.py mercurial/dirstate.py mercurial/localrepo.py mercurial/merge.py tests/test-newbranch tests/test-newbranch.out |
diffstat | 18 files changed, 81 insertions(+), 148 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Tue Mar 13 21:54:34 2007 -0700 +++ b/hgext/mq.py Wed Mar 14 01:26:09 2007 -0500 @@ -1283,7 +1283,7 @@ return 1 self.applied.append(statusentry(revlog.hex(n),'.hg.patches.save.line')) self.applied_dirty = 1 - self.removeundo(undo) + self.removeundo(repo) def full_series_end(self): if len(self.applied) > 0:
--- a/mercurial/changelog.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/changelog.py Wed Mar 14 01:26:09 2007 -0500 @@ -58,7 +58,7 @@ changelog v0 doesn't use extra """ if not text: - return (nullid, "", (0, 0), [], "", {}) + return (nullid, "", (0, 0), [], "", {'branch': 'default'}) last = text.index("\n\n") desc = util.tolocal(text[last + 2:]) l = text[:last].split('\n') @@ -78,6 +78,8 @@ time, timezone, extra = extra_data time, timezone = float(time), int(timezone) extra = self.decode_extra(extra) + if not extra.get('branch'): + extra['branch'] = 'default' files = l[3:] return (manifest, user, (time, timezone), files, desc, extra) @@ -93,6 +95,8 @@ parseddate = "%d %d" % util.parsedate(date) else: parseddate = "%d %d" % util.makedate() + if extra and extra.get("branch") in ("default", ""): + del extra["branch"] if extra: extra = self.encode_extra(extra) parseddate = "%s %s" % (parseddate, extra)
--- a/mercurial/cmdutil.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/cmdutil.py Wed Mar 14 01:26:09 2007 -0500 @@ -263,7 +263,8 @@ self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode))) - if branch: + # don't show the default branch name + if branch != 'default': branch = util.tolocal(branch) self.ui.write(_("branch: %s\n") % branch) for tag in self.repo.nodetags(changenode): @@ -402,7 +403,7 @@ def showbranches(**args): branch = changes[5].get("branch") - if branch: + if branch != 'default': branch = util.tolocal(branch) return showlist('branch', [branch], plural='branches', **args)
--- a/mercurial/commands.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/commands.py Wed Mar 14 01:26:09 2007 -0500 @@ -257,16 +257,14 @@ branch name that shadows an existing branch. """ - if label is not None: + if label: if not opts.get('force') and label in repo.branchtags(): if label not in [p.branch() for p in repo.workingctx().parents()]: raise util.Abort(_('a branch of the same name already exists' ' (use --force to override)')) - repo.opener("branch", "w").write(util.fromlocal(label) + '\n') + repo.dirstate.setbranch(util.fromlocal(label)) else: - b = util.tolocal(repo.workingctx().branch()) - if b: - ui.write("%s\n" % b) + ui.write("%s\n" % util.tolocal(repo.dirstate.branch())) def branches(ui, repo): """list repository named branches @@ -1446,7 +1444,7 @@ if not ui.quiet: branch = util.tolocal(repo.workingctx().branch()) - if branch: + if branch != 'default': output.append("(%s)" % branch) # multiple tags for a single parent separated by '/'
--- a/mercurial/context.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/context.py Wed Mar 14 01:26:09 2007 -0500 @@ -66,7 +66,7 @@ def date(self): return self._changeset[2] def files(self): return self._changeset[3] def description(self): return self._changeset[4] - def branch(self): return self._changeset[5].get("branch", "") + def branch(self): return self._changeset[5].get("branch") def parents(self): """return contexts for each parent changeset""" @@ -412,11 +412,7 @@ def deleted(self): return self._status[3] def unknown(self): return self._status[4] def clean(self): return self._status[5] - def branch(self): - try: - return self._repo.opener("branch").read().strip() - except IOError: - return "" + def branch(self): return self._repo.dirstate.branch() def parents(self): """return contexts for each parent changeset"""
--- a/mercurial/dirstate.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/dirstate.py Wed Mar 14 01:26:09 2007 -0500 @@ -24,6 +24,7 @@ self.dirs = None self.copymap = {} self.ignorefunc = None + self._branch = None def wjoin(self, f): return os.path.join(self.root, f) @@ -136,6 +137,15 @@ self.lazyread() return self.pl + def branch(self): + if not self._branch: + try: + self._branch = self.opener("branch").read().strip()\ + or "default" + except IOError: + self._branch = "default" + return self._branch + def markdirty(self): if not self.dirty: self.dirty = 1 @@ -145,6 +155,10 @@ self.markdirty() self.pl = p1, p2 + def setbranch(self, branch): + self._branch = branch + self.opener("branch", "w").write(branch + '\n') + def state(self, key): try: return self[key][0]
--- a/mercurial/localrepo.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/localrepo.py Wed Mar 14 01:26:09 2007 -0500 @@ -15,7 +15,6 @@ class localrepository(repo.repository): capabilities = ('lookup', 'changegroupsubset') supported = ('revlogv1', 'store') - branchcache_features = ('unnamed',) def __del__(self): self.transhandle = None @@ -395,25 +394,9 @@ def _readbranchcache(self): partial = {} try: - f = self.opener("branches.cache") + f = self.opener("branch.cache") lines = f.read().split('\n') f.close() - features = lines.pop(0).strip() - if not features.startswith('features: '): - raise ValueError(_('branch cache: no features specified')) - features = features.split(' ', 1)[1].split() - missing_features = [] - for feature in self.branchcache_features: - try: - features.remove(feature) - except ValueError, inst: - missing_features.append(feature) - if missing_features: - raise ValueError(_('branch cache: missing features: %s') - % ', '.join(missing_features)) - if features: - raise ValueError(_('branch cache: unknown features: %s') - % ', '.join(features)) last, lrev = lines.pop(0).split(" ", 1) last, lrev = bin(last), int(lrev) if not (lrev < self.changelog.count() and @@ -434,8 +417,7 @@ def _writebranchcache(self, branches, tip, tiprev): try: - f = self.opener("branches.cache", "w") - f.write(" features: %s\n" % ' '.join(self.branchcache_features)) + f = self.opener("branch.cache", "w") f.write("%s %s\n" % (hex(tip), tiprev)) for label, node in branches.iteritems(): f.write("%s %s\n" % (hex(node), label)) @@ -759,7 +741,7 @@ branchname = "" if use_dirstate: - oldname = c1[5].get("branch", "") # stored in UTF-8 + oldname = c1[5].get("branch") # stored in UTF-8 if not commit and not remove and not force and p2 == nullid and \ branchname == oldname: self.ui.status(_("nothing changed\n"))
--- a/mercurial/merge.py Tue Mar 13 21:54:34 2007 -0700 +++ b/mercurial/merge.py Wed Mar 14 01:26:09 2007 -0500 @@ -493,9 +493,9 @@ if not partial: recordupdates(repo, action, branchmerge) repo.dirstate.setparents(fp1, fp2) + if not branchmerge: + repo.dirstate.setbranch(p2.branch()) repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) - if not branchmerge: - repo.opener("branch", "w").write(p2.branch() + "\n") return stats
--- a/tests/test-diffdir Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-diffdir Wed Mar 14 01:26:09 2007 -0500 @@ -1,7 +1,6 @@ #!/bin/sh hg init -hg branch dummy # needed so -r "" doesn't point to the unnamed/default branch touch a hg add a hg ci -m "a" -d "1000000 0"
--- a/tests/test-diffdir.out Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-diffdir.out Wed Mar 14 01:26:09 2007 -0500 @@ -1,19 +1,19 @@ -diff -r 4da5fa99f904 b +diff -r acd8075edac9 b --- /dev/null +++ b/b @@ -0,0 +1,1 @@ +123 -diff -r 4da5fa99f904 b +diff -r acd8075edac9 b --- /dev/null +++ b/b @@ -0,0 +1,1 @@ +123 -diff -r 4da5fa99f904 a +diff -r acd8075edac9 a --- a/a +++ b/a @@ -0,0 +1,1 @@ +foo -diff -r 4da5fa99f904 b +diff -r acd8075edac9 b --- /dev/null +++ b/b @@ -0,0 +1,1 @@
--- a/tests/test-encoding.out Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-encoding.out Wed Mar 14 01:26:09 2007 -0500 @@ -126,13 +126,13 @@ é 3:770b9b11621d % ascii ? 5:db5520b4645f - 4:9cff3c980b58 +default 4:9cff3c980b58 % latin-1 é 5:db5520b4645f - 4:9cff3c980b58 +default 4:9cff3c980b58 % utf-8 é 5:db5520b4645f - 4:9cff3c980b58 +default 4:9cff3c980b58 % utf-8 changeset: 5:db5520b4645f branch: é
--- a/tests/test-globalopts.out Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-globalopts.out Wed Mar 14 01:26:09 2007 -0500 @@ -91,6 +91,7 @@ user: test date: Thu Jan 01 00:00:01 1970 +0000 files+: b +extra: branch=default description: b @@ -102,6 +103,7 @@ user: test date: Thu Jan 01 00:00:01 1970 +0000 files+: a +extra: branch=default description: a
--- a/tests/test-log Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-log Wed Mar 14 01:26:09 2007 -0500 @@ -47,7 +47,6 @@ # log --follow tests hg init ../follow cd ../follow -hg branch dummy # needed so -r "" doesn't point to the unnamed/default branch echo base > base hg ci -Ambase -d '1 0'
--- a/tests/test-log.out Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-log.out Wed Mar 14 01:26:09 2007 -0500 @@ -105,22 +105,19 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding b1 % log -f -changeset: 3:07a62f044f0d -branch: dummy +changeset: 3:e62f78d544b4 tag: tip -parent: 1:fb3d4e35b279 +parent: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b1 -changeset: 1:fb3d4e35b279 -branch: dummy +changeset: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: r1 -changeset: 0:ea445bfed6b9 -branch: dummy +changeset: 0:67e992f2c4f3 user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: base @@ -128,21 +125,18 @@ 1 files updated, 0 files merged, 1 files removed, 0 files unresolved adding b2 % log -f -r 1:tip -changeset: 1:fb3d4e35b279 -branch: dummy +changeset: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: r1 -changeset: 2:e8882cbc828c -branch: dummy +changeset: 2:60c670bf5b30 user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: r2 -changeset: 3:07a62f044f0d -branch: dummy -parent: 1:fb3d4e35b279 +changeset: 3:e62f78d544b4 +parent: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b1 @@ -151,66 +145,57 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) % log --follow-first -changeset: 6:0f621dafa603 -branch: dummy +changeset: 6:2404bbcab562 tag: tip user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b1.1 -changeset: 5:0cf53fb6dfd5 -branch: dummy -parent: 3:07a62f044f0d -parent: 4:b76598590bc3 +changeset: 5:302e9dd6890d +parent: 3:e62f78d544b4 +parent: 4:ddb82e70d1a1 user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: m12 -changeset: 3:07a62f044f0d -branch: dummy -parent: 1:fb3d4e35b279 +changeset: 3:e62f78d544b4 +parent: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b1 -changeset: 1:fb3d4e35b279 -branch: dummy +changeset: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: r1 -changeset: 0:ea445bfed6b9 -branch: dummy +changeset: 0:67e992f2c4f3 user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: base % log -P 2 -changeset: 6:0f621dafa603 -branch: dummy +changeset: 6:2404bbcab562 tag: tip user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b1.1 -changeset: 5:0cf53fb6dfd5 -branch: dummy -parent: 3:07a62f044f0d -parent: 4:b76598590bc3 +changeset: 5:302e9dd6890d +parent: 3:e62f78d544b4 +parent: 4:ddb82e70d1a1 user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: m12 -changeset: 4:b76598590bc3 -branch: dummy -parent: 0:ea445bfed6b9 +changeset: 4:ddb82e70d1a1 +parent: 0:67e992f2c4f3 user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b2 -changeset: 3:07a62f044f0d -branch: dummy -parent: 1:fb3d4e35b279 +changeset: 3:e62f78d544b4 +parent: 1:3d5bf5654eda user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: b1
--- a/tests/test-mq-caches Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-mq-caches Wed Mar 14 01:26:09 2007 -0500 @@ -5,7 +5,7 @@ show_branch_cache() { - branches=.hg/branches.cache + branches=.hg/branch.cache # force cache (re)generation hg log -r does-not-exist 2> /dev/null hg log -r tip --template 'tip: #rev#\n' @@ -61,7 +61,7 @@ echo echo '# removing the cache' -rm .hg/branches.cache +rm .hg/branch.cache show_branch_cache 1 echo
--- a/tests/test-mq-caches.out Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-mq-caches.out Wed Mar 14 01:26:09 2007 -0500 @@ -1,13 +1,12 @@ # mq patch on an empty repo tip: 0 -No .hg/branches.cache +No .hg/branch.cache tip: 0 -No .hg/branches.cache +No .hg/branch.cache # some regular revisions Patch queue now empty tip: 1 - features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -16,12 +15,10 @@ applying p1 Now at: p1 tip: 2 - features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo tip: 3 - features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -30,7 +27,6 @@ # removing the cache tip: 3 - features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -39,7 +35,6 @@ # importing rev 1 (the cache now ends in one of the patches) tip: 3 - features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -54,6 +49,5 @@ applying p2 Now at: p2 tip: 3 - features: unnamed 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
--- a/tests/test-newbranch Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-newbranch Wed Mar 14 01:26:09 2007 -0500 @@ -13,8 +13,8 @@ hg branch bar hg ci -m "change branch name" -d "1000000 0" echo % branch shadowing -hg branch "" -hg branch -f '' +hg branch default +hg branch -f default hg ci -m "clear branch name" -d "1000000 0" hg co foo @@ -32,39 +32,14 @@ echo % test for invalid branch cache hg rollback -cp .hg/branches.cache .hg/bc-invalid +cp .hg/branch.cache .hg/bc-invalid hg log -r foo -cp .hg/bc-invalid .hg/branches.cache +cp .hg/bc-invalid .hg/branch.cache hg --debug log -r foo -rm .hg/branches.cache -echo corrupted > .hg/branches.cache +rm .hg/branch.cache +echo corrupted > .hg/branch.cache hg log -qr foo -cat .hg/branches.cache - -echo % test for different branch cache features -echo '4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4' > .hg/branches.cache -hg branches --debug -echo ' features: unnamed dummy foo bar' > .hg/branches.cache -hg branches --debug -echo ' features: dummy' > .hg/branches.cache -hg branches --debug - -echo % test old hg reading branch cache with feature list -python << EOF -import binascii -f = file('.hg/branches.cache') -lines = f.read().split('\n') -f.close() -firstline = lines[0] -last, lrev = lines.pop(0).rstrip().split(" ", 1) -try: - last, lrev = binascii.unhexlify(last), int(lrev) -except ValueError, inst: - if str(inst) == "invalid literal for int():%s" % firstline: - print "ValueError raised correctly, good." - else: - print "ValueError: %s" % inst -EOF +cat .hg/branch.cache echo % update with no arguments: tipmost revision of the current branch hg up -q -C 0
--- a/tests/test-newbranch.out Tue Mar 13 21:54:34 2007 -0700 +++ b/tests/test-newbranch.out Wed Mar 14 01:26:09 2007 -0500 @@ -45,10 +45,10 @@ summary: initial foo 5:5f8fb06e083e - 3:bf1bc2f45e83 +default 3:bf1bc2f45e83 bar 2:67ec16bde7f1 foo - +default bar % test for invalid branch cache rolling back last transaction @@ -76,26 +76,10 @@ 4:4909a3732169 - features: unnamed 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4 -bf1bc2f45e834c75404d0ddab57d53beab56e2f8 +bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo 67ec16bde7f1575d523313b9bca000f6a6f12dca bar -% test for different branch cache features -branch cache: no features specified -foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f - 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8 -bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca -branch cache: unknown features: dummy, foo, bar -foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f - 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8 -bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca -branch cache: missing features: unnamed -foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f - 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8 -bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca -% test old hg reading branch cache with feature list -ValueError raised correctly, good. % update with no arguments: tipmost revision of the current branch bf1bc2f45e83 4909a3732169 (foo) tip