[PATCH 4 of 4] log: add support for subrepositories
Martin Geisler
mg at aragost.com
Thu Sep 23 10:03:22 CDT 2010
# HG changeset patch
# User Martin Geisler <mg at aragost.com>
# Date 1285254062 -7200
# Node ID 0781ec3ad451b203dd2e2d8deeb5ebb431b91cff
# Parent 2ec1394c1cd819d2ebac281814c7426d5c7e5ac2
log: add support for subrepositories
Adding -S/--subrepos to 'hg log' now makes it recurse into subrepos.
Other command line options such as --limit and --branch apply equally
to all subrepositories. Each log invocation is done separately, which
means that 'hg log -Sl 1' will show one changeset for each subrepo.
A heading is shown when entering a subrepository so that the
changesets from different subrepositories can be distinguished.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2456,7 +2456,7 @@
"""
matchfn = cmdutil.match(repo, pats, opts)
- hg.log(ui, repo, matchfn, opts)
+ hg.log(ui, repo, matchfn, opts, prefix='')
def manifest(ui, repo, node=None, rev=None):
"""output the current or given revision of the project manifest
@@ -4192,7 +4192,7 @@
_('show changesets within the given named branch'), _('BRANCH')),
('P', 'prune', [],
_('do not display revision or any of its ancestors'), _('REV')),
- ] + logopts + walkopts,
+ ] + logopts + subrepoopts + walkopts,
_('[OPTION]... [FILE]')),
"manifest":
(manifest,
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -12,6 +12,7 @@
import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
import lock, util, extensions, error, encoding, node
import cmdutil, discovery, url, changegroup, templatekw
+import match as matchmod
import merge as mergemod
import verify as verifymod
import errno, os, shutil
@@ -114,7 +115,7 @@
return path[5:]
return path
-def log(ui, repo, matchfn, opts):
+def log(ui, repo, matchfn, opts, prefix):
limit = cmdutil.loglimit(opts)
count = 0
@@ -179,6 +180,13 @@
count += 1
displayer.close()
+ if opts.get('subrepos'):
+ ctx = repo[None]
+ for subpath in sorted(ctx.substate):
+ sub = ctx.sub(subpath)
+ submatch = matchmod.narrowmatcher(subpath, matchfn)
+ sub.log(ui, submatch, opts, prefix)
+
def share(ui, source, dest=None, update=True):
'''create a shared repository'''
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -290,6 +290,9 @@
archiver.addfile(os.path.join(prefix, self._path, name),
mode, symlink, self.filedata(name))
+ def log(self, ui, match, opts):
+ ui.status(_("log in subrepository %s\n") % relpath(self))
+
class hgsubrepo(abstractsubrepo):
def __init__(self, ctx, path, state):
@@ -450,6 +453,10 @@
ctx = self._repo[rev]
return ctx.flags(name)
+ def log(self, ui, match, opts, prefix):
+ abstractsubrepo.log(self, ui, match, opts)
+ hg.log(ui, self._repo, match, opts, os.path.join(prefix, self._path))
+
class svnsubrepo(abstractsubrepo):
def __init__(self, ctx, path, state):
diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t
--- a/tests/test-subrepo-recursion.t
+++ b/tests/test-subrepo-recursion.t
@@ -205,6 +205,50 @@
1:9647f22de499 0-1-1
0:4904098473f9 0-0-0
+Recursive log:
+
+ $ hg log -S -l 1
+ changeset: 2:1326fa26d0c0
+ tag: tip
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: 2-3-2
+
+ log in subrepository foo
+ changeset: 3:65903cebad86
+ tag: tip
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: 2-3-2
+
+ log in subrepository foo/bar
+ changeset: 2:31ecbdafd357
+ tag: tip
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: 2-3-2
+
+Log of single files:
+
+ $ hg log -S -l 1 x.txt
+ changeset: 0:23376cbba0d8
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: 0-0-0
+
+ log in subrepository foo
+ log in subrepository foo/bar
+
+ $ hg log -S -l 1 foo/y.txt
+ log in subrepository foo
+ changeset: 3:65903cebad86
+ tag: tip
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: 2-3-2
+
+ log in subrepository foo/bar
+
Status between revisions:
$ hg status
More information about the Mercurial-devel
mailing list