# HG changeset patch # User Thomas Arendsen Hein # Date 1159612471 -7200 # Node ID 9e8dd6114a4e210e71c5f6ace4a9e4aee5818a0e # Parent a7377a238cecc237f894b7500e96f27cf94807b0# Parent e7b7906cc47e150f89e1d2eefe0b568b49ed5b86 merged brendan's hgweb cleanups diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2752,7 +2752,6 @@ table = { _('hg add [OPTION]... [FILE]...')), "addremove": (addremove, - walkopts + dryrunopts + [('s', 'similarity', '', _('guess renamed files by similarity (0<=s<=100)')), ] + walkopts + dryrunopts, diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -32,9 +32,18 @@ class changectx(object): self._node = self._repo.lookup(changeid) self._rev = self._repo.changelog.rev(self._node) + def __str__(self): + return short(self.node()) + def __repr__(self): return "" % short(self.node()) + def __eq__(self, other): + return self._rev == other._rev + + def __nonzero__(self): + return self._rev != -1 + def changeset(self): try: return self._changeset @@ -127,9 +136,18 @@ class filectx(object): else: raise AttributeError, name + def __nonzero__(self): + return self._filerev != nullid + + def __str__(self): + return "%s@%s" % (self.path(), short(self.node())) + def __repr__(self): return "" % (self.path(), short(self.node())) + def __eq__(self, other): + return self._path == other._path and self._changeid == other._changeid + def filectx(self, fileid): '''opens an arbitrary revision of the file without opening a new filelog''' diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -321,6 +321,19 @@ class localrepository(repo.repository): def changectx(self, changeid=None): return context.changectx(self, changeid) + def parents(self, changeid=None): + ''' + get list of changectxs for parents of changeid or working directory + ''' + if changeid is None: + pl = self.dirstate.parents() + else: + n = self.changelog.lookup(changeid) + pl = self.changelog.parents(n) + if pl[1] == nullid: + return [self.changectx(pl[0])] + return [self.changectx(pl[0]), self.changectx(pl[1])] + def filectx(self, path, changeid=None, fileid=None): """changeid can be a changeset revision, node, or tag. fileid can be a file revision or node.""" diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -320,12 +320,12 @@ def update(repo, node, branchmerge=False ### check phase - pl = repo.dirstate.parents() - if not overwrite and pl[1] != nullid: + pl = repo.parents() + if not overwrite and len(pl) > 1: raise util.Abort(_("outstanding uncommitted merges")) - p1, p2 = pl[0], node - pa = repo.changelog.ancestor(p1, p2) + p1, p2 = pl[0], repo.changectx(node) + pa = p1.ancestor(p2) # are we going backwards? backwards = (pa == p2) @@ -345,17 +345,16 @@ def update(repo, node, branchmerge=False if modified or added or removed: raise util.Abort(_("outstanding uncommitted changes")) - m1 = repo.changectx(p1).manifest().copy() - m2 = repo.changectx(p2).manifest().copy() - ma = repo.changectx(pa).manifest() + m1 = p1.manifest().copy() + m2 = p2.manifest().copy() + ma = pa.manifest() # resolve the manifest to determine which files # we care about merging repo.ui.note(_("resolving manifests\n")) repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") % (overwrite, branchmerge, bool(partial))) - repo.ui.debug(_(" ancestor %s local %s remote %s\n") % - (short(p1), short(p2), short(pa))) + repo.ui.debug(_(" ancestor %s local %s remote %s\n") % (p1, p2, pa)) action = [] copy = {} @@ -369,7 +368,7 @@ def update(repo, node, branchmerge=False if not branchmerge: action += forgetremoved(m2, status) if not (backwards or overwrite): - copy = findcopies(repo, m1, m2, repo.changelog.rev(pa)) + copy = findcopies(repo, m1, m2, pa.rev()) action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards) del m1, m2, ma @@ -378,10 +377,10 @@ def update(repo, node, branchmerge=False if not branchmerge: # we don't need to do any magic, just jump to the new rev - p1, p2 = p2, nullid + p1, p2 = p2, repo.changectx(nullid) - xp1, xp2 = hex(p1), hex(p2) - if p2 == nullid: xp2 = '' + xp1, xp2 = str(p1), str(p2) + if not p2: xp2 = '' repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) @@ -389,7 +388,7 @@ def update(repo, node, branchmerge=False # update dirstate if not partial: - repo.dirstate.setparents(p1, p2) + repo.dirstate.setparents(p1.node(), p2.node()) recordupdates(repo, action, branchmerge) if show_stats: @@ -406,8 +405,7 @@ def update(repo, node, branchmerge=False " you can redo the full merge using:\n" " hg update -C %s\n" " hg merge %s\n" - % (repo.changelog.rev(p1), - repo.changelog.rev(p2)))) + % (p1.rev(), p2.rev()))) elif remind: repo.ui.status(_("(branch merge, don't forget to commit)\n")) elif unresolved: diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -356,7 +356,7 @@ class changeset_templater(object): self.write(thing, header=True) def show(self, rev=0, changenode=None, brinfo=None, changes=None, - copies=None, **props): + copies=[], **props): '''show a single changeset or file revision''' log = self.repo.changelog if changenode is None: diff --git a/tests/test-annotate b/tests/test-annotate --- a/tests/test-annotate +++ b/tests/test-annotate @@ -1,7 +1,5 @@ #!/bin/sh -export HGMERGE=true - echo % init hg init diff --git a/tests/test-hook.out b/tests/test-hook.out --- a/tests/test-hook.out +++ b/tests/test-hook.out @@ -62,10 +62,10 @@ precommit hook: p1=8ea2ef7ad3e8cac946c72 precommit.forbid hook abort: precommit.forbid hook exited with status 1 4:8ea2ef7ad3e8 -preupdate hook: p1=b702efe9688826e3a91283852b328b84dbf37bc2 p2= +preupdate hook: p1=b702efe96888 p2= 0 files updated, 0 files merged, 2 files removed, 0 files unresolved -preupdate hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2= -update hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2= err=0 +preupdate hook: p1=8ea2ef7ad3e8 p2= +update hook: p1=8ea2ef7ad3e8 p2= err=0 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 3:4c52fb2e4022 prechangegroup.forbid hook