changeset 7433:c4ce828e8074

merge with mpm
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 27 Nov 2008 01:35:12 +0100
parents df0962f6c54e (diff) 642754e776e2 (current diff)
children cf7741aa1e96
files contrib/mercurial.spec
diffstat 4 files changed, 202 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/mercurial.spec	Thu Nov 27 01:10:27 2008 +0100
+++ b/contrib/mercurial.spec	Thu Nov 27 01:35:12 2008 +0100
@@ -6,7 +6,7 @@
 Group: Development/Tools
 Source: http://www.selenic.com/mercurial/release/%{name}-%{version}.tar.gz
 URL: http://www.selenic.com/mercurial
-BuildRoot: /tmp/build.%{name}-%{version}-%{release}
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 # From the README:
 #
@@ -28,13 +28,13 @@
 for efficient handling of very large distributed projects.
 
 %prep
-rm -rf $RPM_BUILD_ROOT
 %setup -q
 
 %build
 make all
 
 %install
+rm -rf $RPM_BUILD_ROOT
 python setup.py install --root $RPM_BUILD_ROOT --prefix %{_prefix}
 make install-doc DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir}
 
@@ -62,8 +62,6 @@
 %defattr(-,root,root,-)
 %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html doc/ja *.cgi
 %{_mandir}/man?/hg*.gz
-%dir %{pythonlib}
-%dir %{hgext}
 %{_sysconfdir}/bash_completion.d/mercurial.sh
 %{_datadir}/zsh/site-functions/_mercurial
 %{_datadir}/emacs/site-lisp/mercurial.el
@@ -74,12 +72,5 @@
 %{_bindir}/git-rev-tree
 %{_bindir}/mercurial-convert-repo
 %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py2.5.egg-info
