[PATCH 1 of 6] context: let workingctx parents be overriden

Patrick Mézard pmezard at gmail.com
Mon Jun 16 16:58:07 CDT 2008


Patrick Mézard a écrit :
> Matt Mackall a écrit :
> But nothing prevents me from extracting this whole block too:
> 
> 
> """
>             if (not empty_ok and not text) or force_editor:
>                 edittext = []
>                 if text:
>                     edittext.append(text)
>                 edittext.append("")
>                 edittext.append(_("HG: Enter commit message."
>                                   "  Lines beginning with 'HG:' are removed."))
>                 edittext.append("HG: --")
>                 edittext.append("HG: user: %s" % user)
>                 if p2 != nullid:
>                     edittext.append("HG: branch merge")
>                 if branchname:
>                     edittext.append("HG: branch '%s'" % util.tolocal(branchname))
>                 edittext.extend(["HG: changed %s" % f for f in changed])
>                 edittext.extend(["HG: removed %s" % f for f in removed])
>                 if not changed and not remove:
>                     edittext.append("HG: no files changed")
>                 edittext.append("")
>                 # run editor in the repository root
>                 olddir = os.getcwd()
>                 os.chdir(self.root)
>                 text = self.ui.edit("\n".join(edittext), user)
>                 os.chdir(olddir)
> 
>             lines = [line.rstrip() for line in text.rstrip().splitlines()]
>             while lines and not lines[0]:
>                 del lines[0]
>             if not lines and use_dirstate:
>                 raise util.Abort(_("empty commit message"))
>             text = '\n'.join(lines)
> """
> 
> into a cmdutil function. I want to keep the line filtering part for I would like to reuse it in mq to reproduce the same aborting behaviour when refreshing/creating patches with explicit empty messages.

Except the last part does not make a lot of sense, there are simpler ways to achieve this. I will think again about this.

--
Patrick Mézard


More information about the Mercurial-devel mailing list