changeset 36690:b529e640015d

merge with stable
author Augie Fackler <augie@google.com>
date Sun, 04 Mar 2018 10:42:51 -0500
parents 2a258985ffeb (current diff) b394778b1a50 (diff)
children 1b179d151578
files mercurial/context.py mercurial/subrepo.py mercurial/subrepoutil.py tests/test-annotate.t
diffstat 5 files changed, 211 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sat Mar 03 15:31:37 2018 -0800
+++ b/mercurial/context.py	Sun Mar 04 10:42:51 2018 -0500
@@ -1079,7 +1079,8 @@
                 hist[f] = curr
                 del pcache[f]
 
-        return pycompat.ziplist(hist[base][0], hist[base][1].splitlines(True))
+        lineattrs, text = hist[base]
+        return pycompat.ziplist(lineattrs, mdiff.splitnewlines(text))
 
     def ancestors(self, followfirst=False):
         visit = {}
--- a/mercurial/subrepo.py	Sat Mar 03 15:31:37 2018 -0800
+++ b/mercurial/subrepo.py	Sun Mar 04 10:42:51 2018 -0500
@@ -621,7 +621,13 @@
         if len(self._repo) == 0:
             # use self._repo.vfs instead of self.wvfs to remove .hg only
             self._repo.vfs.rmtree()
-            if parentrepo.shared():
+
+            # A remote subrepo could be shared if there is a local copy
+            # relative to the parent's share source.  But clone pooling doesn't
+            # assemble the repos in a tree, so that can't be consistently done.
+            # A simpler option is for the user to configure clone pooling, and
+            # work with that.
+            if parentrepo.shared() and hg.islocal(srcurl):
                 self.ui.status(_('sharing subrepo %s from %s\n')
                                % (subrelpath(self), srcurl))
                 shared = hg.share(self._repo._subparent.baseui,
@@ -629,11 +635,25 @@
                                   update=False, bookmarks=False)
                 self._repo = shared.local()
             else:
+                # TODO: find a common place for this and this code in the
+                # share.py wrap of the clone command.
+                if parentrepo.shared():
+                    pool = self.ui.config('share', 'pool')
+                    if pool:
+                        pool = util.expandpath(pool)
+
+                    shareopts = {
+                        'pool': pool,
+                        'mode': self.ui.config('share', 'poolnaming'),
+                    }
+                else:
+                    shareopts = {}
+
                 self.ui.status(_('cloning subrepo %s from %s\n')
                                % (subrelpath(self), srcurl))
                 other, cloned = hg.clone(self._repo._subparent.baseui, {},
                                          other, self._repo.root,
-                                         update=False)
+                                         update=False, shareopts=shareopts)
                 self._repo = cloned.local()
             self._initrepo(parentrepo, source, create=True)
             self._cachestorehash(srcurl)
--- a/tests/test-annotate.t	Sat Mar 03 15:31:37 2018 -0800
+++ b/tests/test-annotate.t	Sun Mar 04 10:42:51 2018 -0500
@@ -897,6 +897,38 @@
 
   $ cd ..
 
+Annotate with orphaned CR (issue5798)
+-------------------------------------
+
+  $ hg init repo-cr
+  $ cd repo-cr
+
+  $ substcr() {
+  > sed 's/\r/[CR]/g'
+  > }
+
+  >>> with open('a', 'wb') as f:
+  ...     f.write(b'0a\r0b\r\n0c\r0d\r\n0e\n0f\n0g')
+  $ hg ci -qAm0
+  >>> with open('a', 'wb') as f:
+  ...     f.write(b'0a\r0b\r\n1c\r1d\r\n0e\n1f\n0g')
+  $ hg ci -m1
+
+  $ hg annotate -r0 a | substcr
+  0: 0a[CR]0b[CR]
+  0: 0c[CR]0d[CR]
+  0: 0e
+  0: 0f
+  0: 0g
+  $ hg annotate -r1 a | substcr
+  0: 0a[CR]0b[CR]
+  1: 1c[CR]1d[CR]
+  0: 0e
+  1: 1f
+  0: 0g
+
+  $ cd ..
+
 Annotate with linkrev pointing to another branch
 ------------------------------------------------
 
--- a/tests/test-subrepo-recursion.t	Sat Mar 03 15:31:37 2018 -0800
+++ b/tests/test-subrepo-recursion.t	Sun Mar 04 10:42:51 2018 -0500
@@ -292,6 +292,43 @@
   z2
   z3
 
