[PATCH 1 of 2] requires: move requires file writing func from localrepo to scmutil

Martin von Zweigbergk martinvonz at google.com
Tue May 5 10:32:33 CDT 2015


I think this patch still makes sense, even though we're dropping 2/2.

On Mon, May 4, 2015 at 11:28 AM Drew Gottlieb <drgott at google.com> wrote:

> # HG changeset patch
> # User Drew Gottlieb <drgott at google.com>
> # Date 1428963107 14400
> #      Mon Apr 13 18:11:47 2015 -0400
> # Node ID 3f86e3b2548def52732e1f782e89297db8075e8b
> # Parent  e5b507efb36e2b9ad8edb1a38459d26c934d74dd
> requires: move requires file writing func from localrepo to scmutil
>
> The logic to read a requires file resides in scmutil, so it's only logical
> that
> the logic to write the file should be there too.
>
> And now I've typed logic too many times it no longer looks like a word.
> Logically.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -353,10 +353,7 @@
>              self.svfs.options['usetreemanifest'] = usetreemanifest
>
>      def _writerequirements(self):
> -        reqfile = self.vfs("requires", "w")
> -        for r in sorted(self.requirements):
> -            reqfile.write("%s\n" % r)
> -        reqfile.close()
> +        scmutil.writerequires(self.vfs, self.requirements)
>
>      def _checknested(self, path):
>          """Determine if path is a legal nested repository."""
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -1011,6 +1011,12 @@
>                     " for more information"))
>      return requirements
>
> +def writerequires(opener, requirements):
> +    reqfile = opener("requires", "w")
> +    for r in sorted(requirements):
> +        reqfile.write("%s\n" % r)
> +    reqfile.close()
> +
>  class filecachesubentry(object):
>      def __init__(self, path, stat):
>          self.path = path
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150505/388248e3/attachment.html>


More information about the Mercurial-devel mailing list