Deleting a branch

Govind Salinas blix at sophiasuchtig.com
Sun Jan 20 20:23:05 CST 2008


Hi Folks,

I have a problem.  I was first introduced to DSCM with git and there are
several features about it that I particularly like.  I have found that
Mercurial works better for me in most situations though.  The window support
(where I earn my living) is better, its much easier to set up web access for
hg than it is for git and I would rather work in python than in c (I'm
mostly a c++ guy, but I just *like* python).  However, I miss some of the
features offered by git.

Long story short...

I want to update the gitweb style to look work more like gitweb (i have
already started and its going fairly well)
I want to add a "stash" functionality
I want to add the ability to delete a named branch

On that last issue, my thinking was that I would find all the heads, see
where those heads intersect the branch I want to delete and then only delete
so far back as I can without hitting a commit that can be reached from
another head.  In order to do this I have been trying to use
revlog.ancestorto find the intersection points between other heads and
the branch I am
trying to delete.  Unfortunately, I can't figure out what revlog.ancestor is
returning.  The object claims to be a string, but it looks like garbage when
I print it out.  I don't know how to convert it to something that looks like
a commit.  I can see from looking at other parts of the code, that it should
be a nodeid, but I can't tell what the format is or how to convert it to
some other format.

If anyone can point me in the right direction I would appreciate it.
Otherwise if there is a better way of doing this, that would work too.

here is some pseudocode for what i have in mind.

def prunebranch()
  if branch is currentbranch or branch does not exist
    bail
  endif
  for each head in heads
     if head is branch.tip
       continue
     add leastcommonancestor(head, branch) to ancestors
  endfor
  currentcommit = branch.tip
  while currentcommit
    if currentcommit in ancestors
      break
    else
      strip(currentcommit)
    currentcommit = currentcommit.parent //yeah yeah multiple parents, but
you get the idea.
  endwhile

Thanks,
Govind.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20080120/a4231a22/attachment.htm 


More information about the Mercurial-devel mailing list