Patchwork [4,of,4] doc: describe detail about checkambig optional argument

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 12, 2016, 8:15 p.m.
Message ID <a8dc7aac5e39d0982fce.1465762521@feefifofum>
Download mbox | patch
Permalink /patch/15473/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 12, 2016, 8:15 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1465762316 -32400
#      Mon Jun 13 05:11:56 2016 +0900
# Node ID a8dc7aac5e39d0982fce47a8b66ed206ecfd733e
# Parent  02167888292b1c6ce3f2993deff4612eaf0a7591
doc: describe detail about checkambig optional argument

This is followup for patches below, which add checkambig argument to
existing function.

  - 731ced087a4b
  - 76f1ea360c7e
  - ce2d81aafbae
  - a109bf7e0dc2
Yuya Nishihara - June 16, 2016, 12:44 p.m.
On Mon, 13 Jun 2016 05:15:21 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1465762316 -32400
> #      Mon Jun 13 05:11:56 2016 +0900
> # Node ID a8dc7aac5e39d0982fce47a8b66ed206ecfd733e
> # Parent  02167888292b1c6ce3f2993deff4612eaf0a7591
> doc: describe detail about checkambig optional argument

> +        (e.g. repo.lock or repo.slock).

Do you mean repo.wlock?
Katsunori FUJIWARA - June 17, 2016, 9:03 a.m.
At Thu, 16 Jun 2016 21:44:39 +0900,
Yuya Nishihara wrote:
> 
> On Mon, 13 Jun 2016 05:15:21 +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1465762316 -32400
> > #      Mon Jun 13 05:11:56 2016 +0900
> > # Node ID a8dc7aac5e39d0982fce47a8b66ed206ecfd733e
> > # Parent  02167888292b1c6ce3f2993deff4612eaf0a7591
> > doc: describe detail about checkambig optional argument
> 
> > +        (e.g. repo.lock or repo.slock).
> 
> Do you mean repo.wlock?

Oops, you are right. I confused repo.vfs/repo.svfs :-<

Could you fix inflight ? or would I send revised one ?

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Yuya Nishihara - June 17, 2016, 1:29 p.m.
On Fri, 17 Jun 2016 18:03:39 +0900, FUJIWARA Katsunori wrote:
> At Thu, 16 Jun 2016 21:44:39 +0900,
> Yuya Nishihara wrote:
> > On Mon, 13 Jun 2016 05:15:21 +0900, FUJIWARA Katsunori wrote:
> > > # HG changeset patch
> > > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > > # Date 1465762316 -32400
> > > #      Mon Jun 13 05:11:56 2016 +0900
> > > # Node ID a8dc7aac5e39d0982fce47a8b66ed206ecfd733e
> > > # Parent  02167888292b1c6ce3f2993deff4612eaf0a7591
> > > doc: describe detail about checkambig optional argument
> > 
> > > +        (e.g. repo.lock or repo.slock).
> > 
> > Do you mean repo.wlock?
> 
> Oops, you are right. I confused repo.vfs/repo.svfs :-<
> 
> Could you fix inflight ? or would I send revised one ?

sed 's/repo\.slock/repo.wlock/g' and pushed.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -379,6 +379,12 @@  class abstractvfs(object):
         return util.readlock(self.join(path))
 
     def rename(self, src, dst, checkambig=False):
+        """Rename from src to dst
+
+        checkambig argument is used with util.filestat, and is useful
+        only if destination file is guarded by any lock
+        (e.g. repo.lock or repo.slock).
+        """
         dstpath = self.join(dst)
         oldstat = checkambig and util.filestat(dstpath)
         if oldstat and oldstat.stat:
@@ -533,7 +539,9 @@  class vfs(abstractvfs):
            file were opened multiple times, there could be unflushed data
            because the original file handle hasn't been flushed/closed yet.)
 
-        ``checkambig`` is passed to atomictempfile (valid only for writing).
+        ``checkambig`` argument is passed to atomictemplfile (valid
+        only for writing), and is useful only if target file is
+        guarded by any lock (e.g. repo.lock or repo.slock).
         '''
         if self._audit:
             r = util.checkosfilename(path)
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1010,7 +1010,14 @@  def checksignature(func):
 
 def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False):
     '''copy a file, preserving mode and optionally other stat info like
-    atime/mtime'''
+    atime/mtime
+
+    checkambig argument is used with filestat, and is useful only if
+    destination file is guarded by any lock (e.g. repo.lock or
+    repo.slock).
+
+    copystat and checkambig should be exclusive.
+    '''
     assert not (copystat and checkambig)
     oldstat = None
     if os.path.lexists(dest):
@@ -1463,6 +1470,10 @@  class atomictempfile(object):
     the temporary copy to the original name, making the changes
     visible. If the object is destroyed without being closed, all your
     writes are discarded.
+
+    checkambig argument of constructor is used with filestat, and is
+    useful only if target file is guarded by any lock (e.g. repo.lock
+    or repo.slock).
     '''
     def __init__(self, name, mode='w+b', createmode=None, checkambig=False):
         self.__name = name      # permanent name