[PATCH 5 of 6 OBSOLETE-MARKERS] obsolete: add proper metadata handling to obsolete marker: user and date
Patrick Mézard
patrick at mezard.eu
Sun May 13 08:41:20 CDT 2012
Le 12/05/12 19:08, Pierre-Yves David a écrit :
> # HG changeset patch
> # User Pierre-Yves.David at ens-lyon.org
> # Date 1336840751 -7200
> # Node ID 09943a88d99a60e597ba7c3828612c7bec43e370
> # Parent 0d39a100bf11a38b76abdc79b307c3518bd08efd
> obsolete: add proper metadata handling to obsolete marker: user and date
>
> We add "date" and "user" data. It's currently accessed very barely. metadata
> will be more wrapper "later".
>
> "date" are expected to help with garbage collection.
> "user" are expected to help to solve conflicting situation.
>
> encode and decode extra are kept in changelog because I'm not sure we want use
> them as is for now.
>
> diff -r 0d39a100bf11 -r 09943a88d99a mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py Sat May 12 17:41:33 2012 +0200
> +++ b/mercurial/cmdutil.py Sat May 12 18:39:11 2012 +0200
> @@ -10,7 +10,7 @@
> import os, sys, errno, re, tempfile
> import util, scmutil, templater, patch, error, templatekw, revlog, copies
> import match as matchmod
> -import subrepo, context, repair, bookmarks
> +import subrepo, context, repair, bookmarks, changelog
>
> def parsealiases(cmd):
> return cmd.lstrip("^").split("|")
> @@ -698,8 +698,23 @@
> for parent in parents:
> self.ui.write(_("parent: %d:%s\n") % parent,
> label='log.parent')
> - if ctx.obsolete():
> + if util.safehasattr(ctx, 'obsolete') and ctx.obsolete():
Why the hasattr() ?
> self.ui.write(_("obsolete: dead\n"))
> + if self.ui.debug:
> + for marker in self.repo.obsstore.obsoleted[ctx.node()]:
> + if marker[1]: # if replacement
> + msg = "replaced: %s by %s\n"
> + else:
> + msg = "killed: %s by %s\n"
> + metadata = changelog.decodeextra(marker[3])
> + odate = metadata['date'].split(' ')
> + odate = (float(odate[0]), int(odate[1]))
> + odate = util.datestr(odate)
> + self.ui.debug(msg % (odate, metadata['user']))
> + repls = marker[1]
> + for rpn in repls:
> + rp = self.repo[rpn]
> + self.ui.note(_(" by: %d:%s\n") % (rp, rp))
All this should be abstracted by the obsstore(). Maybe with an obsolete object, I don't know. And it means you do not need the changelog import anymore.
>
> if self.ui.debugflag:
> mnode = ctx.manifestnode()
> diff -r 0d39a100bf11 -r 09943a88d99a mercurial/commands.py
> --- a/mercurial/commands.py Sat May 12 17:41:33 2012 +0200
> +++ b/mercurial/commands.py Sat May 12 18:39:11 2012 +0200
> @@ -18,6 +18,7 @@
> import dagparser, context, simplemerge
> import random, setdiscovery, treediscovery, dagutil, pvec
> import phases
> +import changelog
>
> table = {}
>
> @@ -4172,7 +4173,7 @@
>
> @command('obsolete',
> [('r', 'rev', [], _('mark given revision as obsolete'), _('REV')),
> - ],
> + ] + commitopts2,
> _('[--rev] REV'))
> def obsolete(ui, repo, *revs, **opts):
> """mark a changeset as obsolete (DEPRECATED)"""
> @@ -4182,10 +4183,19 @@
> if not revs:
> raise util.Abort(_('no revisions specified'))
>
> + metadata = {}
> + metadata['date'] = opts['date'] or '%f %i' % util.makedate()
> + try:
> + metadata['user'] = opts['user'] or ui.username()
> + except util.Abort, e:
> + ui.write(" %s\n" % e)
> + ui.write(_(" (specify a username in your configuration file)\n"))
> + metadata = changelog.encodeextra(metadata)
Again, wrap all this in an obsstore method or object. And you will not need to import changelog.
> +
> l = repo.lock()
> try:
> for obs in revs:
> - marker = (repo[obs].node(), (), 0, '')
> + marker = (repo[obs].node(), (), 0, metadata)
> repo.obsstore.add(marker)
> finally:
> l.release()
[...]
--
Patrick Mézard
More information about the Mercurial-devel
mailing list