Patchwork journal: rename on disk files to 'namejournal'

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 26, 2016, 10:53 a.m.
Message ID <12908f37248000179f42.1472208791@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/16450/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 26, 2016, 10:53 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1472003959 -7200
#      Wed Aug 24 03:59:19 2016 +0200
# Node ID 12908f37248000179f42892a49d3b4751274d7a6
# Parent  4435d4c951ec2185d92cbe0041852767dda584c8
# EXP-Topic journal.namespace
journal: rename on disk files to 'namejournal'

The 'journal' naming is already used by the transaction journal. Having an
unrelated group of file with such a close naming is confusing and error prone.
We rename the file used by the 'journal' extension to use 'namejournal' as the
extension track the location of various 'names'.
Durham Goode - Aug. 27, 2016, 6:12 p.m.
Was journal marked experimental in the latest release?  Otherwise this 
seems BC breaking.


On 8/26/16 3:53 AM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1472003959 -7200
> #      Wed Aug 24 03:59:19 2016 +0200
> # Node ID 12908f37248000179f42892a49d3b4751274d7a6
> # Parent  4435d4c951ec2185d92cbe0041852767dda584c8
> # EXP-Topic journal.namespace
> journal: rename on disk files to 'namejournal'
>
> The 'journal' naming is already used by the transaction journal. Having an
> unrelated group of file with such a close naming is confusing and error prone.
> We rename the file used by the 'journal' extension to use 'namejournal' as the
> extension track the location of various 'names'.
>
> diff -r 4435d4c951ec -r 12908f372480 hgext/journal.py
> --- a/hgext/journal.py	Thu Aug 25 01:00:26 2016 -0400
> +++ b/hgext/journal.py	Wed Aug 24 03:59:19 2016 +0200
> @@ -162,12 +162,12 @@ def unsharejournal(orig, ui, repo, repop
>               # there is a shared repository and there are shared journal entries
>               # to copy. move shared date over from source to destination but
>               # move the local file first
> -            if repo.vfs.exists('journal'):
> -                journalpath = repo.join('journal')
> +            if repo.vfs.exists('namejournal'):
> +                journalpath = repo.join('namejournal')
>                   util.rename(journalpath, journalpath + '.bak')
>               storage = repo.journal
>               local = storage._open(
> -                repo.vfs, filename='journal.bak', _newestfirst=False)
> +                repo.vfs, filename='namejournal.bak', _newestfirst=False)
>               shared = (
>                   e for e in storage._open(sharedrepo.vfs, _newestfirst=False)
>                   if sharednamespaces.get(e.namespace) in sharedfeatures)
> @@ -273,13 +273,13 @@ class journalstorage(object):
>               raise error.Abort(_('journal lock does not support nesting'))
>           desc = _('journal of %s') % vfs.base
>           try:
> -            l = lock.lock(vfs, 'journal.lock', 0, desc=desc)
> +            l = lock.lock(vfs, 'namejournal.lock', 0, desc=desc)
>           except error.LockHeld as inst:
>               self.ui.warn(
>                   _("waiting for lock on %s held by %r\n") % (desc, inst.locker))
>               # default to 600 seconds timeout
>               l = lock.lock(
> -                vfs, 'journal.lock',
> +                vfs, 'namejournal.lock',
>                   int(self.ui.config("ui", "timeout", "600")), desc=desc)
>               self.ui.warn(_("got lock after %s seconds\n") % l.delay)
>           self._lockref = weakref.ref(l)
> @@ -319,7 +319,7 @@ class journalstorage(object):
>           with self.jlock(vfs):
>               version = None
>               # open file in amend mode to ensure it is created if missing
> -            with vfs('journal', mode='a+b', atomictemp=True) as f:
> +            with vfs('namejournal', mode='a+b', atomictemp=True) as f:
>                   f.seek(0, os.SEEK_SET)
>                   # Read just enough bytes to get a version number (up to 2
>                   # digits plus separator)
> @@ -377,7 +377,7 @@ class journalstorage(object):
>               if sharednamespaces.get(e.namespace) in self.sharedfeatures)
>           return _mergeentriesiter(local, shared)
>   
> -    def _open(self, vfs, filename='journal', _newestfirst=True):
> +    def _open(self, vfs, filename='namejournal', _newestfirst=True):
>           if not vfs.exists(filename):
>               return
>   
> diff -r 4435d4c951ec -r 12908f372480 tests/test-journal.t
> --- a/tests/test-journal.t	Thu Aug 25 01:00:26 2016 -0400
> +++ b/tests/test-journal.t	Wed Aug 24 03:59:19 2016 +0200
> @@ -232,7 +232,7 @@ Test that verbose, JSON, template and co
>   
>   Test for behaviour on unexpected storage version information
>   
> -  $ printf '42\0' > .hg/journal
> +  $ printf '42\0' > .hg/namejournal
>     $ hg journal
>     previous locations of '.':
>     abort: unknown journal file version '42'
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DQIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=9971hZJGu4C0DNEfyfViw1jMJtIKsFjz8UGcTwW1hH0&s=v5HLuNdhi1_h0MO-UzoWtxIZMljK0fhIghWhmgRdN24&e=
Gábor Stefanik - Aug. 27, 2016, 10:47 p.m.
Please forgive my ignorance, but do we even have BC guarantees for extensions?



