# HG changeset patch # User mpm@selenic.com # Date 1118824437 28800 # Node ID b4e0e20646bbdd28ff6a7739250d6bd501445822 # Parent f69a5d2d4fe1ecb6dbe1ca4a8ee5be2fc9397402# Parent b2293093b89e176707a3250f3e861382a0578aff Merge with TAH -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Merge with TAH manifest hash: ec82cc2d7b7357fd7db4917e09d7d6865482de58 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCr+f1ywK+sNU5EO8RAuPtAJ0WilDBo3iG4S/dmIabhzYW987TtgCgkjkM 8OmatsrjG01iJAhkKJj+XnQ= =mOLr -----END PGP SIGNATURE----- diff --git a/contrib/hgit b/contrib/hgit diff --git a/hgeditor b/hgeditor diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -126,18 +126,6 @@ def show_changeset(ui, repo, rev=0, chan ui.status("summary: %s\n" % description.splitlines()[0]) ui.status("\n") -def tags_load(repo): - repo.lookup(0) # prime the cache - i = repo.tags.items() - n = [] - for e in i: - try: - l = repo.changelog.rev(e[1]) - except KeyError: - l = -2 - n.append((l, e)) - return n - def help(ui, cmd=None): '''show help for a given command or all commands''' if cmd: @@ -328,17 +316,15 @@ def identify(ui, repo): """print information about the working copy""" (c, a, d, u) = repo.diffdir(repo.root) mflag = (c or a or d or u) and "+" or "" - parents = [parent for parent in repo.dirstate.parents() - if parent != hg.nullid] + parents = [p for p in repo.dirstate.parents() if p != hg.nullid] if not parents: - ui.note("unknown\n") + ui.write("unknown\n") return tstring = '' if not ui.quiet: - taglist = [e[1] for e in tags_load(repo)] - tstring = " %s" % ' + '.join([e[0] for e in taglist - if e[0] != 'tip' and e[1] in parents]) + tags = sum(map(repo.nodetags, parents), []) + tstring = " " + ' + '.join(tags) hexfunc = ui.verbose and hg.hex or hg.short pstring = '+'.join([hexfunc(parent) for parent in parents]) @@ -544,17 +530,15 @@ def status(ui, repo): def tags(ui, repo): """list repository tags""" - n = tags_load(repo) - - n.sort() - n.reverse() - i = [ e[1] for e in n ] - for k, n in i: + + l = repo.tagslist() + l.reverse() + for t,n in l: try: r = repo.changelog.rev(n) except KeyError: r = "?" - print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) + print "%-30s %5d:%s" % (t, repo.changelog.rev(n), hg.hex(n)) def tip(ui, repo): """show the tip revision""" diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -334,7 +334,8 @@ class localrepository: self.manifest = manifest(self.opener) self.changelog = changelog(self.opener) self.ignorelist = None - self.tags = None + self.tagscache = None + self.nodetagscache = None if not self.remote: self.dirstate = dirstate(self.opener, ui, self.root) @@ -355,9 +356,10 @@ class localrepository: if pat.search(f): return True return False - def lookup(self, key): - if self.tags is None: - self.tags = {} + def tags(self): + '''return a mapping of tag to node''' + if not self.tagscache: + self.tagscache = {} try: # read each head of the tags file, ending with the tip # and add each tag found to the map, with "newer" ones @@ -369,11 +371,35 @@ class localrepository: for l in fl.revision(r).splitlines(): if l: n, k = l.split(" ") - self.tags[k] = bin(n) + self.tagscache[k] = bin(n) except KeyError: pass - self.tags['tip'] = self.changelog.tip() + self.tagscache['tip'] = self.changelog.tip() + + return self.tagscache + + def tagslist(self): + '''return a list of tags ordered by revision''' + l = [] + for t,n in self.tags().items(): + try: + r = self.changelog.rev(n) + except: + r = -2 # sort to the beginning of the list if unknown + l.append((r,t,n)) + l.sort() + return [(t,n) for r,t,n in l] + + def nodetags(self, node): + '''return the tags associated with a node''' + if not self.nodetagscache: + self.nodetagscache = {} + for t,n in self.tags().items(): + self.nodetagscache.setdefault(n,[]).append(t) + return self.nodetagscache.get(node, []) + + def lookup(self, key): try: - return self.tags[key] + return self.tags()[key] except KeyError: return self.changelog.lookup(key) @@ -998,8 +1024,7 @@ class localrepository: remove.append(f) # other deleted it else: if n == m1.get(f, nullid): # same as parent - self.ui.debug("remote deleted %s\n" % f) - remove.append(f) + self.ui.debug("local created %s, keeping\n" % f) else: self.ui.debug("working dir created %s, keeping\n" % f) @@ -1093,8 +1118,8 @@ class localrepository: fl = self.file(fn) base = fl.ancestor(my, other) a = self.wjoin(fn) - b = temp("other", other) - c = temp("base", base) + b = temp("base", base) + c = temp("other", other) self.ui.note("resolving %s\n" % fn) self.ui.debug("file %s: other %s ancestor %s\n" % diff --git a/mercurial/hgweb.py b/mercurial/hgweb.py --- a/mercurial/hgweb.py +++ b/mercurial/hgweb.py @@ -523,12 +523,8 @@ class hgweb: cl = self.repo.changelog mf = cl.read(cl.tip())[0] - self.repo.lookup(0) # prime the cache - i = self.repo.tags.items() - n = [ (cl.rev(e[1]), e) for e in i ] # sort by revision - n.sort() - n.reverse() - i = [ e[1] for e in n ] + i = self.repo.tagslist() + i.reverse() def entries(): parity = 0 diff --git a/mercurial/ui.py b/mercurial/ui.py diff --git a/tests/README b/tests/README diff --git a/tests/run-tests b/tests/run-tests --- a/tests/run-tests +++ b/tests/run-tests @@ -28,6 +28,7 @@ for f in `ls test-* | grep -Ev "\.|~"` ; echo $f output changed: diff -u $H/$f.out .out && true cp .out $H/$f.err + fail=1 fi cd $H diff --git a/tests/test-basic b/tests/test-basic diff --git a/tests/test-basic.out b/tests/test-basic.out diff --git a/tests/test-conflict b/tests/test-conflict new file mode 100755 --- /dev/null +++ b/tests/test-conflict @@ -0,0 +1,17 @@ +#!/bin/bash + +set -x +hg init +echo "nothing" > a +hg add a +hg commit -t ancestor -u test -d "0 0" +echo "something" > a +hg commit -t branch1 -u test -d "0 0" +hg co 0 +echo "something else" > a +hg commit -t branch2 -u test -d "0 0" +export HGMERGE=merge +hg -d up -m 1 +hg id +cat a | grep -v ">>>" | grep -v "<<<" +hg status diff --git a/tests/test-conflict.out b/tests/test-conflict.out new file mode 100644 --- /dev/null +++ b/tests/test-conflict.out @@ -0,0 +1,32 @@ ++ hg init ++ echo nothing ++ hg add a ++ hg commit -t ancestor -u test -d '0 0' ++ echo something ++ hg commit -t branch1 -u test -d '0 0' ++ hg co 0 ++ echo 'something else' ++ hg commit -t branch2 -u test -d '0 0' ++ export HGMERGE=merge ++ HGMERGE=merge ++ hg -d up -m 1 +merge: warning: conflicts during merge +resolving manifests + ancestor 1c6e5a12 local 35fedfab remote a5801785 + a versions differ, resolve +working dir created .out, keeping +merging a +resolving a +file a: other d7250518 ancestor 68ba9db7 +merging a failed! ++ hg id +32e80765+75234512+ tip ++ cat a ++ grep -v '>>>' ++ grep -v '<<<' +something else +======= +something ++ hg status +C a +? .out diff --git a/tests/test-help b/tests/test-help diff --git a/tests/test-help.out b/tests/test-help.out --- a/tests/test-help.out +++ b/tests/test-help.out @@ -12,6 +12,7 @@ hg commands: heads show current repository heads help show help for a given command or all commands history show the changelog history + identify print information about the working copy init create a new repository or copy an existing one log show the revision history of a single file manifest output the latest or given revision of the project manifest @@ -58,6 +59,7 @@ hg commands: heads show current repository heads help show help for a given command or all commands history show the changelog history + identify print information about the working copy init create a new repository or copy an existing one log show the revision history of a single file manifest output the latest or given revision of the project manifest diff --git a/tests/test-pull b/tests/test-pull diff --git a/tests/test-pull.out b/tests/test-pull.out diff --git a/tests/test-simple-update b/tests/test-simple-update diff --git a/tests/test-simple-update.out b/tests/test-simple-update.out diff --git a/tests/test-tags b/tests/test-tags new file mode 100755 --- /dev/null +++ b/tests/test-tags @@ -0,0 +1,34 @@ +#!/bin/bash + +set -x +mkdir t +cd t +hg init +hg id +echo a > a +hg add a +hg commit -t "test" -u test -d "0 0" +hg co +hg identify +T=`hg -q tip | cut -d : -f 2` +echo "$T first" > .hgtags +cat .hgtags +hg add .hgtags +hg commit -t "add tags" -u test -d "0 0" +hg tags +hg identify +echo bb > a +hg status +hg identify +hg co first +hg id +hg -v id +hg status +echo 1 > b +hg add b +hg commit -t "branch" -u test -d "0 0" +hg id +hg co -m 1 +hg id +hg status + diff --git a/tests/test-tags.out b/tests/test-tags.out new file mode 100644 --- /dev/null +++ b/tests/test-tags.out @@ -0,0 +1,47 @@ ++ mkdir t ++ cd t ++ hg init ++ hg id +unknown ++ echo a ++ hg add a ++ hg commit -t test -u test -d '0 0' ++ hg co ++ hg identify +acb14030 tip +++ hg -q tip +++ cut -d : -f 2 ++ T=acb14030fe0a21b60322c440ad2d20cf7685a376 ++ echo 'acb14030fe0a21b60322c440ad2d20cf7685a376 first' ++ cat .hgtags +acb14030fe0a21b60322c440ad2d20cf7685a376 first ++ hg add .hgtags ++ hg commit -t 'add tags' -u test -d '0 0' ++ hg tags +tip 1:b9154636be938d3d431e75a7c906504a079bfe07 +first 0:acb14030fe0a21b60322c440ad2d20cf7685a376 ++ hg identify +b9154636 tip ++ echo bb ++ hg status +C a ++ hg identify +b9154636+ tip ++ hg co first ++ hg id +acb14030+ first ++ hg -v id +acb14030fe0a21b60322c440ad2d20cf7685a376+ first ++ hg status +C a ++ echo 1 ++ hg add b ++ hg commit -t branch -u test -d '0 0' ++ hg id +c8edf041 tip ++ hg co -m 1 ++ hg id +c8edf041+b9154636+ tip ++ hg status +C a +C .hgtags diff --git a/tests/test-undo b/tests/test-undo diff --git a/tests/test-undo.out b/tests/test-undo.out diff --git a/tests/test-up-local-change b/tests/test-up-local-change diff --git a/tests/test-up-local-change.out b/tests/test-up-local-change.out