Patchwork [V3] files: write filenode hash if --debug is passed

login
register
mail settings
Submitter David Soria Parra
Date April 10, 2015, 4:31 p.m.
Message ID <de49a8dd7d9a2c53e70b.1428683487@davidsp-mbp.local>
Download mbox | patch
Permalink /patch/8599/
State Changes Requested
Headers show

Comments

David Soria Parra - April 10, 2015, 4:31 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1427163012 25200
#      Mon Mar 23 19:10:12 2015 -0700
# Node ID de49a8dd7d9a2c53e70bfe1436117811ba8b9f72
# Parent  811a1842cfe5f632145912d9bf2dc859e6ee3eeb
files: write filenode hash if --debug is passed

Write the filenode hash similar to hg manifest if --debug is passed.
This allows to retrieve the filenode hash for a specific patho.
Martin von Zweigbergk - April 10, 2015, 5:02 p.m.
On Fri, Apr 10, 2015 at 9:32 AM David Soria Parra <davidsp@fb.com> wrote:

> # HG changeset patch
> # User David Soria Parra <davidsp@fb.com>
> # Date 1427163012 25200
> #      Mon Mar 23 19:10:12 2015 -0700
> # Node ID de49a8dd7d9a2c53e70bfe1436117811ba8b9f72
> # Parent  811a1842cfe5f632145912d9bf2dc859e6ee3eeb
> files: write filenode hash if --debug is passed
>
> Write the filenode hash similar to hg manifest if --debug is passed.
> This allows to retrieve the filenode hash for a specific patho.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2264,13 +2264,20 @@
>      rev = ctx.rev()
>      ret = 1
>      ds = ctx.repo().dirstate
> -
> +    st = ctx.repo().status()
> +    changed = st.modified + st.removed
>      for f in ctx.matches(m):
>          if rev is None and ds[f] == 'r':
>              continue
>          fm.startitem()
>          if ui.verbose:
>              fc = ctx[f]
> +            if ui.debugflag:
> +                if f in changed:
> +                    formatstr = '%s+ '
> +                else:
> +                    formatstr = '%s  '
> +                fm.write('hash', formatstr, hex(fc.filenode()))
>              fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
>          fm.data(abspath=f)
>          fm.write('path', fmt, m.rel(f))
> diff --git a/tests/test-manifest.t b/tests/test-manifest.t
> --- a/tests/test-manifest.t
> +++ b/tests/test-manifest.t
> @@ -32,6 +32,32 @@
>    a
>    l
>
> +  $ hg files -r . -X b --debug
> +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3           2   a
> +  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
> +
> +  $ echo a >> a
> +  $ hg files -r . -X b --debug
> +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3+          2   a
>

This is surprising to me. I would not expect the "+" on any files that
changed in revision ".". I think the suffix is to indicate that the nodeid
is still unknown. For any committed file revisions, the nodeid is known and
I think it should not have the suffix.

I'd like to see the output of "hg --debug" without "-r ." for modified,
added and removed files as well.


> +  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
> +  $ hg revert --all
> +  reverting a
> +
> +  $ echo new >> new
> +  $ hg add new
> +  $ hg files -r . -X b --debug
> +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3           2   a
> +  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
> +
> +  $ hg rm a
> +  $ hg files -r . -X b --debug
> +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3+          2   a
> +  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
> +
> +  $ hg revert --all
> +  undeleting a
> +  forgetting new
> +
>    $ hg manifest -v
>    644   a
>    755 * b/a
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Pierre-Yves David - April 14, 2015, 8:06 p.m.
On 04/10/2015 01:02 PM, Martin von Zweigbergk wrote:
>
> On Fri, Apr 10, 2015 at 9:32 AM David Soria Parra <davidsp@fb.com
> <mailto:davidsp@fb.com>> wrote:
>
>     # HG changeset patch
>     # User David Soria Parra <davidsp@fb.com <mailto:davidsp@fb.com>>
>     # Date 1427163012 25200
>     #      Mon Mar 23 19:10:12 2015 -0700
>     # Node ID de49a8dd7d9a2c53e70bfe1436117811ba8b9f72
>     # Parent  811a1842cfe5f632145912d9bf2dc859e6ee3eeb
>     files: write filenode hash if --debug is passed
>
>     Write the filenode hash similar to hg manifest if --debug is passed.
>     This allows to retrieve the filenode hash for a specific patho.
>
>     diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
>     --- a/mercurial/cmdutil.py
>     +++ b/mercurial/cmdutil.py
>     @@ -2264,13 +2264,20 @@
>           rev = ctx.rev()
>           ret = 1
>           ds = ctx.repo().dirstate
>     -
>     +    st = ctx.repo().status()
>     +    changed = st.modified + st.removed
>           for f in ctx.matches(m):
>               if rev is None and ds[f] == 'r':
>                   continue
>               fm.startitem()
>               if ui.verbose:
>                   fc = ctx[f]
>     +            if ui.debugflag:
>     +                if f in changed:
>     +                    formatstr = '%s+ '
>     +                else:
>     +                    formatstr = '%s  '
>     +                fm.write('hash', formatstr, hex(fc.filenode()))
>                   fm.write('size flags', '% 10d % 1s ', fc.size(),
>     fc.flags())
>               fm.data(abspath=f)
>               fm.write('path', fmt, m.rel(f))
>     diff --git a/tests/test-manifest.t b/tests/test-manifest.t
>     --- a/tests/test-manifest.t
>     +++ b/tests/test-manifest.t
>     @@ -32,6 +32,32 @@
>         a
>         l
>
>     +  $ hg files -r . -X b --debug
>     +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3           2   a
>     +  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
>     +
>     +  $ echo a >> a
>     +  $ hg files -r . -X b --debug
>     +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3+          2   a
>
>
> This is surprising to me. I would not expect the "+" on any files that
> changed in revision ".". I think the suffix is to indicate that the
> nodeid is still unknown. For any committed file revisions, the nodeid is
> known and I think it should not have the suffix.
>
> I'd like to see the output of "hg --debug" without "-r ." for modified,
> added and removed files as well.

