# HG changeset patch # User Martin Geisler # Date 2010-09-13 11:09:24 # Node ID 01dc8ba3e032d72d2654be92eb5cab9837189528 # Parent 166b9866580a4a35501bec88cdbd2779c3998e93 outgoing: move code from commands to cmdutil This makes it easier to reuse it in a recursive fashion for subrepos. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2672,33 +2672,7 @@ def outgoing(ui, repo, dest=None, **opts Returns 0 if there are outgoing changes, 1 otherwise. """ - limit = cmdutil.loglimit(opts) - dest = ui.expandpath(dest or 'default-push', dest or 'default') - dest, branches = hg.parseurl(dest, opts.get('branch')) - revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) - if revs: - revs = [repo.lookup(rev) for rev in revs] - - other = hg.repository(hg.remoteui(repo, opts), dest) - ui.status(_('comparing with %s\n') % url.hidepassword(dest)) - o = discovery.findoutgoing(repo, other, force=opts.get('force')) - if not o: - ui.status(_("no changes found\n")) - return 1 - o = repo.changelog.nodesbetween(o, revs)[0] - if opts.get('newest_first'): - o.reverse() - displayer = cmdutil.show_changeset(ui, repo, opts) - count = 0 - for n in o: - if limit is not None and count >= limit: - break - parents = [p for p in repo.changelog.parents(n) if p != nullid] - if opts.get('no_merges') and len(parents) == 2: - continue - count += 1 - displayer.show(repo[n]) - displayer.close() + return hg.outgoing(ui, repo, dest, opts) def parents(ui, repo, file_=None, **opts): """show the parents of the working directory or revision diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -8,8 +8,10 @@ from i18n import _ from lock import release +from node import hex, nullid, nullrev, short import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo import lock, util, extensions, error, encoding, node +import cmdutil, discovery, url import merge as mergemod import verify as verifymod import errno, os, shutil @@ -406,6 +408,35 @@ def merge(repo, node, force=None, remind repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats[3] > 0 +def outgoing(ui, repo, dest, opts): + limit = cmdutil.loglimit(opts) + dest = ui.expandpath(dest or 'default-push', dest or 'default') + dest, branches = parseurl(dest, opts.get('branch')) + revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev')) + if revs: + revs = [repo.lookup(rev) for rev in revs] + + other = repository(remoteui(repo, opts), dest) + ui.status(_('comparing with %s\n') % url.hidepassword(dest)) + o = discovery.findoutgoing(repo, other, force=opts.get('force')) + if not o: + ui.status(_("no changes found\n")) + return 1 + o = repo.changelog.nodesbetween(o, revs)[0] + if opts.get('newest_first'): + o.reverse() + displayer = cmdutil.show_changeset(ui, repo, opts) + count = 0 + for n in o: + if limit is not None and count >= limit: + break + parents = [p for p in repo.changelog.parents(n) if p != nullid] + if opts.get('no_merges') and len(parents) == 2: + continue + count += 1 + displayer.show(repo[n]) + displayer.close() + def revert(repo, node, choose): """revert changes to revision in node without updating dirstate""" return mergemod.update(repo, node, False, True, choose)[3] > 0