On Sat, Aug 27, 2016 at 8:13 PM +0200, "Durham Goode" <durham@fb.com<mailto:durham@fb.com>> wrote:

Was journal marked experimental in the latest release?  Otherwise this
seems BC breaking.


On 8/26/16 3:53 AM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1472003959 -7200
> #      Wed Aug 24 03:59:19 2016 +0200
> # Node ID 12908f37248000179f42892a49d3b4751274d7a6
> # Parent  4435d4c951ec2185d92cbe0041852767dda584c8
> # EXP-Topic journal.namespace
> journal: rename on disk files to 'namejournal'
>
> The 'journal' naming is already used by the transaction journal. Having an
> unrelated group of file with such a close naming is confusing and error prone.
> We rename the file used by the 'journal' extension to use 'namejournal' as the
> extension track the location of various 'names'.
>
> diff -r 4435d4c951ec -r 12908f372480 hgext/journal.py
> --- a/hgext/journal.py        Thu Aug 25 01:00:26 2016 -0400
> +++ b/hgext/journal.py        Wed Aug 24 03:59:19 2016 +0200
> @@ -162,12 +162,12 @@ def unsharejournal(orig, ui, repo, repop
>               # there is a shared repository and there are shared journal entries
>               # to copy. move shared date over from source to destination but
>               # move the local file first
> -            if repo.vfs.exists('journal'):
> -                journalpath = repo.join('journal')
> +            if repo.vfs.exists('namejournal'):
> +                journalpath = repo.join('namejournal')
>                   util.rename(journalpath, journalpath + '.bak')
>               storage = repo.journal
>               local = storage._open(
> -                repo.vfs, filename='journal.bak', _newestfirst=False)
> +                repo.vfs, filename='namejournal.bak', _newestfirst=False)
>               shared = (
>                   e for e in storage._open(sharedrepo.vfs, _newestfirst=False)
>                   if sharednamespaces.get(e.namespace) in sharedfeatures)
> @@ -273,13 +273,13 @@ class journalstorage(object):
>               raise error.Abort(_('journal lock does not support nesting'))
>           desc = _('journal of %s') % vfs.base
>           try:
> -            l = lock.lock(vfs, 'journal.lock', 0, desc=desc)
> +            l = lock.lock(vfs, 'namejournal.lock', 0, desc=desc)
>           except error.LockHeld as inst:
>               self.ui.warn(
>                   _("waiting for lock on %s held by %r\n") % (desc, inst.locker))
>               # default to 600 seconds timeout
>               l = lock.lock(
> -                vfs, 'journal.lock',
> +                vfs, 'namejournal.lock',
>                   int(self.ui.config("ui", "timeout", "600")), desc=desc)
>               self.ui.warn(_("got lock after %s seconds\n") % l.delay)
>           self._lockref = weakref.ref(l)
> @@ -319,7 +319,7 @@ class journalstorage(object):
>           with self.jlock(vfs):
>               version = None
>               # open file in amend mode to ensure it is created if missing
> -            with vfs('journal', mode='a+b', atomictemp=True) as f:
> +            with vfs('namejournal', mode='a+b', atomictemp=True) as f:
>                   f.seek(0, os.SEEK_SET)
>                   # Read just enough bytes to get a version number (up to 2
>                   # digits plus separator)
> @@ -377,7 +377,7 @@ class journalstorage(object):
>               if sharednamespaces.get(e.namespace) in self.sharedfeatures)
>           return _mergeentriesiter(local, shared)
>
> -    def _open(self, vfs, filename='journal', _newestfirst=True):
> +    def _open(self, vfs, filename='namejournal', _newestfirst=True):
>           if not vfs.exists(filename):
>               return
>
> diff -r 4435d4c951ec -r 12908f372480 tests/test-journal.t
> --- a/tests/test-journal.t    Thu Aug 25 01:00:26 2016 -0400
> +++ b/tests/test-journal.t    Wed Aug 24 03:59:19 2016 +0200
> @@ -232,7 +232,7 @@ Test that verbose, JSON, template and co
>
>   Test for behaviour on unexpected storage version information
>
> -  $ printf '42\0' > .hg/journal
> +  $ printf '42\0' > .hg/namejournal
>     $ hg journal
>     previous locations of '.':
>     abort: unknown journal file version '42'
>

