changeset 3209:9e8dd6114a4e

merged brendan's hgweb cleanups
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 30 Sep 2006 12:34:31 +0200
parents a7377a238cec (diff) e7b7906cc47e (current diff)
children 7240f9e47144
files mercurial/context.py
diffstat 7 files changed, 49 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Sep 29 16:26:09 2006 -0700
+++ b/mercurial/commands.py	Sat Sep 30 12:34:31 2006 +0200
@@ -2752,7 +2752,6 @@
          _('hg add [OPTION]... [FILE]...')),
     "addremove":
         (addremove,
-         walkopts + dryrunopts +
          [('s', 'similarity', '',
            _('guess renamed files by similarity (0<=s<=100)')),
          ] + walkopts + dryrunopts,
--- a/mercurial/context.py	Fri Sep 29 16:26:09 2006 -0700
+++ b/mercurial/context.py	Sat Sep 30 12:34:31 2006 +0200
@@ -32,9 +32,18 @@
         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 "<changectx %s>" % 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 @@
         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 "<filectx %s@%s>" % (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'''
--- a/mercurial/localrepo.py	Fri Sep 29 16:26:09 2006 -0700
+++ b/mercurial/localrepo.py	Sat Sep 30 12:34:31 2006 +0200
@@ -321,6 +321,19 @@
     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."""
--- a/mercurial/merge.py	Fri Sep 29 16:26:09 2006 -0700
+++ b/mercurial/merge.py	Sat Sep 30 12:34:31 2006 +0200
@@ -320,12 +320,12 @@
 
     ### 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 @@
         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 @@
     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 @@
 
     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 @@
 
     # 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 @@
                                 " 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:
--- a/mercurial/templater.py	Fri Sep 29 16:26:09 2006 -0700
+++ b/mercurial/templater.py	Sat Sep 30 12:34:31 2006 +0200
@@ -356,7 +356,7 @@
         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:
--- a/tests/test-annotate	Fri Sep 29 16:26:09 2006 -0700
+++ b/tests/test-annotate	Sat Sep 30 12:34:31 2006 +0200
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-export HGMERGE=true
-
 echo % init
 hg init
 
--- a/tests/test-hook.out	Fri Sep 29 16:26:09 2006 -0700
+++ b/tests/test-hook.out	Sat Sep 30 12:34:31 2006 +0200
@@ -62,10 +62,10 @@
 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