diff options
author | Tristan Seligmann <mithrandi@debian.org> | 2017-08-11 11:50:14 +0200 |
---|---|---|
committer | Tristan Seligmann <mithrandi@debian.org> | 2017-08-11 11:50:14 +0200 |
commit | f505a84d33c238a892064774ca31854d3b5b1df2 (patch) | |
tree | a67f8519abfc6a529260814e24809d62356fc46a /hgsubversion/wrappers.py | |
parent | ef9caf1c5d12cf3a5886c1eb3ff5bb956fdf482f (diff) |
Upstream snapsnot 1.8.7+1517-b3e41b0d50a2
Diffstat (limited to 'hgsubversion/wrappers.py')
-rw-r--r-- | hgsubversion/wrappers.py | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py index 8a74ed7..f818a6f 100644 --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -1,3 +1,6 @@ +import inspect +import os + from hgext import rebase as hgrebase from mercurial import cmdutil @@ -18,8 +21,8 @@ from mercurial import repair from mercurial import revset from mercurial import scmutil +import inspect import layouts -import os import replay import pushmod import stupid as stupidmod @@ -103,7 +106,7 @@ def incoming(orig, ui, repo, origsource='default', **opts): meta = repo.svnmeta(svn.uuid, svn.subdir) ui.status('incoming changes from %s\n' % other.svnurl) - svnrevisions = list(svn.revisions(start=meta.lastpulled)) + svnrevisions = list(svn.revisions(start=meta.revmap.lastpulled)) if opts.get('newest_first'): svnrevisions.reverse() # Returns 0 if there are incoming changes, 1 otherwise. @@ -133,7 +136,12 @@ def findcommonoutgoing(repo, other, onlyheads=None, force=False, common, heads = util.outgoing_common_and_heads(repo, hashes, parent) outobj = getattr(discovery, 'outgoing', None) if outobj is not None: - # Mercurial 2.1 and later + argspec = inspect.getargspec(outobj.__init__) + if 'repo' in argspec[0]: + # Starting from Mercurial 3.9.1 outgoing.__init__ accepts + # `repo` object instead of a `changelog` + return outobj(repo, common, heads) + # Mercurial 2.1 through 3.9 return outobj(repo.changelog, common, heads) # Mercurial 2.0 and earlier return common, heads @@ -199,11 +207,13 @@ def push(repo, dest, force, revs): old_encoding = util.swap_out_encoding() try: - hasobsolete = obsolete._enabled + hasobsolete = (obsolete._enabled or + obsolete.isenabled(repo, obsolete.createmarkersopt)) except: hasobsolete = False temporary_commits = [] + obsmarkers = [] try: # TODO: implement --rev/#rev support # TODO: do credentials specified in the URL still work? @@ -300,9 +310,7 @@ def push(repo, dest, force, revs): if meta.get_source_rev(ctx=c)[0] == pushedrev.revnum: # This is corresponds to the changeset we just pushed if hasobsolete: - ui.note('marking %s as obsoleted by %s\n' % - (original_ctx.hex(), c.hex())) - obsolete.createmarkers(repo, [(original_ctx, [c])]) + obsmarkers.append([(original_ctx, [c])]) tip_ctx = c @@ -343,10 +351,18 @@ def push(repo, dest, force, revs): finally: util.swap_out_encoding() - if not hasobsolete: - # strip the original changesets since the push was - # successful and changeset obsolescence is unavailable - util.strip(ui, repo, outgoing, "all") + with repo.lock(): + if hasobsolete: + for marker in obsmarkers: + obsolete.createmarkers(repo, marker) + beforepush = marker[0][0] + afterpush = marker[0][1][0] + ui.note('marking %s as obsoleted by %s\n' % + (beforepush.hex(), afterpush.hex())) + else: + # strip the original changesets since the push was + # successful and changeset obsolescence is unavailable + util.strip(ui, repo, outgoing, "all") finally: try: # It's always safe to delete the temporary commits. @@ -358,11 +374,12 @@ def push(repo, dest, force, revs): parent = repo[None].p1() if parent.node() in temporary_commits: hg.update(repo, parent.p1().node()) - if hasobsolete: - relations = ((repo[n], ()) for n in temporary_commits) - obsolete.createmarkers(repo, relations) - else: - util.strip(ui, repo, temporary_commits, backup=None) + with repo.lock(): + if hasobsolete: + relations = ((repo[n], ()) for n in temporary_commits) + obsolete.createmarkers(repo, relations) + else: + util.strip(ui, repo, temporary_commits, backup=None) finally: util.swap_out_encoding(old_encoding) @@ -413,8 +430,7 @@ def pull(repo, source, heads=[], force=False, meta=None): meta.branchmap['default'] = meta.branch ui = repo.ui - start = meta.lastpulled - origrevcount = len(meta.revmap) + start = meta.revmap.lastpulled if start <= 0: # we are initializing a new repository @@ -507,7 +523,7 @@ def pull(repo, source, heads=[], force=False, meta=None): util.swap_out_encoding(old_encoding) if lastpulled is not None: - meta.lastpulled = lastpulled + meta.revmap.lastpulled = lastpulled revisions = len(meta.revmap) - oldrevisions if revisions == 0: @@ -590,6 +606,7 @@ def rebase(orig, ui, repo, **opts): optionmap = { 'tagpaths': ('hgsubversion', 'tagpaths'), 'authors': ('hgsubversion', 'authormap'), + 'mapauthorscmd': ('hgsubversion', 'mapauthorscmd'), 'branchdir': ('hgsubversion', 'branchdir'), 'trunkdir': ('hgsubversion', 'trunkdir'), 'infix': ('hgsubversion', 'infix'), @@ -646,9 +663,13 @@ def clone(orig, ui, source, dest=None, **opts): # calling hg.clone directoly to get the repository instances it returns, # breaks in subtle ways, so we double-wrap - orighgclone = extensions.wrapfunction(hg, 'clone', hgclonewrapper) - orig(ui, source, dest, **opts) - hg.clone = orighgclone + orighgclone = None + try: + orighgclone = extensions.wrapfunction(hg, 'clone', hgclonewrapper) + orig(ui, source, dest, **opts) + finally: + if orighgclone: + hg.clone = orighgclone # do this again; the ui instance isn't shared between the wrappers if data.get('branches'): @@ -660,7 +681,7 @@ def clone(orig, ui, source, dest=None, **opts): if dstrepo.local() and srcrepo.capable('subversion'): dst = dstrepo.local() - fd = dst.opener("hgrc", "a", text=True) + fd = dst.vfs("hgrc", "a", text=True) preservesections = set(s for s, v in optionmap.itervalues()) preservesections |= extrasections for section in preservesections: |