[cid:image5d8cd3.GIF@90809048.40ba132f]
Pierre-Yves David - Aug. 28, 2016, 1:11 a.m.
On 08/27/2016 08:12 PM, Durham Goode wrote:
> Was journal marked experimental in the latest release?  Otherwise this
> seems BC breaking.

Journal is still marked as experimental right now.
Augie Fackler - Aug. 29, 2016, 2:14 p.m.
On Fri, Aug 26, 2016 at 12:53:11PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1472003959 -7200
> #      Wed Aug 24 03:59:19 2016 +0200
> # Node ID 12908f37248000179f42892a49d3b4751274d7a6
> # Parent  4435d4c951ec2185d92cbe0041852767dda584c8
> # EXP-Topic journal.namespace
> journal: rename on disk files to 'namejournal'

Seems fine. Queued, thanks.

>
> The 'journal' naming is already used by the transaction journal. Having an
> unrelated group of file with such a close naming is confusing and error prone.
> We rename the file used by the 'journal' extension to use 'namejournal' as the
> extension track the location of various 'names'.
>
> diff -r 4435d4c951ec -r 12908f372480 hgext/journal.py
> --- a/hgext/journal.py	Thu Aug 25 01:00:26 2016 -0400
> +++ b/hgext/journal.py	Wed Aug 24 03:59:19 2016 +0200
> @@ -162,12 +162,12 @@ def unsharejournal(orig, ui, repo, repop
>              # there is a shared repository and there are shared journal entries
>              # to copy. move shared date over from source to destination but
>              # move the local file first
> -            if repo.vfs.exists('journal'):
> -                journalpath = repo.join('journal')
> +            if repo.vfs.exists('namejournal'):
> +                journalpath = repo.join('namejournal')
>                  util.rename(journalpath, journalpath + '.bak')
>              storage = repo.journal
>              local = storage._open(
> -                repo.vfs, filename='journal.bak', _newestfirst=False)
> +                repo.vfs, filename='namejournal.bak', _newestfirst=False)
>              shared = (
>                  e for e in storage._open(sharedrepo.vfs, _newestfirst=False)
>                  if sharednamespaces.get(e.namespace) in sharedfeatures)
> @@ -273,13 +273,13 @@ class journalstorage(object):
>              raise error.Abort(_('journal lock does not support nesting'))
>          desc = _('journal of %s') % vfs.base
>          try:
> -            l = lock.lock(vfs, 'journal.lock', 0, desc=desc)
> +            l = lock.lock(vfs, 'namejournal.lock', 0, desc=desc)
>          except error.LockHeld as inst:
>              self.ui.warn(
>                  _("waiting for lock on %s held by %r\n") % (desc, inst.locker))
>              # default to 600 seconds timeout
>              l = lock.lock(
> -                vfs, 'journal.lock',
> +                vfs, 'namejournal.lock',
>                  int(self.ui.config("ui", "timeout", "600")), desc=desc)
>              self.ui.warn(_("got lock after %s seconds\n") % l.delay)
>          self._lockref = weakref.ref(l)
> @@ -319,7 +319,7 @@ class journalstorage(object):
>          with self.jlock(vfs):
>              version = None
>              # open file in amend mode to ensure it is created if missing
> -            with vfs('journal', mode='a+b', atomictemp=True) as f:
> +            with vfs('namejournal', mode='a+b', atomictemp=True) as f:
>                  f.seek(0, os.SEEK_SET)
>                  # Read just enough bytes to get a version number (up to 2
>                  # digits plus separator)
> @@ -377,7 +377,7 @@ class journalstorage(object):
>              if sharednamespaces.get(e.namespace) in self.sharedfeatures)
>          return _mergeentriesiter(local, shared)
>
> -    def _open(self, vfs, filename='journal', _newestfirst=True):
> +    def _open(self, vfs, filename='namejournal', _newestfirst=True):
>          if not vfs.exists(filename):
>              return
>
> diff -r 4435d4c951ec -r 12908f372480 tests/test-journal.t
> --- a/tests/test-journal.t	Thu Aug 25 01:00:26 2016 -0400
> +++ b/tests/test-journal.t	Wed Aug 24 03:59:19 2016 +0200
> @@ -232,7 +232,7 @@ Test that verbose, JSON, template and co
>
>  Test for behaviour on unexpected storage version information
>
> -  $ printf '42\0' > .hg/journal
> +  $ printf '42\0' > .hg/namejournal
>    $ hg journal
>    previous locations of '.':
>    abort: unknown journal file version '42'
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Matt Mackall - Aug. 29, 2016, 10:02 p.m.
On Sat, 2016-08-27 at 22:47 +0000, Gábor STEFANIK wrote:
> Please forgive my ignorance, but do we even have BC guarantees for extensions?

