[PATCH] allow localrepo.commit to store arbitrary data into the changelog dictionary
Brendan Cully
brendan at kublai.com
Tue Nov 7 00:37:59 UTC 2006
To support the new branch format, the changelog now sports a new
dictionary field. But this is not exported to commit, so the only user
is the branch code inside commit itself. I'd like to export that
dictionary to callers of commit, primarily so that my transplant
extension can use it to figure out whether a patch has already been
transplanted without messy changelog message parsing. Here's my
proposed patch to both hg and the transplant extension.
Comments?
-------------- next part --------------
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1162858840 28800
# Node ID 1e87c5f4fad204fdcd4331e9c52c5d9b60d9dd3d
# Parent cf001fb04109a27e550e0f06d095d02dfad884bd
Export changelog dict in localrepo.commit
diff -r cf001fb04109 -r 1e87c5f4fad2 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sun Nov 05 21:57:52 2006 +0100
+++ b/mercurial/localrepo.py Mon Nov 06 16:20:40 2006 -0800
@@ -618,10 +618,12 @@ class localrepository(repo.repository):
def commit(self, files=None, text="", user=None, date=None,
match=util.always, force=False, lock=None, wlock=None,
- force_editor=False):
+ force_editor=False, extra=None):
commit = []
remove = []
changed = []
+ if not extra:
+ extra = {}
if files:
for f in files:
@@ -712,7 +714,6 @@ class localrepository(repo.repository):
if not lines:
return None
text = '\n'.join(lines)
- extra = {}
if branchname:
extra["branch"] = branchname
n = self.changelog.add(mn, changed + remove, text, tr, p1, p2,
-------------- next part --------------
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1162859836 28800
# Node ID e021a996d43e4705c9aebf3a24fa7d493aed7f01
# Parent 377d650ec1e2a0428a07cf3e3188ddfe64c179ed
Record source node in changelog dict instead of log message
diff -r 377d650ec1e2 -r e021a996d43e transplant.py
--- a/transplant.py Mon Nov 06 16:29:51 2006 -0800
+++ b/transplant.py Mon Nov 06 16:37:16 2006 -0800
@@ -145,7 +145,7 @@ class transplanter:
try:
n = self.applyone(repo, node, source.changelog.read(node),
patchfile, merge=domerge,
- log=not opts.get('no_log'),
+ log=opts.get('log'),
filter=opts.get('filter'),
lock=lock, wlock=wlock)
if domerge:
@@ -185,11 +185,12 @@ class transplanter:
return message
- def applyone(self, repo, node, cl, patchfile, merge=False, log=True,
+ def applyone(self, repo, node, cl, patchfile, merge=False, log=False,
filter=None, lock=None, wlock=None):
'''apply the patch in patchfile to the repository as a transplant'''
(manifest, user, (time, timezone), files, message) = cl[:5]
date = "%d %d" % (time, timezone)
+ extra = {'transplant_source': node}
if filter:
message = self.filter(filter, cl, patchfile)
@@ -223,7 +224,8 @@ class transplanter:
if merge:
p1, p2 = repo.dirstate.parents()
repo.dirstate.setparents(p1, node)
- n = repo.commit(files, message, user, date, lock=lock, wlock=wlock)
+ n = repo.commit(files, message, user, date, lock=lock, wlock=wlock,
+ extra=extra)
if not merge:
self.transplants.set(n, node)
@@ -342,16 +344,10 @@ class transplanter:
return False
if source.changelog.parents(node)[1] != revlog.nullid:
return False
- msg = source.changelog.read(node)[4]
- if msg:
- msg = msg.splitlines()[-1]
- if msg.startswith('(transplanted from '):
- try:
- cnode = revlog.bin(msg[19:59])
- except TypeError:
- return True
- if self.applied(repo, cnode, root):
- return False
+ extra = source.changelog.read(node)[5]
+ cnode = extra.get('transplant_source')
+ if cnode and self.applied(repo, cnode, root):
+ return False
return True
return matchfn
@@ -407,7 +403,7 @@ def transplant(ui, repo, *revs, **opts):
'''transplant changesets from another branch
Selected changesets will be applied on top of the current working
- directory with the log of the original changeset. Unless --no-log is
+ directory with the log of the original changeset. If --log is
specified, log messages will have a comment appended of the form:
(transplanted from CHANGESETHASH)
@@ -422,9 +418,8 @@ def transplant(ui, repo, *revs, **opts):
is specified, all changesets on the branch will be transplanted,
otherwise you will be prompted to select the changesets you want.
- hg transplant --branch REVISION --all --no-log will rebase the
- selected branch (up to the named revision) onto your current working
- directory.
+ hg transplant --branch REVISION --all will rebase the selected branch
+ (up to the named revision) onto your current working directory.
You can optionally mark selected transplanted changesets as
merge changesets. You will not be prompted to transplant any
@@ -493,8 +488,8 @@ def transplant(ui, repo, *revs, **opts):
checkopts(opts, revs)
- if not opts.get('no_log'):
- opts['no_log'] = ui.config('transplant', 'no-log')
+ if not opts.get('log'):
+ opts['log'] = ui.config('transplant', 'log')
if not opts.get('filter'):
opts['filter'] = ui.config('transplant', 'filter')
@@ -567,7 +562,7 @@ cmdtable = {
('a', 'all', None, _('pull all changesets up to BRANCH')),
('p', 'prune', [], _('skip over REV')),
('m', 'merge', [], _('merge at REV')),
- ('n', 'no-log', None, _('do not append transplant info to log message')),
+ ('', 'log', None, _('append transplant info to log message')),
('c', 'continue', None, _('continue last transplant session after repair')),
('', 'filter', '', _('filter changesets through FILTER'))],
_('hg transplant [-s REPOSITORY] [-b BRANCH] [-p REV] [-m REV] [-n] REV...'))
More information about the Mercurial-devel
mailing list