Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 23170:02e8f9b60052
bundle2: support a "version" argument in `changegroup` part
When included, this mandatory parameter (mandatory == cannot be ignored) lets the
part handler select the right cgunpacker class.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 24 Sep 2014 21:33:12 -0700 |
parents | e4dc2b0be056 |
children | ca38764e2f38 |
comparison
equal
deleted
inserted
replaced
23169:e4dc2b0be056 | 23170:02e8f9b60052 |
---|---|
900 """extract the list of supported obsmarkers versions from a bundle2caps dict | 900 """extract the list of supported obsmarkers versions from a bundle2caps dict |
901 """ | 901 """ |
902 obscaps = caps.get('b2x:obsmarkers', ()) | 902 obscaps = caps.get('b2x:obsmarkers', ()) |
903 return [int(c[1:]) for c in obscaps if c.startswith('V')] | 903 return [int(c[1:]) for c in obscaps if c.startswith('V')] |
904 | 904 |
905 @parthandler('b2x:changegroup') | 905 @parthandler('b2x:changegroup', ('version',)) |
906 def handlechangegroup(op, inpart): | 906 def handlechangegroup(op, inpart): |
907 """apply a changegroup part on the repo | 907 """apply a changegroup part on the repo |
908 | 908 |
909 This is a very early implementation that will massive rework before being | 909 This is a very early implementation that will massive rework before being |
910 inflicted to any end-user. | 910 inflicted to any end-user. |
913 # | 913 # |
914 # The addchangegroup function will get a transaction object by itself, but | 914 # The addchangegroup function will get a transaction object by itself, but |
915 # we need to make sure we trigger the creation of a transaction object used | 915 # we need to make sure we trigger the creation of a transaction object used |
916 # for the whole processing scope. | 916 # for the whole processing scope. |
917 op.gettransaction() | 917 op.gettransaction() |
918 cg = changegroup.cg1unpacker(inpart, 'UN') | 918 unpackerversion = inpart.params.get('version', '01') |
919 # We should raise an appropriate exception here | |
920 unpacker = changegroup.packermap[unpackerversion][1] | |
921 cg = unpacker(inpart, 'UN') | |
919 # the source and url passed here are overwritten by the one contained in | 922 # the source and url passed here are overwritten by the one contained in |
920 # the transaction.hookargs argument. So 'bundle2' is a placeholder | 923 # the transaction.hookargs argument. So 'bundle2' is a placeholder |
921 ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2') | 924 ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2') |
922 op.records.add('changegroup', {'return': ret}) | 925 op.records.add('changegroup', {'return': ret}) |
923 if op.reply is not None: | 926 if op.reply is not None: |