Yes.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff -r 4435d4c951ec -r 12908f372480 hgext/journal.py
--- a/hgext/journal.py	Thu Aug 25 01:00:26 2016 -0400
+++ b/hgext/journal.py	Wed Aug 24 03:59:19 2016 +0200
@@ -162,12 +162,12 @@  def unsharejournal(orig, ui, repo, repop
             # there is a shared repository and there are shared journal entries
             # to copy. move shared date over from source to destination but
             # move the local file first
-            if repo.vfs.exists('journal'):
-                journalpath = repo.join('journal')
+            if repo.vfs.exists('namejournal'):
+                journalpath = repo.join('namejournal')
                 util.rename(journalpath, journalpath + '.bak')
             storage = repo.journal
             local = storage._open(
-                repo.vfs, filename='journal.bak', _newestfirst=False)
+                repo.vfs, filename='namejournal.bak', _newestfirst=False)
             shared = (
                 e for e in storage._open(sharedrepo.vfs, _newestfirst=False)
                 if sharednamespaces.get(e.namespace) in sharedfeatures)
@@ -273,13 +273,13 @@  class journalstorage(object):
             raise error.Abort(_('journal lock does not support nesting'))
         desc = _('journal of %s') % vfs.base
         try:
-            l = lock.lock(vfs, 'journal.lock', 0, desc=desc)
+            l = lock.lock(vfs, 'namejournal.lock', 0, desc=desc)
         except error.LockHeld as inst:
             self.ui.warn(
                 _("waiting for lock on %s held by %r\n") % (desc, inst.locker))
             # default to 600 seconds timeout
             l = lock.lock(
-                vfs, 'journal.lock',
+                vfs, 'namejournal.lock',
                 int(self.ui.config("ui", "timeout", "600")), desc=desc)
             self.ui.warn(_("got lock after %s seconds\n") % l.delay)
         self._lockref = weakref.ref(l)
@@ -319,7 +319,7 @@  class journalstorage(object):
         with self.jlock(vfs):
             version = None
             # open file in amend mode to ensure it is created if missing
-            with vfs('journal', mode='a+b', atomictemp=True) as f:
+            with vfs('namejournal', mode='a+b', atomictemp=True) as f:
                 f.seek(0, os.SEEK_SET)
                 # Read just enough bytes to get a version number (up to 2
                 # digits plus separator)
@@ -377,7 +377,7 @@  class journalstorage(object):
             if sharednamespaces.get(e.namespace) in self.sharedfeatures)
         return _mergeentriesiter(local, shared)
 
-    def _open(self, vfs, filename='journal', _newestfirst=True):
+    def _open(self, vfs, filename='namejournal', _newestfirst=True):
         if not vfs.exists(filename):
             return
 
diff -r 4435d4c951ec -r 12908f372480 tests/test-journal.t
--- a/tests/test-journal.t	Thu Aug 25 01:00:26 2016 -0400
+++ b/tests/test-journal.t	Wed Aug 24 03:59:19 2016 +0200
@@ -232,7 +232,7 @@  Test that verbose, JSON, template and co
 
 Test for behaviour on unexpected storage version information
 
-  $ printf '42\0' > .hg/journal
+  $ printf '42\0' > .hg/namejournal
   $ hg journal
   previous locations of '.':
   abort: unknown journal file version '42'