Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 41 additions & 39 deletions book/09-git-and-other-scms/sections/import-p4.asc
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
==== Perforce

(((Perforce)))(((Importing, from Perforce)))
The next system you'll look at importing from is Perforce.
As we discussed above, there are two ways to let Git and Perforce talk to each other: git-p4 and Perforce Git Fusion.
El siguiente sistema que verá importando es Perforce
Como mencionamos anteriormente, hay dos formas de que Git y Perforce hablen entre sí: git-p4 y Perforce Git Fusion.

===== Perforce Git Fusion

Git Fusion makes this process fairly painless.
Just configure your project settings, user mappings, and branches using a configuration file (as discussed in <<_p4_git_fusion>>), and clone the repository.
Git Fusion leaves you with what looks like a native Git repository, which is then ready to push to a native Git host if you desire.
You could even use Perforce as your Git host if you like.
Git Fusion hace que este proceso sea bastante sencillo.
Simplemente elija la configuración de su proyecto, las asignaciones de usuario y las ramas con un archivo de configuración (como se explica en << _ p4_git_fusion >>) y clone el repositorio.
Git Fusion te deja con lo que parece ser un repositorio nativo de Git, que luego está listo para enviar a un host nativo de Git si lo deseas.
Incluso puede usar Perforce como su host Git si gusta.


[[_git_p4]]
===== Git-p4

Git-p4 can also act as an import tool.
As an example, we'll import the Jam project from the Perforce Public Depot.
To set up your client, you must export the P4PORT environment variable to point to the Perforce depot:
Git-p4 también puede actuar como una herramienta de importación.
Como ejemplo, importaremos el proyecto Jam desde Perforce Public Depot.
Para configurar su cliente, debe exportar la variable de entorno P4PORT para que se dirija al depósito de Perforce:


[source,console]
----
Expand All @@ -26,53 +28,53 @@ $ export P4PORT=public.perforce.com:1666

[NOTE]
====
In order to follow along, you'll need a Perforce depot to connect with.
We'll be using the public depot at public.perforce.com for our examples, but you can use any depot you have access to.
Para poder seguir, necesitarás un depósito de Perforce para conectarte.
Utilizaremos el depósito público en public.perforce.com para ver nuestros ejemplos, pero puede usar cualquier depósito al que tenga acceso.
====

(((git commands, p4)))
Run the `git p4 clone` command to import the Jam project from the Perforce server, supplying the depot and project path and the path into which you want to import the project:
Ejecute el comando `git p4 clone` para importar el proyecto Jam desde el servidor Perforce, proporcionando la ruta de depósito y proyecto y la ruta en la que desea importar el proyecto:

[source,console]
----
$ git-p4 clone //guest/perforce_software/jam@all p4import
Importing from //guest/perforce_software/jam@all into p4import
Initialized empty Git repository in /private/tmp/p4import/.git/
Import destination: refs/remotes/p4/master
Importing revision 9957 (100%)
Importación desde //guest/perforce_software/jam@all into p4import
Inicializó el repositorio vacío de Git en /private/tmp/p4import/.git/
Destino de importación: refs/remotes/p4/master
Importando revisión 9957 (100%)
----

This particular project has only one branch, but if you have branches that are configured with branch views (or just a set of directories), you can use the `--detect-branches` flag to `git p4 clone` to import all the project's branches as well.
See <<_git_p4_branches>> for a bit more detail on this.
Este proyecto en particular tiene solo una rama, pero esta configurado con vistas de ramificaciones (o simplemente un conjunto de directorios), y puede usar el indicador `--detect-branches` en` git p4 clone` para importar todas las ramas del proyecto. Ver << _ git_p4_branches >> para un poco más de detalle sobre esto.

At this point you're almost done.
If you go to the `p4import` directory and run `git log`, you can see your imported work:
En este punto, casi has terminado.
Si va al directorio `p4import` y ejecuta` git log`, puede ver su trabajo importado:

[source,console]
----
$ git log -2
commit e5da1c909e5db3036475419f6379f2c73710c4e6
Author: giles <giles@giles@perforce.com>
Date: Wed Feb 8 03:13:27 2012 -0800
Autor: giles <giles@giles@perforce.com>
Información: Wed Feb 8 03:13:27 2012 -0800

Correction to line 355; change </UL> to </OL>.
Corrección a línea 355; change </UL> to </OL>.

[git-p4: depot-paths = "//public/jam/src/": change = 8068]

