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

login
register
mail settings
Submitter Drew Gottlieb
Date May 4, 2015, 6:27 p.m.
Message ID <3f86e3b2548def52732e.1430764077@waste.org>
Download mbox | patch
Permalink /patch/8868/
State Accepted
Commit 5abd0a76bc8fd4608308818480703e83c53ea9cc
Headers show

Comments

Drew Gottlieb - May 4, 2015, 6:27 p.m.
# HG changeset patch
# User Drew Gottlieb <drgott@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.
Martin von Zweigbergk - May 5, 2015, 3:32 p.m.
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@google.com> wrote:

> # HG changeset patch
> # User Drew Gottlieb <drgott@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@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Pierre-Yves David - May 5, 2015, 7:54 p.m.
On 05/04/2015 11:27 AM, Drew Gottlieb wrote:
> # HG changeset patch
> # User Drew Gottlieb <drgott@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.

Pushed to the clowncopter. http://goo.gl/6pJhkc

Patch

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