monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Feature request: mtn rebase


From: Nathaniel Smith
Subject: Re: [Monotone-devel] Feature request: mtn rebase
Date: Fri, 10 Oct 2008 13:59:41 -0700

On Fri, Oct 10, 2008 at 1:31 PM, Daniel Carrera <address@hidden> wrote:
> Hello,
>
> I'd like to officially request a "mtn rebase" command. I could try to write
> it in Lua (I don't know how hard that would be, but I'd try).
>
> Usage:  mtn rebase <revision-id>
>
> Effect: Edit _MTN/revision to point to <revision-id>

NB that you probably can't implement this in a fully correct way in
Lua, because you need to move any pending adds/drops/renames so that
they apply to the new base revision; just changing the base_revision
field won't do that.  If all you have are file edits, then things may
be fine; otherwise there's a chance of your workspace becoming
inconsistent, and subsequent mtn commands will notice this and refuse
to work.

It would be quite easy to implement in mtn itself, though, because it
has all the high-level code for handling file trees already.  Just do
something like (untested):

revision_id new_base_rid;
cached_roster new_base_roster;
roster_t workspace_roster;
parent_map old_parents, new_parents;
temp_node_id_source nis;

if (app.opts.revision_selectors.size() != 1) throw usage(execid);
complete(app, idx(app.opts.revision_selectors, 0)(), new_base_rid);
N(app.db.revision_exists(new_base), F("no such revision '%s'") % new_base_rid);
app.require_workspace();
app.db.get_roster(new_base_rid, new_base_roster);
app.work.get_work_state_shape_only(old_parents, workspace_roster, nis);
N(old_parents.size() == 1, F("cannot rebase a merge workspace"));
new_parents.insert(std::make_pair(new_base_rid, new_base_roster));
app.work.set_work_state(new_parents, workspace_roster);

-- Nathaniel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]