commit aa21359a0a135dda85c50a7f7cf249e4f7b8fd98
Author: kwirth <kwirth@perforce.com>
Date: Tue Jul 7 01:35:51 2009 -0800
Autor: kwirth <kwirth@perforce.com>
Información: Tue Jul 7 01:35:51 2009 -0800

Fix spelling error on Jam doc page (cummulative -> cumulative).
Corrige el error de ortografía en la página Jam doc (cummulative -> cumulative).

[git-p4: depot-paths = "//public/jam/src/": change = 7304]
----

You can see that `git-p4` has left an identifier in each commit message.
It's fine to keep that identifier there, in case you need to reference the Perforce change number later.
However, if you'd like to remove the identifier, now is the time to do so – before you start doing work on the new repository.
(((git commands, filter-branch)))
You can use `git filter-branch` to remove the identifier strings en masse:
Puede ver que `git-p4` ha dejado un identificador en cada mensaje de confirmación.
Está bien mantener ese identificador allí, en caso de que necesite hacer referencia al número de cambio Perforce más adelante.
Sin embargo, si desea eliminar el identificador, ahora es el momento de hacerlo, antes de comenzar a trabajar en el nuevo repositorio.
(((comandos git, filter-branch)))
Puede usar `git filter-branch` para eliminar las cadenas de identificador en masa:


[source,console]
----
Expand All @@ -81,22 +83,22 @@ Rewrite e5da1c909e5db3036475419f6379f2c73710c4e6 (125/125)
Ref 'refs/heads/master' was rewritten
----

If you run `git log`, you can see that all the SHA-1 checksums for the commits have changed, but the `git-p4` strings are no longer in the commit messages:
Si ejecuta `git log`, puede ver que todas las sumas de comprobación SHA-1 para las confirmaciones han cambiado, pero las cadenas` git-p4` ya no se encuentran en los mensajes de confirmación:

[source,console]
----
$ git log -2
commit b17341801ed838d97f7800a54a6f9b95750839b7
Author: giles <giles@giles@perforce.com>
Date: Wed Feb 8 03:13:27 2012 -0800
Autor: giles <giles@giles@perforce.com>
Información: Wed Feb 8 03:13:27 2012 -0800

Correction to line 355; change </UL> to </OL>.
Corrección a linea 355; change </UL> to </OL>.

commit 3e68c2e26cd89cb983eb52c024ecdfba1d6b3fff
Author: kwirth <kwirth@perforce.com>
Date: Tue Jul 7 01:35:51 2009 -0800
Autor: kwirth <kwirth@perforce.com>
Información: Tue Jul 7 01:35:51 2009 -0800

Fix spelling error on Jam doc page (cummulative -> cumulative).
Corrige el error de ortografía en la página Jam doc (cummulative -> cumulative).
----

Your import is ready to push up to your new Git server.
Su importación está lista para subir a su nuevo servidor Git.
47 changes: 16 additions & 31 deletions book/09-git-and-other-scms/sections/import-svn.asc
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
==== Subversion
==== Subversión

(((Subversion)))
(((Importing, from Subversion)))
If you read the previous section about using `git svn`, you can easily use those instructions to `git svn clone` a repository; then, stop using the Subversion server, push to a new Git server, and start using that.
If you want the history, you can accomplish that as quickly as you can pull the data out of the Subversion server (which may take a while).
Si lee la sección anterior sobre el uso de git svn, usted puede usar fácilmente esas instrucciones para clonar un repositorio; luego, deje de usar el servidor de Subversión, presione en un nuevo servidor de Git y comience a usarlo. Si desea ver el historial, puede lograrlo tan rápido como pueda extraer los datos del servidor de Subversión (lo que puede llevar un tiempo).

However, the import isn't perfect; and because it will take so long, you may as well do it right.
The first problem is the author information.
In Subversion, each person committing has a user on the system who is recorded in the commit information.
The examples in the previous section show `schacon` in some places, such as the `blame` output and the `git svn log`.
If you want to map this to better Git author data, you need a mapping from the Subversion users to the Git authors.
Create a file called `users.txt` that has this mapping in a format like this:
Sin embargo, la importación no es perfecta; y porque tomará tanto tiempo, también puedes hacerlo bien. El primer problema es la información del autor. En Subversión, cada persona comprometida tiene un usuario en el sistema que está registrado en la información de confirmación. Los ejemplos en la sección anterior muestran schacon en algunos lugares, como la salida de culpa y el registro de git svn. Si desea asignar esto a mejores datos de autor de Git, necesita una asignación de los usuarios de Subversión a los autores de Git. Cree un archivo llamado users.txt que tenga esta asignación en un formato como este:

[source]
----
schacon = Scott Chacon <schacon@geemail.com>
selse = Someo Nelse <selse@geemail.com>
----

To get a list of the author names that SVN uses, you can run this:
Para obtener una lista de los nombres de autor que utilizan SVN, puede ejecutar esto:

[source,console]
----
$ svn log --xml | grep author | sort -u | \
perl -pe 's/.*>(.*?)<.*/$1 = /'
----

That generates the log output in XML format, then keeps only the lines with author information, discards duplicates, strips out the XML tags.
(Obviously this only works on a machine with `grep`, `sort`, and `perl` installed.)
Then, redirect that output into your users.txt file so you can add the equivalent Git user data next to each entry.
Eso genera la salida del registro en formato XML, luego mantiene solo las líneas con la información del autor, descarta los duplicados y elimina las etiquetas XML. (Obviamente, esto solo funciona en una máquina con grep, sort y perl instalados). Luego, redirija esa salida a su archivo users.txt para que pueda agregar los datos de usuario equivalentes de Git al lado de cada entrada.

You can provide this file to `git svn` to help it map the author data more accurately.
You can also tell `git svn` not to include the metadata that Subversion normally imports, by passing `--no-metadata` to the `clone` or `init` command.
This makes your `import` command look like this:
Puede proporcionar este archivo a git svn para ayudarlo a mapear los datos del autor con mayor precisión. También puede indicarle a git svn que no incluya los metadatos que normalmente importa Subversión, pasando --no-metadata al comando clone o init. Esto hace que su comando de importación se vea así:

[source,console]
----
$ git svn clone http://my-project.googlecode.com/svn/ \
--authors-file=users.txt --no-metadata -s my_project
----

Now you should have a nicer Subversion import in your `my_project` directory.
Instead of commits that look like this
Ahora debería tener una importación de Subversión más agradable en su directorio my_project. En lugar de commits que se ven así

[source]
----
Expand All @@ -55,7 +44,7 @@ Date: Sun May 3 00:12:22 2009 +0000
be05-5f7a86268029
----

they look like this:
se ven así:

[source]
----
Expand All @@ -66,44 +55,40 @@ Date: Sun May 3 00:12:22 2009 +0000
fixed install - go to trunk
----

Not only does the Author field look a lot better, but the `git-svn-id` is no longer there, either.
No solo el campo Autor se ve mucho mejor, sino que el git-svn-id ya no está allí.

You should also do a bit of post-import cleanup.
For one thing, you should clean up the weird references that `git svn` set up.
First you'll move the tags so they're actual tags rather than strange remote branches, and then you'll move the rest of the branches so they're local.
También debería hacer un poco de limpieza posterior a la importación. Por un lado, debe limpiar las referencias raras que git svn configuró. Primero moverá las etiquetas para que sean etiquetas reales en lugar de ramas remotas extrañas, y luego moverá el resto de las ramas para que sean locales.

To move the tags to be proper Git tags, run
Para mover las etiquetas para que sean etiquetas Git correctas, ejecuta

[source,console]
----
$ cp -Rf .git/refs/remotes/origin/tags/* .git/refs/tags/
$ rm -Rf .git/refs/remotes/origin/tags
----

This takes the references that were remote branches that started with `remotes/origin/tags/` and makes them real (lightweight) tags.
Esto toma las referencias que eran ramas remotas que comenzaron con controles remotos / origen / etiquetas / y las convierte en etiquetas reales (ligeras).

Next, move the rest of the references under `refs/remotes` to be local branches:
A continuación, mueva el resto de las referencias en refs / remotes para que sean sucursales locales:

[source,console]
----
$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes
----

Now all the old branches are real Git branches and all the old tags are real Git tags.
The last thing to do is add your new Git server as a remote and push to it.
Here is an example of adding your server as a remote:
Ahora todas las ramas antiguas son ramas reales de Git y todas las etiquetas antiguas son etiquetas Git reales. Lo último que debe hacer es agregar su nuevo servidor Git como un control remoto y pulsarlo. Aquí hay un ejemplo de cómo agregar su servidor como un control remoto:

[source,console]
----
$ git remote add origin git@my-git-server:myrepository.git
----

Because you want all your branches and tags to go up, you can now run this:
Como quiere que todas sus ramas y etiquetas suban, ahora puede ejecutar esto:

[source,console]
----
$ git push origin --all
----

All your branches and tags should be on your new Git server in a nice, clean import.
Todas sus ramas y etiquetas deben estar en su nuevo servidor Git en una importación agradable y limpia..