-%{pythonlib}/templates
-%{pythonlib}/*.py*
-%{pythonlib}/hgweb/*.py*
-%{pythonlib}/*.so
-%{hgext}/*.py*
-%{hgext}/convert/*.py*
-%{hgext}/inotify/*.py*
-%{hgext}/highlight/*.py*
-%{hgext}/inotify/linux/
+%{pythonlib}
+%{hgext}
--- a/hgext/graphlog.py	Thu Nov 27 01:10:27 2008 +0100
+++ b/hgext/graphlog.py	Thu Nov 27 01:35:12 2008 +0100
@@ -4,15 +4,22 @@
 #
 # This software may be used and distributed according to the terms of
 # the GNU General Public License, incorporated herein by reference.
-'''show revision graphs in terminal windows'''
+'''show revision graphs in terminal windows
+
+This extension adds a --graph option to the incoming, outgoing and log
+commands. When this options is given, an ascii representation of the
+revision graph is also shown.
+'''
 
 import os
 import sys
 from mercurial.cmdutil import revrange, show_changeset
-from mercurial.commands import templateopts
+from mercurial.commands import templateopts, logopts, remoteopts
 from mercurial.i18n import _
 from mercurial.node import nullrev
 from mercurial.util import Abort, canonpath
+from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions
+from mercurial import hg, ui, url
 
 def revisions(repo, start, stop):
     """cset DAG generator yielding (rev, node, [parents]) tuples
@@ -257,6 +264,14 @@
     else:
         return (len(repo) - 1, 0)
 
+def check_unsupported_flags(opts):
+    for op in ["follow", "follow_first", "date", "copies", "keyword", "remove",
+               "only_merges", "user", "only_branch", "prune", "newest_first",
+               "no_merges", "include", "exclude"]:
+        if op in opts and opts[op]:
+            raise Abort(_("--graph option is incompatible with --%s") % op)
+
+
 def graphlog(ui, repo, path=None, **opts):
     """show revision history alongside an ASCII revision graph
 
@@ -267,6 +282,7 @@
     directory.
     """
 
+    check_unsupported_flags(opts)
     limit = get_limit(opts["limit"])
     start, stop = get_revs(repo, opts["rev"])
     stop = max(stop, start - limit + 1)
@@ -293,6 +309,165 @@
 
     ascii(ui, grapher(graphabledag()))
 
+def outgoing_revs(ui, repo, dest, opts):
+    """cset DAG generator yielding (node, [parents]) tuples
+
+    This generator function walks through the revisions not found
+    in the destination
+    """
+    limit = cmdutil.loglimit(opts)
+    dest, revs, checkout = hg.parseurl(
+        ui.expandpath(dest or 'default-push', dest or 'default'),
+        opts.get('rev'))
+    cmdutil.setremoteconfig(ui, opts)
+    if revs:
+        revs = [repo.lookup(rev) for rev in revs]
+    other = hg.repository(ui, dest)
+    ui.status(_('comparing with %s\n') % url.hidepassword(dest))
+    o = repo.findoutgoing(other, force=opts.get('force'))
+    if not o:
+        ui.status(_("no changes found\n"))
+        return
+    o = repo.changelog.nodesbetween(o, revs)[0]
+    o.reverse()
+    revdict = {}
+    for n in o:
+        revdict[repo.changectx(n).rev()]=True
+    count = 0
+    for n in o:
+        if count >= limit:
+            break
+        ctx = repo.changectx(n)
+        parents = [p.rev() for p in ctx.parents() if p.rev() in revdict]
+        parents.sort()
+        yield (ctx, parents)
+        count += 1
+
+def goutgoing(ui, repo, dest=None, **opts):
+    """show the outgoing changesets alongside an ASCII revision graph
+
+    Print the outgoing changesets alongside a revision graph drawn with
+    ASCII characters.
+
+    Nodes printed as an @ character are parents of the working
+    directory.
+    """
+    check_unsupported_flags(opts)
+    revdag = outgoing_revs(ui, repo, dest, opts)
+    repo_parents = repo.dirstate.parents()
+    displayer = show_changeset(ui, repo, opts, buffered=True)
+    def graphabledag():
+        for (ctx, parents) in revdag:
+            # log_strings is the list of all log strings to draw alongside
+            # the graph.
+            displayer.show(ctx)
+            lines = displayer.hunk.pop(ctx.rev()).split("\n")[:-1]
+            char = ctx.node() in repo_parents and '@' or 'o'
+            yield (ctx.rev(), parents, char, lines)
+
+    ascii(ui, grapher(graphabledag()))
+
+def incoming_revs(other, chlist, opts):
+    """cset DAG generator yielding (node, [parents]) tuples
+
+    This generator function walks through the revisions of the destination
+    not found in repo
+    """
+    limit = cmdutil.loglimit(opts)
+    chlist.reverse()
+    revdict = {}
+    for n in chlist:
+        revdict[other.changectx(n).rev()]=True
+    count = 0
+    for n in chlist:
+        if count >= limit:
+            break
+        ctx = other.changectx(n)
+        parents = [p.rev() for p in ctx.parents() if p.rev() in revdict]
+        parents.sort()
+        yield (ctx, parents)
+        count += 1
+
+def gincoming(ui, repo, source="default", **opts):
+    """show the incoming changesets alongside an ASCII revision graph
+
+    Print the incoming changesets alongside a revision graph drawn with
+    ASCII characters.
+
+    Nodes printed as an @ character are parents of the working
+    directory.
+    """
+
+    check_unsupported_flags(opts)
+    source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
+    cmdutil.setremoteconfig(ui, opts)
+
+    other = hg.repository(ui, source)
+    ui.status(_('comparing with %s\n') % url.hidepassword(source))
+    if revs:
+        revs = [other.lookup(rev) for rev in revs]
+    incoming = repo.findincoming(other, heads=revs, force=opts["force"])
+    if not incoming:
+        try:
+            os.unlink(opts["bundle"])
+        except:
+            pass
+        ui.status(_("no changes found\n"))
+        return
+
+    cleanup = None
+    try:
+        fname = opts["bundle"]
+        if fname or not other.local():
+            # create a bundle (uncompressed if other repo is not local)
+            if revs is None:
+                cg = other.changegroup(incoming, "incoming")
+            else:
+                cg = other.changegroupsubset(incoming, revs, 'incoming')
+            bundletype = other.local() and "HG10BZ" or "HG10UN"
+            fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
+            # keep written bundle?
+            if opts["bundle"]:
+                cleanup = None
+            if not other.local():
+                # use the created uncompressed bundlerepo
+                other = bundlerepo.bundlerepository(ui, repo.root, fname)
+
+        chlist = other.changelog.nodesbetween(incoming, revs)[0]
+        revdag = incoming_revs(other, chlist, opts)
+        other_parents = other.dirstate.parents()
+        displayer = show_changeset(ui, other, opts, buffered=True)
+        def graphabledag():
+            for (ctx, parents) in revdag:
+                # log_strings is the list of all log strings to draw alongside
+                # the graph.
+                displayer.show(ctx)
+                lines = displayer.hunk.pop(ctx.rev()).split("\n")[:-1]
+                char = ctx.node() in other_parents and '@' or 'o'
+                yield (ctx.rev(), parents, char, lines)
+
+        ascii(ui, grapher(graphabledag()))
+    finally:
+        if hasattr(other, 'close'):
+            other.close()
+        if cleanup:
+            os.unlink(cleanup)
+
+def uisetup(ui):
+    '''Initialize the extension.'''
+    _wrapcmd(ui, 'log', commands.table, graphlog)
+    _wrapcmd(ui, 'incoming', commands.table, gincoming)
+    _wrapcmd(ui, 'outgoing', commands.table, goutgoing)
+
+def _wrapcmd(ui, cmd, table, wrapfn):
+    '''wrap the command'''
+    def graph(orig, *args, **kwargs):
+        if kwargs['graph']:
+            return wrapfn(*args, **kwargs)
+        return orig(*args, **kwargs)
+    entry = extensions.wrapcommand(table, cmd, graph)
+    entry[1].append(('g', 'graph', None, _("show the revision DAG")))
+
 cmdtable = {
     "glog":
         (graphlog,
--- a/mercurial/hook.py	Thu Nov 27 01:10:27 2008 +0100
+++ b/mercurial/hook.py	Thu Nov 27 01:35:12 2008 +0100
@@ -96,19 +96,20 @@
         oldstdout = os.dup(sys.__stdout__.fileno())
         os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
 
-    for hname, cmd in util.sort(ui.configitems('hooks')):
-        if hname.split('.')[0] != name or not cmd:
-            continue
-        if callable(cmd):
-            r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
-        elif cmd.startswith('python:'):
-            r = _pythonhook(ui, repo, name, hname, cmd[7:].strip(),
-                            args, throw) or r
-        else:
-            r = _exthook(ui, repo, hname, cmd, args, throw) or r
-
-    if _redirect:
-        os.dup2(oldstdout, sys.__stdout__.fileno())
-        os.close(oldstdout)
+    try:
+        for hname, cmd in util.sort(ui.configitems('hooks')):
+            if hname.split('.')[0] != name or not cmd:
+                continue
+            if callable(cmd):
+                r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
+            elif cmd.startswith('python:'):
+                r = _pythonhook(ui, repo, name, hname, cmd[7:].strip(),
+                                args, throw) or r
+            else:
+                r = _exthook(ui, repo, hname, cmd, args, throw) or r
+    finally:
+        if _redirect:
+            os.dup2(oldstdout, sys.__stdout__.fileno())
+            os.close(oldstdout)
 
     return r
--- a/tests/test-convert-darcs	Thu Nov 27 01:10:27 2008 +0100
+++ b/tests/test-convert-darcs	Thu Nov 27 01:35:12 2008 +0100
@@ -1,6 +1,12 @@
 #!/bin/sh
 
 "$TESTDIR/hghave" darcs || exit 80
+if darcs --version 2>&1 | grep '^2\.' > /dev/null; then
+    # FIXME: darcs 2 will fail with
+    ### Abort: timeout after 180 seconds.
+    echo 'skipped: test currently disabled for darcs 2'
+    exit 80
+fi
 
 echo "[extensions]" >> $HGRCPATH
 echo "convert=" >> $HGRCPATH