Patchwork D1551: remotenames: consider existing data while storing newer data

login
register
mail settings
Submitter phabricator
Date Dec. 5, 2017, 10:23 p.m.
Message ID <9d3de7f02cb22dddd587ec2dc28ce155@localhost.localdomain>
Download mbox | patch
Permalink /patch/25953/
State Not Applicable
Headers show

Comments

phabricator - Dec. 5, 2017, 10:23 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2ea6e42ed15e: remotenames: consider existing data while storing newer data (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1551?vs=3974&id=4142

REVISION DETAIL
  https://phab.mercurial-scm.org/D1551

AFFECTED FILES
  mercurial/remotenames.py
  tests/test-remotenames.t

CHANGE DETAILS




To: pulkit, #hg-reviewers, durin42
Cc: durin42, dlax, mercurial-devel

Patch

diff --git a/tests/test-remotenames.t b/tests/test-remotenames.t
--- a/tests/test-remotenames.t
+++ b/tests/test-remotenames.t
@@ -102,10 +102,15 @@ 
   $ cat .hg/remotenames/bookmarks
   0
   
+  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00file:$TESTTMP/server\x00foo (esc)
+  87d6d66763085b629e6d7ed56778c79827273022\x00file:$TESTTMP/server\x00bar (esc)
   87d6d66763085b629e6d7ed56778c79827273022\x00file:$TESTTMP/server2\x00bar (esc)
   62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00file:$TESTTMP/server2\x00foo (esc)
+
   $ cat .hg/remotenames/branches
   0
   
+  3e1487808078543b0af6d10dadf5d46943578db0\x00file:$TESTTMP/server\x00wat (esc)
+  ec2426147f0e39dbc9cef599b066be6035ce691d\x00file:$TESTTMP/server\x00default (esc)
   ec2426147f0e39dbc9cef599b066be6035ce691d\x00file:$TESTTMP/server2\x00default (esc)
   3e1487808078543b0af6d10dadf5d46943578db0\x00file:$TESTTMP/server2\x00wat (esc)
diff --git a/mercurial/remotenames.py b/mercurial/remotenames.py
--- a/mercurial/remotenames.py
+++ b/mercurial/remotenames.py
@@ -64,6 +64,12 @@ 
     # version '0' represents the very initial version of the storage format
     f.write('0\n\n')
 
+    olddata = set(readremotenamefile(repo, nametype))
+    # re-save the data from a different remote than this one.
+    for node, oldpath, rname in sorted(olddata):
+        if oldpath != remotepath:
+            f.write('%s\0%s\0%s\n' % (node, oldpath, rname))
+
     for name, node in sorted(names.iteritems()):
         if nametype == "branches":
             for n in node: