Patchwork [3,of,3] largefiles: handle logging from outside the repo

login
register
mail settings
Submitter Matt Harbison
Date March 4, 2015, 4:57 a.m.
Message ID <e4a6988bbd6fdb0c4fcf.1425445021@Envy>
Download mbox | patch
Permalink /patch/7897/
State Accepted
Commit e6b0de02a02e7fcf8369bc902edc9d0b60621586
Headers show

Comments

Matt Harbison - March 4, 2015, 4:57 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1425252929 18000
#      Sun Mar 01 18:35:29 2015 -0500
# Node ID e4a6988bbd6fdb0c4fcfcc8dbc324ec727590f2b
# Parent  4deaf73138da53d72506cc439f256cb5418bf548
largefiles: handle logging from outside the repo

It's probably possible to refactor so that the 'if m._cwd' check isn't
necessary, but the False case is the typical case (i.e. run from the root of the
repo), and simpler to read.

An exact path to a largefile from outside the repo was previously ignored.

match.rel('.hglf') will handle figuring out both the correct '../' length to the
standin directory if inside the repo, or path/to/repo from outside, at the cost
of a pconvert() to keep the patterns using '/' on Windows.
Matt Mackall - March 5, 2015, 7:27 p.m.
On Tue, 2015-03-03 at 23:57 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1425252929 18000
> #      Sun Mar 01 18:35:29 2015 -0500
> # Node ID e4a6988bbd6fdb0c4fcfcc8dbc324ec727590f2b
> # Parent  4deaf73138da53d72506cc439f256cb5418bf548
> largefiles: handle logging from outside the repo

These are queued for default, thanks. I added a "# no-msys" hint to
check-code and cleaned up patch 2.
Matt Harbison - March 6, 2015, 1:58 a.m.
On Thu, 05 Mar 2015 14:27:06 -0500, Matt Mackall <mpm@selenic.com> wrote:

> On Tue, 2015-03-03 at 23:57 -0500, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison@yahoo.com>
>> # Date 1425252929 18000
>> #      Sun Mar 01 18:35:29 2015 -0500
>> # Node ID e4a6988bbd6fdb0c4fcfcc8dbc324ec727590f2b
>> # Parent  4deaf73138da53d72506cc439f256cb5418bf548
>> largefiles: handle logging from outside the repo
>
> These are queued for default, thanks. I added a "# no-msys" hint to
> check-code and cleaned up patch 2.
>

OK, thanks.  Any thoughts 'glob:a*' seeing the rename of file 'a' -> 'b',  
but an explicit path 'a' doesn't?  (See the test-log.t change in  
13c1e66f9653, and the test immediately above the change.)

Nothing in my reading of 'hg help patterns' seems to explain it.

--Matt
Matt Mackall - March 6, 2015, 2:04 a.m.
On Thu, 2015-03-05 at 20:58 -0500, Matt Harbison wrote:
> On Thu, 05 Mar 2015 14:27:06 -0500, Matt Mackall <mpm@selenic.com> wrote:
> 
> > On Tue, 2015-03-03 at 23:57 -0500, Matt Harbison wrote:
> >> # HG changeset patch
> >> # User Matt Harbison <matt_harbison@yahoo.com>
> >> # Date 1425252929 18000
> >> #      Sun Mar 01 18:35:29 2015 -0500
> >> # Node ID e4a6988bbd6fdb0c4fcfcc8dbc324ec727590f2b
> >> # Parent  4deaf73138da53d72506cc439f256cb5418bf548
> >> largefiles: handle logging from outside the repo
> >
> > These are queued for default, thanks. I added a "# no-msys" hint to
> > check-code and cleaned up patch 2.
> >
> 
> OK, thanks.  Any thoughts 'glob:a*' seeing the rename of file 'a' -> 'b',  
> but an explicit path 'a' doesn't?  (See the test-log.t change in  
> 13c1e66f9653, and the test immediately above the change.)

Seems wrong.
Matt Harbison - March 6, 2015, 4:23 a.m.
On Thu, 05 Mar 2015 21:04:34 -0500, Matt Mackall <mpm@selenic.com> wrote:

> On Thu, 2015-03-05 at 20:58 -0500, Matt Harbison wrote:
>> On Thu, 05 Mar 2015 14:27:06 -0500, Matt Mackall <mpm@selenic.com>  
>> wrote:
>>
>> > On Tue, 2015-03-03 at 23:57 -0500, Matt Harbison wrote:
>> >> # HG changeset patch
>> >> # User Matt Harbison <matt_harbison@yahoo.com>
>> >> # Date 1425252929 18000
>> >> #      Sun Mar 01 18:35:29 2015 -0500
>> >> # Node ID e4a6988bbd6fdb0c4fcfcc8dbc324ec727590f2b
>> >> # Parent  4deaf73138da53d72506cc439f256cb5418bf548
>> >> largefiles: handle logging from outside the repo
>> >
>> > These are queued for default, thanks. I added a "# no-msys" hint to
>> > check-code and cleaned up patch 2.
>> >
>>
>> OK, thanks.  Any thoughts 'glob:a*' seeing the rename of file 'a' ->  
>> 'b',
>> but an explicit path 'a' doesn't?  (See the test-log.t change in
>> 13c1e66f9653, and the test immediately above the change.)
>
> Seems wrong.

What is happening here is that 'glob:*' causes match.anypats() to be True,  
which triggers the slow path, which uses the file() revset.  An explicit  
path uses filelog(), unless --remove is specified on the command line  
(which forces the slow path).

Now that I understand what is going on, I see there is a note in 'hg help  
log' that mentions "may omit duplicate changes, removals and mode changes"  
for performance reasons without --remove, so I'll leave it alone.

--Matt

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -313,19 +313,25 @@ 
             return tostandin(kindpat[1])
 
         if m._cwd:
-            if os.path.isabs(m._cwd):
-                # TODO: handle largefile magic when invoked from other cwd
-                return matchandpats
-            back = (m._cwd.count('/') + 1) * '../'
+            hglf = lfutil.shortname
+            back = util.pconvert(m.rel(hglf)[:-len(hglf)])
 
             def tostandin(f):
                 # The file may already be a standin, so trucate the back
-                # escaping and test before mangling it.  This avoids turning
+                # prefix and test before mangling it.  This avoids turning
                 # 'glob:../.hglf/foo*' into 'glob:../.hglf/../.hglf/foo*'.
                 if f.startswith(back) and lfutil.splitstandin(f[len(back):]):
                     return f
 
-                return back + lfutil.standin(m._cwd + '/' + f)
+                # An absolute path is from outside the repo, so truncate the
+                # path to the root before building the standin.  Otherwise cwd
+                # is somewhere in the repo, relative to root, and needs to be
+                # prepended before building the standin.
+                if os.path.isabs(m._cwd):
+                    f = f[len(back):]
+                else:
+                    f = m._cwd + '/' + f
+                return back + lfutil.standin(f)
 
             pats.update(fixpats(f, tostandin) for f in p)
         else:
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -451,6 +451,10 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     anotherlarge
   
+  $ hg --debug log -T '{rev}: {desc}\n' ../sub/anotherlarge
+  updated patterns: set(['../.hglf/sub/../sub/anotherlarge', '../sub/anotherlarge'])
+  1: anotherlarge
+
   $ hg log -G anotherlarge
   @  changeset:   1:9627a577c5e9
   |  tag:         tip
@@ -510,6 +514,15 @@ 
 
   $ cd ..
 
+Log from outer space
+  $ hg --debug log -R addrm2 -T '{rev}: {desc}\n' 'addrm2/sub/anotherlarge'
+  updated patterns: set(['addrm2/.hglf/sub/anotherlarge', 'addrm2/sub/anotherlarge'])
+  1: anotherlarge
+  $ hg --debug log -R addrm2 -T '{rev}: {desc}\n' 'addrm2/.hglf/sub/anotherlarge'
+  updated patterns: set(['addrm2/.hglf/sub/anotherlarge'])
+  1: anotherlarge
+
+
 Check error message while exchange
 =========================================================