# HG changeset patch # User FUJIWARA Katsunori # Date 2014-07-07 09:45:46 # Node ID 87aa279f707310f7953e2cf77d14f76509abb5ce # Parent 12019e6aa8a21613f0ba413048b77a231c5ac7e3 largefiles: show also how many data entities are outgoing at "hg outgoing" Before this patch, "hg outgoing --large" shows which largefiles are changed or added in outgoing revisions only in the point of the view of filenames. For example, according to the list of outgoing largefiles shown in "hg outgoing" output, users should expect that the former below costs much more to upload outgoing largefiles than the latter. - outgoing revisions add a hundred largefiles, but all of them refer the same data entity in this case, only one data entity is outgoing, even though "hg summary" says that a hundred largefiles are outgoing. - a hundred outgoing revisions change only one largefile with distinct data in this case, a hundred data entities are outgoing, even though "hg summary" says that only one largefile is outgoing. But the latter costs much more than the former, in fact. This patch shows also how many data entities are outgoing at "hg outgoing" by counting number of unique hash values for outgoing largefiles. When "--debug" is specified, this patch also shows what entities (in hash) are outgoing for each largefiles listed up, for debug purpose. In "ui.debugflag" route, "addfunc()" can append given "lfhash" to the list "toupload[fn]" always without duplication check, because de-duplication is already done in "_getoutgoings()". diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -1009,15 +1009,34 @@ def _getoutgoings(repo, missing, addfunc def outgoinghook(ui, repo, other, opts, missing): if opts.pop('large', None): - toupload = set() - lfutil.getlfilestoupload(repo, missing, - lambda fn, lfhash: toupload.add(fn)) + lfhashes = set() + if ui.debugflag: + toupload = {} + def addfunc(fn, lfhash): + if fn not in toupload: + toupload[fn] = [] + toupload[fn].append(lfhash) + lfhashes.add(lfhash) + def showhashes(fn): + for lfhash in sorted(toupload[fn]): + ui.debug(' %s\n' % (lfhash)) + else: + toupload = set() + def addfunc(fn, lfhash): + toupload.add(fn) + lfhashes.add(lfhash) + def showhashes(fn): + pass + _getoutgoings(repo, missing, addfunc) + if not toupload: ui.status(_('largefiles: no files to upload\n')) else: - ui.status(_('largefiles to upload:\n')) + ui.status(_('largefiles to upload (%d entities):\n') + % (len(lfhashes))) for file in sorted(toupload): ui.status(lfutil.splitstandin(file) + '\n') + showhashes(file) ui.status('\n') def summaryremotehook(ui, repo, opts, changes): 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 @@ -478,7 +478,7 @@ check messages when there are files to u date: Thu Jan 01 00:00:00 1970 +0000 summary: #1 - largefiles to upload: + largefiles to upload (1 entities): b $ hg -R clone2 outgoing --large --graph --template "{rev}" @@ -486,7 +486,7 @@ check messages when there are files to u searching for changes @ 1 - largefiles to upload: + largefiles to upload (1 entities): b @@ -509,11 +509,28 @@ check messages when there are files to u searching for changes 1:1acbe71ce432 2:6095d0695d70 - largefiles to upload: + largefiles to upload (1 entities): b b1 b2 + $ hg -R clone2 cat -r 1 clone2/.hglf/b + 89e6c98d92887913cadf06b2adb97f26cde4849b + $ hg -R clone2 outgoing --large -T "{rev}:{node|short}\n" --debug + comparing with $TESTTMP/issue3651/src (glob) + query 1; heads + searching for changes + all remote heads known locally + 1:1acbe71ce432 + 2:6095d0695d70 + largefiles to upload (1 entities): + b + 89e6c98d92887913cadf06b2adb97f26cde4849b + b1 + 89e6c98d92887913cadf06b2adb97f26cde4849b + b2 + 89e6c98d92887913cadf06b2adb97f26cde4849b + $ echo bbb > clone2/b $ hg -R clone2 commit -m '#3: add new largefile entity as existing file' @@ -542,11 +559,35 @@ check messages when there are files to u 3:7983dce246cc 4:233f12ada4ae 5:036794ea641c - largefiles to upload: + largefiles to upload (3 entities): b b1 b2 + $ hg -R clone2 cat -r 3 clone2/.hglf/b + c801c9cfe94400963fcb683246217d5db77f9a9a + $ hg -R clone2 cat -r 4 clone2/.hglf/b + 13f9ed0898e315bf59dc2973fec52037b6f441a2 + $ hg -R clone2 outgoing --large -T "{rev}:{node|short}\n" --debug + comparing with $TESTTMP/issue3651/src (glob) + query 1; heads + searching for changes + all remote heads known locally + 1:1acbe71ce432 + 2:6095d0695d70 + 3:7983dce246cc + 4:233f12ada4ae + 5:036794ea641c + largefiles to upload (3 entities): + b + 13f9ed0898e315bf59dc2973fec52037b6f441a2 + 89e6c98d92887913cadf06b2adb97f26cde4849b + c801c9cfe94400963fcb683246217d5db77f9a9a + b1 + 89e6c98d92887913cadf06b2adb97f26cde4849b + b2 + 89e6c98d92887913cadf06b2adb97f26cde4849b + $ cd .. diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t --- a/tests/test-largefiles.t +++ b/tests/test-largefiles.t @@ -680,7 +680,7 @@ Test that outgoing --large works (with r date: Thu Jan 01 00:00:00 1970 +0000 summary: this used to not notice the rm - largefiles to upload: + largefiles to upload (2 entities): foo large large8