+Clone pooling from a remote URL will share the top level repo and the subrepos,
+even if they are referenced by remote URL.
+
+  $ hg --config extensions.share= --config share.pool=$TESTTMP/pool \
+  >    clone http://localhost:$HGPORT shared
+  (sharing from new pooled repository 23376cbba0d87c15906bb3652584927c140907bf)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 3 changesets with 5 changes to 3 files
+  new changesets 23376cbba0d8:1326fa26d0c0
+  searching for changes
+  no changes found
+  updating working directory
+  cloning subrepo foo from http://localhost:$HGPORT/foo
+  (sharing from new pooled repository af048e97ade2e236f754f05d07013e586af0f8bf)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 7 changes to 3 files
+  new changesets af048e97ade2:65903cebad86
+  searching for changes
+  no changes found
+  cloning subrepo foo/bar from http://localhost:$HGPORT/foo/bar
+  (sharing from new pooled repository 4904098473f96c900fec436dad267edd4da59fad)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 3 changesets with 3 changes to 1 files
+  new changesets 4904098473f9:31ecbdafd357
+  searching for changes
+  no changes found
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
   $ cat access.log
   * "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
   * "GET /?cmd=batch HTTP/1.1" 200 - * (glob)
@@ -302,6 +339,27 @@
   * "GET /foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
   * "GET /foo/bar?cmd=batch HTTP/1.1" 200 - * (glob)
   * "GET /foo/bar?cmd=getbundle HTTP/1.1" 200 - * (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=0 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=1326fa26d0c00d2146c63b56bb6a45149d7325ac&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D1326fa26d0c00d2146c63b56bb6a45149d7325ac x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=0&common=1326fa26d0c00d2146c63b56bb6a45149d7325ac&heads=1326fa26d0c00d2146c63b56bb6a45149d7325ac&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=0 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D65903cebad86f1a84bd4f1134f62fa7dcb7a1c98 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=0&common=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&heads=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=0 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=31ecbdafd357f54b281c9bd1d681bb90de219e22&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D31ecbdafd357f54b281c9bd1d681bb90de219e22 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=0&common=31ecbdafd357f54b281c9bd1d681bb90de219e22&heads=31ecbdafd357f54b281c9bd1d681bb90de219e22&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
 
   $ killdaemons.py
   $ rm hg1.pid error.log access.log
@@ -485,6 +543,22 @@
   commit: (clean)
   update: 4 new changesets (update)
 
+Sharing a local repo without the locally referenced subrepo (i.e. it was never
+updated from null), fails the same as a clone operation.
+
+  $ hg --config progress.disable=True clone -U ../empty ../empty2
+
+  $ hg --config extensions.share= --config progress.disable=True \
+  >    share ../empty2 ../empty_share
+  updating working directory
+  abort: repository $TESTTMP/empty2/foo not found!
+  [255]
+
+  $ hg --config progress.disable=True clone ../empty2 ../empty_clone
+  updating to branch default
+  abort: repository $TESTTMP/empty2/foo not found!
+  [255]
+
 Disable progress extension and cleanup:
 
   $ mv $HGRCPATH.no-progress $HGRCPATH
--- a/tests/test-subrepo-relative-path.t	Sat Mar 03 15:31:37 2018 -0800
+++ b/tests/test-subrepo-relative-path.t	Sun Mar 04 10:42:51 2018 -0500
@@ -72,6 +72,87 @@
    source   ../sub
    revision 863c1745b441bd97a8c4a096e87793073f4fb215
 
+Test sharing with a remote URL reference
+
+  $ hg init absolute_subrepo
+  $ cd absolute_subrepo
+  $ echo foo > foo.txt
+  $ hg ci -Am 'initial commit'
+  adding foo.txt
+  $ echo "sub = http://localhost:$HGPORT/sub" > .hgsub
+  $ hg ci -Am 'add absolute subrepo'
+  adding .hgsub
+  $ cd ..
+
+Clone pooling works for local clones with a remote subrepo reference.  The
+subrepo is cloned to the pool and shared from there, so that all clones will
+share the same subrepo.
+
+  $ hg --config extensions.share= --config share.pool=$TESTTMP/pool \
+  >    clone absolute_subrepo cloned_from_abs
+  (sharing from new pooled repository 8d6a2f1e993b34b6557de0042cfe825ae12a8dae)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 3 changes to 3 files
+  new changesets 8d6a2f1e993b:* (glob)
+  searching for changes
+  no changes found
+  updating working directory
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  (sharing from new pooled repository 863c1745b441bd97a8c4a096e87793073f4fb215)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  searching for changes
+  no changes found
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Vanilla sharing with a subrepo remote path reference will clone the subrepo.
+Each share of these top level repos will end up with independent subrepo copies
+(potentially leaving the shared parent with dangling cset references).
+
+  $ hg --config extensions.share= share absolute_subrepo shared_from_abs
+  updating working directory
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg --config extensions.share= share -U absolute_subrepo shared_from_abs2
+  $ hg -R shared_from_abs2 update -r tip
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+A parent repo without its subrepo available locally can be shared if the
+subrepo is referenced by absolute path.
+
+  $ hg clone -U absolute_subrepo cloned_null_from_abs
+  $ hg --config extensions.share= share cloned_null_from_abs shared_from_null_abs
+  updating working directory
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
   $ killdaemons.py
 
 subrepo paths with ssh urls