I shared the same confusion as Martin and dropping this from the 
clowncopter.
Martin von Zweigbergk - April 14, 2015, 8:12 p.m.
How about we allow --debug only with --rev, at least for now, to make some
progress? That would take us one step closer to deprecating 'hg manifest'.


On Tue, Apr 14, 2015 at 1:06 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

>
>
> On 04/10/2015 01:02 PM, Martin von Zweigbergk wrote:
> >
> > On Fri, Apr 10, 2015 at 9:32 AM David Soria Parra <davidsp@fb.com
> > <mailto:davidsp@fb.com>> wrote:
> >
> >     # HG changeset patch
> >     # User David Soria Parra <davidsp@fb.com <mailto:davidsp@fb.com>>
> >     # Date 1427163012 25200
> >     #      Mon Mar 23 19:10:12 2015 -0700
> >     # Node ID de49a8dd7d9a2c53e70bfe1436117811ba8b9f72
> >     # Parent  811a1842cfe5f632145912d9bf2dc859e6ee3eeb
> >     files: write filenode hash if --debug is passed
> >
> >     Write the filenode hash similar to hg manifest if --debug is passed.
> >     This allows to retrieve the filenode hash for a specific patho.
> >
> >     diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> >     --- a/mercurial/cmdutil.py
> >     +++ b/mercurial/cmdutil.py
> >     @@ -2264,13 +2264,20 @@
> >           rev = ctx.rev()
> >           ret = 1
> >           ds = ctx.repo().dirstate
> >     -
> >     +    st = ctx.repo().status()
> >     +    changed = st.modified + st.removed
> >           for f in ctx.matches(m):
> >               if rev is None and ds[f] == 'r':
> >                   continue
> >               fm.startitem()
> >               if ui.verbose:
> >                   fc = ctx[f]
> >     +            if ui.debugflag:
> >     +                if f in changed:
> >     +                    formatstr = '%s+ '
> >     +                else:
> >     +                    formatstr = '%s  '
> >     +                fm.write('hash', formatstr, hex(fc.filenode()))
> >                   fm.write('size flags', '% 10d % 1s ', fc.size(),
> >     fc.flags())
> >               fm.data(abspath=f)
> >               fm.write('path', fmt, m.rel(f))
> >     diff --git a/tests/test-manifest.t b/tests/test-manifest.t
> >     --- a/tests/test-manifest.t
> >     +++ b/tests/test-manifest.t
> >     @@ -32,6 +32,32 @@
> >         a
> >         l
> >
> >     +  $ hg files -r . -X b --debug
> >     +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3           2   a
> >     +  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
> >     +
> >     +  $ echo a >> a
> >     +  $ hg files -r . -X b --debug
> >     +  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3+          2   a
> >
> >
> > This is surprising to me. I would not expect the "+" on any files that
> > changed in revision ".". I think the suffix is to indicate that the
> > nodeid is still unknown. For any committed file revisions, the nodeid is
> > known and I think it should not have the suffix.
> >
> > I'd like to see the output of "hg --debug" without "-r ." for modified,
> > added and removed files as well.
>
> I shared the same confusion as Martin and dropping this from the
> clowncopter.
>
> --
> Pierre-Yves David
>

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2264,13 +2264,20 @@ 
     rev = ctx.rev()
     ret = 1
     ds = ctx.repo().dirstate
-
+    st = ctx.repo().status()
+    changed = st.modified + st.removed
     for f in ctx.matches(m):
         if rev is None and ds[f] == 'r':
             continue
         fm.startitem()
         if ui.verbose:
             fc = ctx[f]
+            if ui.debugflag:
+                if f in changed:
+                    formatstr = '%s+ '
+                else:
+                    formatstr = '%s  '
+                fm.write('hash', formatstr, hex(fc.filenode()))
             fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
         fm.data(abspath=f)
         fm.write('path', fmt, m.rel(f))
diff --git a/tests/test-manifest.t b/tests/test-manifest.t
--- a/tests/test-manifest.t
+++ b/tests/test-manifest.t
@@ -32,6 +32,32 @@ 
   a
   l
 
+  $ hg files -r . -X b --debug
+  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3           2   a
+  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
+
+  $ echo a >> a
+  $ hg files -r . -X b --debug
+  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3+          2   a
+  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
+  $ hg revert --all
+  reverting a
+
+  $ echo new >> new
+  $ hg add new
+  $ hg files -r . -X b --debug
+  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3           2   a
+  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
+
+  $ hg rm a
+  $ hg files -r . -X b --debug
+  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3+          2   a
+  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597           1 l l
+
+  $ hg revert --all
+  undeleting a
+  forgetting new
+
   $ hg manifest -v
   644   a
   755 * b/a